Overview
Architecture
The Grammar Engine coordinates six specialized checkers:Configuration
GrammarEngineConfig
GrammarRuleConfig
Load custom grammar rules from YAML:Grammar Rules
Rule Types
| Rule Type | Description | Example |
|---|---|---|
| Particle Typos | Common particle mistakes | ဘူ → ဘူး |
| Medial Confusions | Ya-pin vs Ra-yit | ကျောင်း → ကြောင်း |
| POS Sequences | Invalid tag combinations | N-N without particle |
| Verb-Particle | Verb ending agreement | Missing tense marker |
| Sentence Structure | Sentence completeness | Missing final particle |
Particle Typo Detection
Medial Confusion Detection
Detects common medial character confusions:| Confusion | Characters | Example |
|---|---|---|
| Ya-pin / Ra-yit | ျ / ြ | ကျွန် / ကြွန် |
| Wa-swe / Ha-htoe | ွ / ှ | ကွ / ကှ |
POS Sequence Validation
Validates POS tag sequences:| Sequence | Validity | Reason |
|---|---|---|
| N + V | Warning | Usually needs particle |
| V + V | Error* | Except auxiliaries |
| P_SENT + P_SENT | Error | Double sentence particles |
| N + P_SUBJ | Valid | Subject marking |
Verb-Particle Agreement
Sentence Structure Validation
Specialized Checkers
AspectChecker
Validates aspect markers (completion, continuation):ပြီ- Completionနေ- Continuationခဲ့- Pastမယ်- Future
ClassifierChecker
Validates Myanmar numeral classifiers:ယောက်- Peopleကောင်- Animalsလုံး- Round objectsခု- General objects
CompoundChecker
Validates compound words and reduplications:NegationChecker
Validates negation patterns:မ...ဘူး- Colloquial negativeမ...ပါ- Polite negativeမ...- Literary negative
RegisterChecker
Validates register consistency (formal vs colloquial):- Colloquial:
တယ်,ဘူး,မယ် - Formal:
သည်,ပါ,မည်
Confidence Scoring
Get confidence for suggestions:| Factor | Weight | Description |
|---|---|---|
| Exact match | 0.95 | Exact pattern match |
| Verb context | 0.90 | After verb validation |
| Noun context | 0.85 | After noun validation |
| Context dependent | 0.65 | Ambiguous context |
| Default | 0.80 | No specific context |
Integration with SpellChecker
The Grammar Engine integrates automatically via validation strategies when rule-based validation is enabled:GrammarEngineConfig) is managed internally. For advanced customization, use SyntacticRuleChecker directly with a custom config path.
Custom Rules
YAML Configuration
Loading Custom Rules
See Also
- Grammar Checkers - Individual checker details
- Validation Strategies - Strategy integration
- POS Tagging - POS tag reference
- Rules System - YAML rule files