Expand description
Faithful port of num2words2’s base.py engine.
The Python original builds a nested list-of-tuples tree in splitnum,
then folds it with clean/merge. The tree shape is load-bearing:
clean branches on whether an element is a tuple or a list, so Node
mirrors that distinction exactly rather than flattening it.
Structs§
- Cards
- The ordered card table: value -> word, in descending key order.
- Kwargs
- The kwargs bag handed to the
*_kwtrait hooks. Order-preserving — insertion order never matters to the converters, but it keeps error messages deterministic.
Enums§
- KwVal
- A grammatical-kwargs value (
case=,gender=,reading=, …). - N2WError
- Errors mirroring the exception types the Python original raises.
- Node
- A node in the tree
splitnumproduces.
Traits§
- Lang
- The per-language behaviour that
base.pyleaves abstract or overridable.
Functions§
- clean
- Python’s
clean: fold the tree down to a single(text, num)leaf. - default_
to_ cardinal - Python’s
Num2Word_Base.to_cardinalfor integral input. - default_
to_ fraction - Python’s
Num2Word_Base.to_fraction. - set_
low_ numwords - Python’s
set_low_numwords: words map to descending values ending at 0. - set_
mid_ numwords - splitnum
- Python’s
splitnum. ReturnsNonewhere Python falls off the loop and implicitly returnsNone(value larger than every card).