uttrflow / uttrflow/uttrflow-swift
The personal dictionary can't help Hindi dictation: a Devanagari word never meets a Latin entry, spelling variants like पहुँच/पहुंच get different keys, and a Hindi correction is never learnt
- Dominant language
- Swift
- Stars
- 4
- Forks
- 17
- Avg merge
- 3h 32m
- Merged PRs (30d)
- 277
Description
## What happens
The recogniser writes Hindi and most Hinglish in Devanagari: 11 of 12 committed passages in a bench run on `origin/main` 26d7bc1. The rules keep it that way (#445). Each dictionary path fails on that text:
1. **Lookup across scripts.** `PronunciationCoder.keys` (`Sources/UttrflowDictionary/PronunciationCoder.swift:8-13`) files a spelling with Latin letters under its Double Metaphone codes. A spelling with none goes under its own folded spelling. A heard Devanagari name is therefore looked up under its Devanagari spelling, and an entry the user typed in Latin sits under a metaphone code. The two never meet, so a Latin entry can never correct a Devanagari mishearing. In the bench run, Hindi names came back misspelt in Devanagari (for example रगुनात, and a name heard as the ordinary word मेरा), with no way for a dictionary entry to reach them.
2. **Lookup within Devanagari.** `spellingKey` (`:16-19`) folds case and diacritics. `folding(.diacriticInsensitive)` leaves Devanagari marks alone, so common spelling variants get different keys, checked by running `spellingKey` verbatim: पहुँच ≠ पहुंच, हूँ ≠ हूं, क़ ≠ क. The recogniser writes the anusvara forms (पहुंच, दूंगा, हूं in the bench run), while people often type chandrabindu. An entry typed one way isn't found when heard the other way.
3. **Learning.** `LearnableWords.corrected(over:wrote:)` learns a spelling when a dictation over a selection corrects it. It requires a non-silent sound code that matches the selection's (`Sources/UttrflowDictionary/LearnableWords.swift:50-54`), and Devanagari has no code. So re-dictating over "रगुनात" to fix it teaches nothing, and neither does fixing it to a Latin spelling.
#220 (closed) made a Devanagari entry reachable by its own spelling. This is what remains for Hindi speakers.
## Why it matters
Names are the words a dictionary exists for, and Hindi names are the ones a Hindi speaker says most. Today a Hindi user can add entries, but none of them affects a Hindi dictation, and nothing says so.
## Acceptance criteria
- A Devanagari spelling also gets a key that can meet a Latin entry. One way: ICU `Latin-Devanagari` / `toLatin` transliteration with diacritics stripped, then Double Metaphone on that. `TextNormaliser.transliteratedToLatin` in `UttrflowEval` shows the transform. Use it as a second key, not a replacement.
- `spellingKey` folds chandrabindu to anusvara and nukta forms to their base consonants, or normalises to a canonical form that does, so पहुँच and पहुंच share a key.
- `corrected(over:wrote:)` accepts a correction whose two sides share a transliterated key.
- Tests in `Tests/UttrflowDictionaryTests/PronunciationCoderTests.swift` and `LearnableWordsTests.swift` cover: a Latin entry reached from its Devanagari rendering, the three variant pairs above, and a Devanagari re-dictation being learnt.
- The dictionary page says which scripts an entry matches in, if any limitation remains.
Contributor guide
Research direction
Start with Sources/UttrflowDictionary/PronunciationCoder.swift and LearnableWords.swift, then read TextNormaliser.transliteratedToLatin in UttrflowEval and run the named PronunciationCoderTests.swift and LearnableWordsTests.swift. Done means the specified Latin/Devanagari lookup, spelling-variant, and Devanagari-learning cases pass, with the dictionary page documenting script matching or limitations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- macos, swift
- Domain
- desktop, internationalization
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 64/100