Expand description
Pure-Rust core for words2num2 — the inverse of num2words2.
§Why this is small
119 of words2num2’s 120 locales never had a hand-written parser. They use
Words2Num_Base, which materialises a reverse lookup table by calling
num2words across LOOKUP_RANGE (range(-1, 10001)) — 10,002 renders —
and then does a dict hit. Only en is hand-written.
So the port is: the generic table backend + _normalize + the en
grammar parser. The table is built by calling the Rust num2words core
(num2words2-core) directly, which is where the speedup comes from.
This crate has no PyO3 dependency: it is the pure-Rust engine. The
words2num2-py crate is a thin PyO3 binder over the public API here.
Re-exports§
pub use w2n_sentence::words2num;
Modules§
- w2n_
formats - Port of
words2num2/formats.py— per-locale number-format defaults and the configurable numeric-string parser. - w2n_
lang_ en - Port of
words2num2/words2num2/lang_EN.py— theWords2Num_ENgrammar. - w2n_
sentence - Port of the words2num2 sentence-level API.
Enums§
- Lookup
Error - Error from the reverse-table backend.
Functions§
- en_
to_ cardinal Words2Num_EN().to_cardinal(text).- en_
to_ ordinal Words2Num_EN().to_ordinal(text).- en_
to_ year Words2Num_EN().to_year(text).- lookup
- Port of
Words2Num_Base._lookup+to_cardinal/to_ordinal. - normalize
- Pure-Rust port of
Words2Num_Base._normalize. - normalize_
tail - Port of the tail of
Words2Num_Base._normalize— the pure ASCII-shaped rewriting that follows NFKD decomposition + combining-mark stripping. - parse_
int - Port of
_rust.parse_int— a plainint(s)for a signed ASCII integer. - supported_
langs - Languages the Rust core can serve (Python’s
_RUST.supported_langs()).