TextProofreader
class TextProofreader: NSObjectPerforms proofreading on text.
This API expects a LiteRT-LM model asset bundle.
-
Creates a new instance of
MPPTextProofreaderfrom an absolute path to a model asset bundle stored locally on the device and the defaultMPPTextProofreaderOptions.Declaration
Swift
convenience init(modelPath: String) throwsParameters
modelPathAn absolute path to a model file stored locally on the device.
errorAn optional error parameter populated when there is an error in initializing the text proofreader.
Return Value
A new instance of
MPPTextProofreaderwith the given model path.nilif there is an error in initializing the text proofreader. -
Creates a new instance of
MPPTextProofreaderfrom the givenMPPTextProofreaderOptions.Declaration
Swift
init(options: TextProofreaderOptions) throwsParameters
optionsThe options of type
MPPTextProofreaderOptionsto use for configuring theMPPTextProofreader.errorAn optional error parameter populated when there is an error in initializing the text proofreader.
Return Value
A new instance of
MPPTextProofreaderwith the given options.nilif there is an error in initializing the text proofreader. -
Shuts down the
MPPTextProofreaderwhen all the work is done.Declaration
Swift
func close() throwsParameters
errorAn optional error parameter populated when there is an error in shutting down the text proofreader.
Return Value
YESif theMPPTextProofreaderwas successfully closed,NOotherwise. -
Performs proofreading on the input text.
Declaration
Swift
func proofread(text: String) throws -> TextProofreaderResultParameters
textThe
NSStringon which proofreading is to be performed.errorAn optional error parameter populated when there is an error in performing proofreading on the input text.
Return Value
A
MPPTextProofreaderResultobject that contains the complete proofread result. -
Performs proofreading on the input
textand returns the result incrementally via the callback.Declaration
Swift
func proofreadStreaming(text: String, completion completionHandler: @escaping (TextProofreaderStreamResult?, (any Error)?) -> Void) throwsParameters
textThe input text to be proofread.
completionHandlerThe completion handler invoked with the incremental proofreading result or an error.
errorAn optional error parameter populated when there is an error in initiating the proofreading on the input text.
Return Value
YESif the stream proofreading was successfully initiated,NOotherwise.