Overview
Myanmar homophones often arise from:HomophoneChecker
Constructor
Basic Usage
Common Homophone Pairs
Custom Homophone Map
With Provider (DB Confusable Pairs)
provider parameter enables DB-driven confusable pair lookup via get_confusable_pairs(). The DB source provides ~21K pairs (aspiration, medial, nasal, tone swaps) and is the primary source. The YAML source is a curated fallback for pairs that corpus mining cannot discover.
Load from Config
Homophone Validation Strategy
TheHomophoneValidationStrategy uses context to detect homophone errors:
Configuration Parameters
Improvement ratios and probability thresholds are managed internally by
NgramContextChecker.compute_required_ratio(), not passed directly to the strategy constructor.How It Works
- For each word, check if it has homophones
- Analyze surrounding context (N-gram probabilities)
- If a homophone has higher probability in context, flag as error
- Suggest the contextually appropriate homophone
Minimum Probability Threshold
TheNgramContextChecker applies a minimum probability threshold internally to prevent false positives from infrequent N-gram occurrences:
Example Detection
Integration with SpellChecker
Homophone checking is automatically enabled with context validation:Homophones YAML Configuration
Homophones are defined inrules/homophones.yaml:
Structure
Best Practices
- Enable with context: Homophones need context for accurate detection
- Review suggestions: Homophone detection has moderate confidence
- Add domain-specific pairs: Extend homophones.yaml for your domain
- Use with N-grams: N-gram probabilities improve accuracy
Performance
- Homophone lookup: O(1) hash table
- Context analysis: Depends on N-gram checker
- Memory: Minimal (homophone map is small)
See Also
- Context Checking - N-gram context validation
- Validation Strategies - Strategy pipeline
- Text Utilities - Phonetic hashing
- Rules System - YAML configuration