Skip to content

Compose multi-scale cardinals for reverse-table locales - #7

Merged
jqueguiner merged 1 commit into
mainfrom
fix-scale-cardinals
Jul 27, 2026
Merged

Compose multi-scale cardinals for reverse-table locales#7
jqueguiner merged 1 commit into
mainfrom
fix-scale-cardinals

Conversation

@jqueguiner

Copy link
Copy Markdown
Owner

Problem

Reverse-table backend covers only LOOKUP_RANGE (-1..10001). Spoken numbers above it — e.g. French soixante-neuf mille huit (postal 69008) — have no whole-string table entry, so the sentence walker emitted fragments 69 1000 8. Every locale except en (hand-written grammar) lacked thousands/millions composition.

Fix

parse_scaled: derive each locale's scale words (mille/million/milliard) by rendering 10^3/10^6/10^9 through num2words, then recursively compose left * scale + right. Wired into base_convert after the table miss, cardinal only.

  • Space-separated locales (fr/es/pt/…) gain thousands/millions.
  • Agglutinative locales (de/nl) find no split token → fall back unchanged, no regression.

Verify

soixante-neuf mille huit → 69008 · soixante-quinze mille treize → 75013 · quatre-vingt-douze mille cent → 92100. New test scaled_cardinals_above_table; 26/26 green; en untouched.

🤖 Generated with Claude Code

The reverse-table backend only covers LOOKUP_RANGE (-1..10001), so spoken
numbers above it (e.g. FR "soixante-neuf mille huit" = 69008) had no
whole-string entry and the sentence walker emitted the fragments "69 1000 8".

Add parse_scaled: derive each locale's scale words (mille/million/milliard) by
rendering 10^3/10^6/10^9 via num2words, then recursively compose
left*scale+right. Wired into base_convert after the table miss, cardinal only.
Space-separated locales (fr/es/pt/...) gain thousands/millions; agglutinative
ones (de/nl) find no split token and fall back to the table unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jqueguiner
jqueguiner merged commit 936fc25 into main Jul 27, 2026
18 checks passed
@jqueguiner
jqueguiner deleted the fix-scale-cardinals branch July 27, 2026 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant