Commit 37336f2
feat(sentence): multi-language ordinal + date registry in Rust core
Reimplements PR #121's multi-language ordinal/date extension inside the
Rust SentenceConverter port (rust/num2words2-py/src/sentencepath.rs)
instead of reintroducing a pure-Python converter — the project is
Rust-native (num2words2 is a thin binder over the compiled _rust core),
so the feature must live in Rust.
Extends ordinal coverage from 6 languages (en/fr/es/de/it/pt) to ~26 and
date detection to ~26 by porting lang_registry's surface-form tables:
ORDINAL_PATTERNS, MONTH_NAMES, DATE_PATTERNS_TEMPLATE, TEMP_PATTERNS and
NEGATIVE_WORDS, plus the _norm_lang normalisation. Passes 3 (standalone
ordinals), 4 (dates) and 5 (years) are rewritten to be registry-driven
and byte-compatible with the legacy 6-language behaviour:
* ordinals own their full surface span; the date pass only fires where
no ordinal was consumed;
* the day is auto-located as the first all-digit capture group;
* langs whose written day form is "<n>." consume the trailing period;
* year detection is gated on the active language's month names.
27 new multilang tests pass; all 42 existing sentence-converter tests
still pass (69 total). No change to any other language path.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 6cc0b0a commit 37336f2
2 files changed
Lines changed: 500 additions & 210 deletions
0 commit comments