# TextProofreader

    class TextProofreader: NSObject

Performs proofreading on text.

This API expects a LiteRT-LM model asset bundle.
- `
  ### [init(modelPath:)](https://developers.google.com/edge/api/mediapipe/swift/text/Classes/TextProofreader.md.txt#/c:objc(cs)MPPTextProofreader(im)initWithModelPath:error:)

  ` Creates a new instance of `MPPTextProofreader` from an absolute path to a model asset bundle stored locally on the device and the default `MPPTextProofreaderOptions`.

  #### Declaration

  Swift

      convenience init(modelPath: String) throws

  #### Parameters

  |---|---|
  | `modelPath` | An absolute path to a model file stored locally on the device. |
  | `error` | An optional error parameter populated when there is an error in initializing the text proofreader. |

  #### Return Value

  A new instance of `MPPTextProofreader` with the given model path. `nil` if there is an error in initializing the text proofreader.
- `
  ### [init(options:)](https://developers.google.com/edge/api/mediapipe/swift/text/Classes/TextProofreader.md.txt#/c:objc(cs)MPPTextProofreader(im)initWithOptions:error:)

  ` Creates a new instance of `MPPTextProofreader` from the given `MPPTextProofreaderOptions`.

  #### Declaration

  Swift

      init(options: TextProofreaderOptions) throws

  #### Parameters

  |---|---|
  | `options` | The options of type `MPPTextProofreaderOptions` to use for configuring the `MPPTextProofreader`. |
  | `error` | An optional error parameter populated when there is an error in initializing the text proofreader. |

  #### Return Value

  A new instance of `MPPTextProofreader` with the given options. `nil` if there is an error in initializing the text proofreader.
- `
  ### [close()](https://developers.google.com/edge/api/mediapipe/swift/text/Classes/TextProofreader.md.txt#/c:objc(cs)MPPTextProofreader(im)closeWithError:)

  ` Shuts down the `MPPTextProofreader` when all the work is done.

  #### Declaration

  Swift

      func close() throws

  #### Parameters

  |---|---|
  | `error` | An optional error parameter populated when there is an error in shutting down the text proofreader. |

  #### Return Value

  `YES` if the `MPPTextProofreader` was successfully closed, `NO` otherwise.
- `
  ### [proofread(text:)](https://developers.google.com/edge/api/mediapipe/swift/text/Classes/TextProofreader.md.txt#/c:objc(cs)MPPTextProofreader(im)proofreadText:error:)

  ` Performs proofreading on the input text.

  #### Declaration

  Swift

      func proofread(text: String) throws -> TextProofreaderResult

  #### Parameters

  |---|---|
  | `text` | The `NSString` on which proofreading is to be performed. |
  | `error` | An optional error parameter populated when there is an error in performing proofreading on the input text. |

  #### Return Value

  A `MPPTextProofreaderResult` object that contains the complete proofread result.
- `
  ### [proofreadStreaming(text:completion:)](https://developers.google.com/edge/api/mediapipe/swift/text/Classes/TextProofreader.md.txt#/c:objc(cs)MPPTextProofreader(im)proofreadStreamingWithText:completionHandler:error:)

  ` Performs proofreading on the input `text` and returns the result incrementally via the callback.

  #### Declaration

  Swift

      func proofreadStreaming(text: String, completion completionHandler: @escaping (TextProofreaderStreamResult?, (any Error)?) -> Void) throws

  #### Parameters

  |---|---|
  | `text` | The input text to be proofread. |
  | `completionHandler` | The completion handler invoked with the incremental proofreading result or an error. |
  | `error` | An optional error parameter populated when there is an error in initiating the proofreading on the input text. |

  #### Return Value

  `YES` if the stream proofreading was successfully initiated, `NO` otherwise.