mp.tasks.text.TextProofreader

Performs proofreading on text.

Methods

close

View source

Shuts down the MediaPipe task instance.

create_from_model_path

View source

Creates a TextProofreader object from model path.

Args
model_path Path to the model.

Returns
TextProofreader object that's created from the model file and the default TextProofreaderOptions.

Raises
ValueError If failed to create TextProofreader object from the provided file such as invalid file path.
RuntimeError If other types of error occurred.

create_from_options

View source

Creates the TextProofreader object from text proofreader options.

Args
options Options for the text proofreader task.

Returns
TextProofreader object that's created from options.

Raises
ValueError If failed to create TextProofreader object from TextProofreaderOptions such as missing the model.
RuntimeError If other types of error occurred.

proofread

View source

Performs proofreading on the input text.

Args
text The input text.

Returns
A TextProofreaderResult object that contains the proofread text.

Raises
ValueError If any of the input arguments is invalid.
RuntimeError If proofreading failed to run.

proofread_async

View source

Performs proofreading on the input text asynchronously.

Args
text The input text.
result_callback A callback function that will be called with the TextProofreaderResult and an error message (if any).

Raises
ValueError If any of the input arguments is invalid, or if proofread_async is called before the previous call has finished.
RuntimeError If proofreading failed to run.

__enter__

View source

Returns self upon entering the runtime context.

__exit__

View source

Shuts down the MediaPipe task instance on exit of the context manager.