How It Works
Syllable Assembly
After syllable validation, valid syllables are assembled into potential words:Dictionary Lookup
Assembled words are checked against the word dictionary:Suggestion Generation
For invalid words, SymSpell generates suggestions in O(1) time:SymSpell Algorithm
mySpellChecker uses the Symmetric Delete algorithm for fast suggestions:Traditional Approach (Slow)
SymSpell Approach (Fast)
Why It’s Fast
| Operation | Traditional | SymSpell |
|---|---|---|
| Single lookup | O(n × m) | O(1) |
| Scales with dictionary size | Slow (linear) | Very Fast (constant) |
Configuration
Enable Word Validation
Suggestion Settings
SymSpell Configuration
Word Error Types
Unknown Word
Word not found in dictionary:Misspelled Word
Word is close to a valid dictionary entry:Compound Error
Multiple syllable errors forming invalid word:Morphological Synthesis
Before generating errors, word validation checks if an OOV word is a productive formation from known dictionary words. This suppresses false positives on valid compounds and reduplications.Reduplication Validation
Myanmar creates valid words through reduplication (repeating syllables for emphasis):Compound Word Synthesis
Myanmar forms compounds by joining morphemes:Morpheme-Level Suggestions
When a compound word has a typo in one morpheme, the suggestion engine corrects that specific morpheme instead of suggesting unrelated words:Configuration
Enable/disable morphological synthesis inValidationConfig. Tune algorithm parameters
in the dedicated CompoundResolverConfig and ReduplicationConfig:
Suggestion Ranking
TheDefaultRanker scores suggestions using a multi-factor formula where lower scores indicate better suggestions:
| Factor | Effect | Description |
|---|---|---|
| Frequency bonus | Up to configurable ceiling | Asymptotic bonus based on corpus frequency |
| Phonetic bonus | Configurable weight | Rewards phonetically similar suggestions |
| Nasal bonus | Fixed weight | Rewards nasal variant matches (န် / ံ) |
| Same nasal bonus | Fixed weight | Rewards same nasal ending as input |
| POS fit bonus | Configurable weight | Rewards grammatically fitting suggestions (via POS bigrams) |
| Span bonus | Length-scaled | Prefers suggestions matching the error span length |
RankerConfig. Alternative rankers (FrequencyFirstRanker, PhoneticFirstRanker, EditDistanceOnlyRanker) emphasize different factors. See Suggestion Ranking for the full algorithm details.
Frequency-Based Ranking
Edit Distance Ranking
Performance Characteristics
| Metric | Value |
|---|---|
| Speed | Fast |
| Lookup Complexity | O(1) average |
| Suggestion Generation | O(k) where k = candidates |
API Reference
Using SpellChecker for Word Validation
WordValidator requires a DI container setup.
For most use cases, use SpellChecker.check() with level=ValidationLevel.WORD.
SymSpell Interface
Common Patterns
Custom Word List
Ignore Unknown Words
Get Top Suggestions Only
Troubleshooting
Issue: Valid words marked as errors
Cause: Word not in dictionary Solution: Add to dictionary:Issue: Poor suggestions
Cause: Low corpus frequency or missing similar words Solution: Improve corpus quality or adjust settings:Issue: Slow suggestion generation
Cause: Large edit distance or dictionary Solution: Reduce max_edit_distance:Next Steps
- Context Checking - Detect real-word errors
- SymSpell Algorithm - Deep dive into SymSpell
- Performance Tuning - Optimization strategies