Visitar URL original
MediaPipeTasksText Framework Reference  |  Google AI Edge  |  Google for Developers

MediaPipeTasksText Framework Reference

TextProofreader

class TextProofreader: NSObject

Performs proofreading on text.

This API expects a LiteRT-LM model asset bundle.

  • 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.

    Return Value

    A new instance of MPPTextProofreader with the given model path. nil if there is an error in initializing the text proofreader.

  • 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.

    Return Value

    A new instance of MPPTextProofreader with the given options. nil if there is an error in initializing the text proofreader.

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

    Declaration

    Swift

    func close() throws
  • 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.

    Return Value

    A MPPTextProofreaderResult object that contains the complete proofread result.

  • 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.