Overview
The module loads transliteration variants fromrules/loan_words.yaml and provides:
- Variant → Standard: Given a non-standard spelling, find the standard form(s)
- Standard → Variants: Given a standard spelling, find all known variant forms
- SymSpell integration: Variants are injected as spell check candidates during word validation
Data Coverage
| Source Language | Words | Variants | Examples |
|---|---|---|---|
| English | ~120 | ~200 | computer, telephone, television |
| Pali/Sanskrit | ~50 | ~100 | religious terms, formal vocabulary |
| Other | ~16 | ~23 | Thai, Hindi, Chinese borrowings |
| Total | 186 | 323 |
Usage
Basic Lookup
Integration with SpellChecker
Loan word variants are automatically used during spell checking when the SymSpell algorithm generates candidates. If a user types a non-standard variant, the standard form is suggested — and vice versa.YAML Structure
Loan words are organized by source language inrules/loan_words.yaml:
Performance
- YAML is loaded once and cached via
@lru_cache - Public API returns
frozenset(immutable, safe for concurrent access) - Lookup is O(1) dictionary access
See Also
- Word Validation - Dictionary-based word checking
- Grammar Checkers - Particle and grammar validation
- Homophones - Sound-alike word detection
- Rules System - YAML rule configuration