uttrflow / uttrflow/uttrflow-swift
Lakh and crore amounts are half converted ("one lakh fifty thousand rupees" becomes "One lakh 50,000 rupees"), and digits are only ever grouped in thousands
- Dominant language
- Swift
- Stars
- 4
- Forks
- 17
- Avg merge
- 3h 32m
- Merged PRs (30d)
- 277
Description
## What happens
`NumberWords` knows hundred, thousand and million, and no Indian scale (`Sources/UttrflowCore/Cleaning/NumberWords.swift:15`):
```swift
public static let scales: [String: Int] = ["hundred": 100, "thousand": 1_000, "million": 1_000_000]
```
`NumberFormsPass` converts a spoken number under ten only in a context or before a currency word (`Sources/UttrflowAI/Passes/NumberFormsPass.swift:137-138`), and "lakh"/"crore" are neither. The only digit groupings are `.thousands` and `.none` (`Sources/UttrflowCore/Models/DestinationFormatter.swift:20-25`).
The result is inconsistent inside one amount, and from one amount to the next:
```
$ uttrflow-dev clean -e rules "one lakh fifty thousand rupees" → One lakh 50,000 rupees.
$ uttrflow-dev clean -e rules "two lakh rupees" → Two lakh rupees.
$ uttrflow-dev clean -e rules "twenty five lakh rupees" → 25 lakh rupees.
$ uttrflow-dev clean -e rules "one crore twenty lakh" → One crore 20 lakh.
$ uttrflow-dev clean -e rules "it costs one hundred fifty thousand rupees" → It costs 150,000 rupees.
```
"One lakh 50,000" mixes words and digits for a single amount (1,50,000). 150,000 is grouped the Western way, though an Indian reader writes 1,50,000.
In a pipeline run (`uttrflow-dev bench`, `say -v Lekha`), the recogniser wrote "2 करोड़ 50 लाग" and "50 लाक" (लाख misheard, see #708). Apple's model then wrote "2 crore 50 lakh", which is right. The rules path left the misspelling.
## Why it matters
Lakh and crore are how amounts are said and written in India, in English as much as in Hindi: salaries, prices, budgets. An amount the reader has to piece together from "One lakh 50,000" is an error in exactly the kind of text where numbers matter.
## Decision needed
- Should "one lakh fifty thousand" become "1.5 lakh", "1,50,000" or "150,000"? Should that depend on the locale (`en_IN`, `hi_IN`) or on a setting?
- Is Indian grouping a third `DigitGrouping` case chosen from the locale, or left alone?
## Acceptance criteria
- "lakh" (also "lac", "लाख") and "crore" ("करोड़") are scales in `NumberWords`, so an amount that uses them is converted whole or not at all. The chosen written form is used consistently.
- The digit grouping follows the decision above.
- `Tests/UttrflowAITests/Passes/NumberFormsPassTests.swift` covers the five inputs above. It has one Devanagari case today, around line 246.
- Lakh/crore cases are in the clean-up corpus (#706).
Contributor guide
Research direction
Start with the scales in Sources/UttrflowCore/Cleaning/NumberWords.swift, conversion rules in Sources/UttrflowAI/Passes/NumberFormsPass.swift, and grouping in Sources/UttrflowCore/Models/DestinationFormatter.swift. Run the five clean-up examples, then read NumberFormsPassTests.swift around line 246. First settle the written-form and locale decision; done means consistent lakh/crore conversion, agreed grouping, five passing tests, and corpus coverage in #706.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- localization, testing
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100