Skip to content

Commit bdbe8fd

Browse files
committed
Update API shape to support multiple labels per correction.
1 parent dfce5aa commit bdbe8fd

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Web applications can also benefit from such proofreading capability. This propos
99

1010

1111
1. Error Correction: Correct input text by the user
12-
2. Error Labeling: For each correction made to each error in the input text, label the error type (e.g. spelling, punctuation, etc.)
12+
2. Error Labeling: For each correction made to each error in the input text, label the error type(s) (e.g. spelling, punctuation, etc.)
1313
3. Error Explanation: Annotates each error with a plain language explanation
1414

1515
Note that Labeling & Explanation are independent features that can be either added or dropped.
@@ -50,7 +50,7 @@ const proofreader = await Proofreader.create({
5050
const corrections = await proofreader.proofread("I seen him yesterday at the store, and he bought two loafs of bread.");
5151
```
5252

53-
`proofread()` corrects the input text and returns a list of corrections made. Additional proofreading features can be configured using includeCorrectionTypes and `includeCorrectionExplanations`. When `includeCorrectionTypes` is set to `true`, `proofread()` will provide an error type label for each correction made to each error. When `includeCorrectionExplanations` is set to `true`, `proofread()` will provide an annotation for each error with a plain language explanation.
53+
`proofread()` corrects the input text and returns a list of corrections made. Additional proofreading features can be configured using includeCorrectionTypes and `includeCorrectionExplanations`. When `includeCorrectionTypes` is set to `true`, `proofread()` will provide the error type labels associated for each correction made to each error. When `includeCorrectionExplanations` is set to `true`, `proofread()` will provide an annotation for each error with a plain language explanation.
5454

5555
Detailed design for the corrections output is [discussed later](#proofreading-correction-output).
5656

@@ -197,7 +197,7 @@ dictionary ProofreadCorrection {
197197
unsigned long long startIndex;
198198
unsigned long long endIndex;
199199
DOMString correction;
200-
CorrectionType type; // exists if proofreader.includeCorrectionTypes === true
200+
sequence<CorrectionType> type; // exists if proofreader.includeCorrectionTypes === true
201201
DOMString explanation; // exists if proofreader.includeCorrectionExplanations === true
202202
}
203203
@@ -206,6 +206,14 @@ enum CorrectionType { "spelling", "punctuation", "capitalization", "preposition"
206206

207207
`type` only exists when the proofreader object is configured with `includeCorrectionTypes = true`, while `explanation` only exists when the proofreader object is configured with `includeCorrectionExplanations = true`.
208208

209+
Each correction could be associated with mutliple correction type labels. For example:
210+
211+
```js
212+
const original_text = "`thatd` a good amt of time!!! !" // `thatd` is the text to be corrected
213+
const proofread_text = "`That's` a good amount of time!" // `That's` is the corrected text
214+
```
215+
where the correction from "thatd" to "That's" contains three types of correction - "Captilization", "Spelling" and "Punctuation". When there's only one label, the sequence will be of size 1.
216+
209217
Not all correction types here will be applicable to all languages, and in the future we might propose more specific correction types. The generic catch-all type, if no more-specific type matches, is `"grammar"`.
210218

211219
To get an error in the input, use `input.substring(startIndex, endIndex)`. Corrections in the `corrections` list will be organized in ascending order based on the `startIndex` of the correction.

0 commit comments

Comments
 (0)