Compose multi-scale cardinals for reverse-table locales - #7
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Reverse-table backend covers only
LOOKUP_RANGE(-1..10001). Spoken numbers above it — e.g. Frenchsoixante-neuf mille huit(postal 69008) — have no whole-string table entry, so the sentence walker emitted fragments69 1000 8. Every locale excepten(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 composeleft * scale + right. Wired intobase_convertafter the table miss, cardinal only.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;enuntouched.🤖 Generated with Claude Code