Logo Lanfrica

Alphaguyasa/ethiopic-text

Domain:

natural language processing

Record type:

software
Creator:
Alp
Host:
Search, matching and normalization for Ethiopic script. Makes "???" match "???". TypeScript, zero dependencies. # ethiopic-text ```js "ሠላም".includes("ሰላም") // false isFoldEquivalent("ሠላም", "ሰላም") // true ``` Same word. Two spellings. Every Amharic search box in existence quietly returns nothing for the second one. **Search, matching, and normalization for Ethiopic script.** TypeScript, zero runtime dependencies, 0.49 KB gzipped for the core. --- ## Why Ethiopic has homophone consonant families — characters that sound identical and that writers use interchangeably. The same shop, the same name, the same product gets spelled either way depending on who typed it. Unicode treats them as different characters, so string comparison fails and nobody notices until a customer says "your search is broken." Four families, reached from five variant blocks, covering 40 codepoints once you multiply across the vowel orders: | Sound | Canonical | Also written | Codepoints | | --- | --- | --- | --- | | *hä* | ሀ | ሐ ኀ | `U+1200` ← `U+1210`, `U+1280` | | *sä* | ሰ | ሠ | `U+1230` ← `U+1220` | | glottal | አ | ዐ | `U+12A0` ← `U+12D0` | | *ts'ä* | ጸ | ፀ | `U+1338` ← `U+1340` | Fixing it is codepoint arithmetic, not a lookup table. Ethiopic gives each consonant eight consecutive codepoints in vowel order, so the offset within the block survives a change of base untouched: ```text order = (cp - 0x1200) % 8 base = cp - order folded = (FOLD_MAP.get(base) ?? base) + order ``` Four lines, all 40 characters, every vowel order. ## Install ```sh npm install ethiopic-text ``` Node 18+, all modern browsers, and edge runtimes. Dual ESM/CJS. No dependencies, and none planned. ## The two fold levels This is the one thing to get right before you use the library. **Level 1 — consonant folding.** Maps ሐ/ኀ → ሀ, ሠ → ሰ, ዐ → አ, ፀ → ጸ, preserving the vowel order. Safe and meaning-preserving: two strings that fold together really are the same word spelled two ways. **Level 2 — also folds the glottal 4th order** (ኣ → አ), because writers interchange አ/ዓ/ኣ/ዐ freely. This catches ዓለም ≡ አለ …