Error System¶
Grammar checking uses three components: CG3 error tags, errors.json mapping, and Fluent message files.
errors.json Mapping¶
Maps error tags to Fluent message IDs. These lists of matches may either be error IDs as emitted by the CG3 output, or a regular expression that matches those.
Simple Mapping¶
Regex Patterns¶
Matches any error tag starting with lex-
or msyn-
.
Multiple Mappings¶
First match wins:
{
"agreement-errors": [
{ "id": "agr-subj-verb" },
{ "id": "agr-noun-adj" },
{ "re": "^agr-.*" }
]
}
Fluent Message Files¶
Note
The format used in the .ftl is unstable and subject to change, as it is presently a rudimentary port of the errors.xml functionality. Things like using € replacements are highly likely to change.
Create errors-{locale}.ftl
files in assets/
:
spelling-error = Spelling error
.desc = The word {$1} is not in the dictionary.
agr-noun-adj = Agreement error
.desc = The adjective {$1} should agree with the noun {$2}.
msyn-verb-form = Wrong verb form
.desc = After "has", use the past participle "gone" not {$1}.
Parameters¶
{$1}
- Error word (always available){$2}
,{$3}
- Context words from CG3 relations€1
,€2
- Suggestions (replaced with actual values)
Multi-Locale Example¶
errors-en.ftl:
errors-fo.ftl:
Select locale at runtime:
Complete Workflow¶
-
Tag error in CG3:
-
Map in errors.json:
-
Create message in .ftl:
-
Test:
Output:
{
"form": "mispeled",
"beg": 0,
"end": 8,
"err": "typo",
"msg": ["Spelling error", "The word mispeled is not in the dictionary."],
"rep": ["misspelled"]
}
Error Tag Naming¶
Use consistent prefixes:
typo
- Spelling errorsmsyn-*
- Morphosyntactic errorslex-*
- Lexical selectionagr-*
- Agreement errorsreal-word-error
- Wrong word (correct spelling)
File Structure¶
Common Patterns¶
Spelling¶
Grammar¶
Lexical¶
Error Tags in CG3¶
CG3 rules tag errors using &
prefix:
COERROR Tags¶
Related errors use co&
prefix: