This document describes the enrichment of liblevenshtein's LLev phonetic rules through extraction of knowledge from classic phonetic algorithms.
The LLev (Levenshtein Language) rule system provides phonetic normalization through rewrite transformation rules. This project enriched the existing 125+ language rule sets by systematically extracting patterns from established phonetic matching algorithms.
Terminology. A phonetic algorithm maps orthography (spelling) to an approximation of pronunciation so that sound-alike strings collide; a phoneme is a contrastive unit of sound. Symbols such as
ʃ(the "sh" sound) are drawn from the IPA (International Phonetic Alphabet). Consonants are distinguished along three dimensions: place of articulation (where the vocal tract is constricted), manner of articulation (how airflow is shaped), and voicing (whether the vocal folds vibrate). See../GLOSSARY.mdfor fuller definitions. These rules ship behind thephonetic-rulesCargo feature (liblevenshtein 0.9.1).
| Algorithm | Languages | Rule IDs | Rules Added |
|---|---|---|---|
| Soundex | English | 2100-2199 | ~20 |
| Metaphone | English | 2200-2299 | ~35 |
| DoubleMetaphone | Multi-origin English | 2300-2399 | ~40 |
| Caverphone | NZ English | 2700-2799 | ~25 |
| NYSIIS | American names | 2800-2899 | ~25 |
| ColognePhonetic | German | 2400-2499 | ~25 |
| SpanishMetaphone | Spanish | 2500-2599 | ~20 |
| PHONEX | French | 2600-2699 | ~30 |
| Beider-Morse | Multi-language | 2900-2999, 3100-3899 | ~300 |
| Daitch-Mokotoff | Jewish/E. European | 3000-3099 | ~50 |
Total: ~570 new rules
/data/rules/english/base.llev
/data/rules/english/new_zealand.llev - Caverphone rules for NZ English/data/rules/english/names.llev - NYSIIS rules for American names/data/rules/german/base.llev
/data/rules/german/names.llev - Germanic surname patterns/data/rules/spanish/base.llev
/data/rules/spanish/latin_american.llev - Regional variants/data/rules/french/base.llev
/data/rules/polish/base.llev
/data/rules/polish/names.llev - Polish surname patterns/data/rules/russian/base.llev
/data/rules/russian/names.llev - Russian patronymic and surname patterns/data/rules/jewish/names.llev - Daitch-Mokotoff Soundex rules for Jewish/Eastern European names/data/rules/hungarian/base.llev
/data/rules/italian/base.llev
/data/rules/greek/base.llev
/data/rules/hebrew/base.llev
To prevent conflicts, rules use non-overlapping ID ranges:
| Range | Algorithm/Category |
|---|---|
| 2100-2199 | Soundex |
| 2200-2299 | Metaphone |
| 2300-2399 | DoubleMetaphone |
| 2400-2499 | ColognePhonetic |
| 2500-2599 | SpanishMetaphone |
| 2600-2699 | PHONEX (French) |
| 2700-2799 | Caverphone |
| 2800-2899 | NYSIIS |
| 2900-2999 | Beider-Morse (Generic) |
| 3000-3099 | Daitch-Mokotoff |
| 3100-3199 | BM Polish |
| 3200-3299 | Polish Names |
| 3300-3399 | Russian Names |
| 3400-3499 | BM Russian |
| 3500-3599 | BM Hungarian |
| 3600-3699 | DM Italian |
| 3700-3799 | BM Greek |
| 3800-3899 | BM Hebrew |
The rule-based phonetic patterns described above handle known phonetic equivalences through explicit transformations. For residual substitutions not covered by rules, liblevenshtein also provides articulatory distance—a feature-based approach that computes phonetic similarity between any two IPA characters based on their articulatory properties.
| Approach | Strengths | Use Case |
|---|---|---|
| LLev Rules | Context-sensitive, language-specific, explicit patterns | Known phonetic alternations (tion→ʃən, ph→f) |
| Articulatory Distance | Universal, handles novel pairs, gradient costs | Residual substitutions after rule application |
The two approaches complement each other: rules handle predictable patterns while articulatory distance provides principled costs for everything else.
For full details on articulatory distance, see: Articulatory Distance Guide
Rules use a consistent weight system:
[id: 2100, name: "rule_name", weight: 0.15, group: category, ipa: "/IPA/"]
pattern -> replacement / left_context _ right_context;
Components:
Context syntax:
#_: Word start_#: Word end$VOWEL: Any vowel character$CONSONANT: Any consonant character[abc]: Character classSee individual documentation files for detailed algorithm analysis:
Every classic phonetic algorithm below predates the DOI system or was published in a patent, trade magazine, technical report, or genealogy journal that was never assigned a DOI; the per-source notes record this explicitly, and the per-algorithm documents carry the full citations.
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |