Overview
Grammar rules are defined in YAML files and control syntactic validation including:- Invalid POS sequences (e.g., V-V, P-P patterns)
- Sentence boundary constraints
- Particle chain validation
- Register consistency (formal vs colloquial)
- Negation and classifier rules
Rule File Location
Default grammar rules are located at:YAML Schema
File Structure
Rule Categories
Sentence Constraints
Define what particles can or cannot appear at sentence boundaries:Invalid POS Sequences
Define patterns that indicate grammatical errors:Required Particles
Define when particles are typically required:Particle Chains
Define valid and invalid particle combinations:Register Rules
Check for consistency between formal and colloquial style:Negation Rules
Validate proper negation patterns:Classifier Rules
Validate numeral-classifier-noun patterns:Tag Definitions
Particle Tags
Map specific words to POS tags for validation:Interjection Tags
Severity Levels
| Level | Description | Action |
|---|---|---|
error | Clear grammatical error | Flag as error, suggest fix |
warning | Likely error, context-dependent | Flag with medium confidence |
info | Informational, may be intentional | Optional flag, low confidence |
Confidence Scores
Confidence ranges from 0.0 to 1.0:| Range | Meaning |
|---|---|
| 0.90-1.0 | Very high confidence, clear error |
| 0.70-0.89 | High confidence, likely error |
| 0.50-0.69 | Medium confidence, context-dependent |
| < 0.50 | Low confidence, informational |
Creating Custom Rules
Best Practices
1. Use Examples
Always include examples in rules:2. Include Exceptions
List valid exceptions to patterns:3. Set Appropriate Confidence
- High confidence (0.9+) for clear errors
- Medium confidence (0.6-0.8) for likely errors
- Low confidence (<0.5) for informational patterns
4. Group Related Rules
Organize rules by category for maintainability:Debugging Rules
Enable Grammar Debug Logging
Check Rule Matching
See Also
- Grammar Checking - Feature overview
- POS Tagging - Part-of-speech tagging
- Viterbi Algorithm - POS tagger implementation
- Error Types - Error type reference