MediaPipeTasksText Framework Reference

TextProofreader

final class TextProofreader

Corrects spelling and grammatical errors in input text and computes token-level diffs.

  • Creates a TextProofreader with default options using the model file at modelPath.

    Declaration

    Swift

    convenience init(modelPath: String) throws
  • Creates a TextProofreader configured with options.

    Declaration

    Swift

    init(options: TextProofreaderOptions) throws
  • Releases the underlying engine; subsequent calls are no-ops, and later proofreading calls throw TasksError with .failedPrecondition.

    Declaration

    Swift

    final func close() throws
  • Proofreads text synchronously and returns the corrected text and edit segments.

    Declaration

    Swift

    final func proofread(text: String) throws -> TextProofreaderResult
  • Streams incremental proofread chunks for text, concluding with a final element where isDone is true and corrections is populated.

    Cancelling the returned AsyncThrowingStream stops yielding elements immediately while the underlying C engine finishes draining the active generation, during which overlapping proofreading calls or close() throw TasksError with .failedPrecondition.

    Declaration

    Swift

    final func proofreadStreaming(text: String) -> AsyncThrowingStream<TextProofreaderStreamResult, any Error>