Performs text proofreading and grammar correction on input text.
Signature:
export declare class TextProofreader extends TaskRunner
Extends: TaskRunner
Methods
| Method | Modifiers | Description |
|---|---|---|
| close() | Cleans up the resources held by the TextProofreader. | |
| createFromModelBuffer(wasmFileset, modelAssetBuffer, maxNumTokens) | static |
Initializes the Wasm runtime and creates a new text proofreader based on the provided model asset buffer. |
| createFromModelPath(wasmFileset, modelAssetPath, maxNumTokens) | static |
Initializes the Wasm runtime and creates a new text proofreader based on the path to the model asset. |
| createFromOptions(wasmFileset, textProofreaderOptions) | static |
Initializes the Wasm runtime and creates a new text proofreader from the provided options. |
| proofread(text) | Proofreads the provided text synchronously and returns the corrected text along with diff segments. | |
| proofreadStreaming(text, progressListener) | Proofreads the provided text with streaming token callbacks and resolves with the final TextProofreaderResult. |
|
| setOptions(options) | Sets new options for the text proofreader. |
TextProofreader.close()
Cleans up the resources held by the TextProofreader.
Signature:
close(): void;
Returns:
void
TextProofreader.createFromModelBuffer()
Initializes the Wasm runtime and creates a new text proofreader based on the provided model asset buffer.
Signature:
static createFromModelBuffer(wasmFileset: WasmFileset, modelAssetBuffer: Uint8Array | ReadableStreamDefaultReader, maxNumTokens?: number): Promise<TextProofreader>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| wasmFileset | WasmFileset | A configuration object that provides the location of the Wasm binary and its loader. |
| modelAssetBuffer | Uint8Array | ReadableStreamDefaultReader | A binary representation of the model or a stream reader. |
| maxNumTokens | number | Optional maximum number of tokens for input and output combined. |
Returns:
Promise<TextProofreader>
TextProofreader.createFromModelPath()
Initializes the Wasm runtime and creates a new text proofreader based on the path to the model asset.
Signature:
static createFromModelPath(wasmFileset: WasmFileset, modelAssetPath: TrustedResourceUrl | string, maxNumTokens?: number): Promise<TextProofreader>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| wasmFileset | WasmFileset | A configuration object that provides the location of the Wasm binary and its loader. |
| modelAssetPath | TrustedResourceUrl | string | The path to the model asset. |
| maxNumTokens | number | Optional maximum number of tokens for input and output combined. |
Returns:
Promise<TextProofreader>
TextProofreader.createFromOptions()
Initializes the Wasm runtime and creates a new text proofreader from the provided options.
Signature:
static createFromOptions(wasmFileset: WasmFileset, textProofreaderOptions: TextProofreaderOptions): Promise<TextProofreader>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| wasmFileset | WasmFileset | A configuration object that provides the location of the Wasm binary and its loader. |
| textProofreaderOptions | TextProofreaderOptions | The options for the text proofreader. |
Returns:
Promise<TextProofreader>
TextProofreader.proofread()
Proofreads the provided text synchronously and returns the corrected text along with diff segments.
Signature:
proofread(text: string): TextProofreaderResult;
Parameters
| Parameter | Type | Description |
|---|---|---|
| text | string | The input text to proofread. |
Returns:
TextProofreader.proofreadStreaming()
Proofreads the provided text with streaming token callbacks and resolves with the final TextProofreaderResult.
Signature:
proofreadStreaming(text: string, progressListener?: (partialText: string, done: boolean) => void): Promise<TextProofreaderResult>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| text | string | The input text to proofread. |
| progressListener | (partialText: string, done: boolean) => void | Optional callback invoked with incremental generated text chunks. |
Returns:
Promise<TextProofreaderResult>
TextProofreader.setOptions()
Sets new options for the text proofreader.
Signature:
setOptions(options: TextProofreaderOptions): Promise<void>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| options | TextProofreaderOptions | The options for the text proofreader. |
Returns:
Promise<void>