Skip to content

Plural/connector/long-scale support for scaled cardinals - #8

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

Plural/connector/long-scale support for scaled cardinals#8
jqueguiner merged 1 commit into
mainfrom
fix-scale-plurals-connectors

Conversation

@jqueguiner

Copy link
Copy Markdown
Owner

Follow-up to #7. A round-trip sweep (num2words → words2num over values above the reverse table) across ~30 locales surfaced three more bug classes:

class example (before)
plural scale word deux millions2 millions (only singular derived)
connector in run sesenta **y** nueve mil ocho60 y 9008
long-scale billion es dos millones2000000000 (mapped 10⁶→10⁹)

Fixes

  • scale_words samples n/2n/5n of 10³/10⁶/10⁹ → singular + plural + Slavic genitive plural (tysięcy/тысяч), smallest-magnitude-first so the collision guard pins each token to its true scale (mil millones=10⁹ composes from parts).
  • includable connectors per locale (y e et i und en și de) let the walker grow a run across joining words.
  • fragment edges connector-trimmed before lookup.

Result

Round-trip now clean for es/pt/ca/pl/ru/uk/sr (all were broken). en grammar untouched (its remaining fails are comma-rendered output, pre-existing). Agglutinative locales (de/nl/sv/fi/hu/tr/ja/zh/…) still need sub-word segmentation — left untouched, no regression. 26/26 tests, new multi-lang assertions.

🤖 Generated with Claude Code

Follow-up to the multi-scale composition. A round-trip sweep (num2words →
words2num over values above the reverse table) surfaced three more bug classes
in the reverse-table locales:

- plural scale words: "deux millions" left "million" unmatched (only the
  singular was derived);
- connectors inside a run: "sesenta y nueve mil ocho", "... mil e oito",
  "... de mii" broke at the joining word;
- long-scale billions: es/pt "mil millones"/"mil milhões" (10^9) mis-mapped
  its last token to 10^9.

Fixes:
- scale_words now samples n/2n/5n of 10^3/10^6/10^9 to capture singular, plural
  and the Slavic genitive plural (tysięcy/тысяч), smallest-magnitude-first so
  the collision guard pins each token to its true scale;
- includable connector words per locale let the sentence walker grow a run
  across y/e/et/i/und/en/și/de;
- fragment edges are connector-trimmed before lookup.

Round-trip now clean for es/pt/ca/pl/ru/uk/sr (were broken); fr/en unchanged
except where blocked by orthography (fr cent-plural, en comma rendering).
Agglutinative locales (de/nl/sv/…) still need sub-word segmentation — untouched.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jqueguiner
jqueguiner merged commit cfb1de9 into main Jul 27, 2026
15 checks passed
@jqueguiner
jqueguiner deleted the fix-scale-plurals-connectors branch July 27, 2026 18:33
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