Skip to main content

Module base

Module base 

Source
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 *_kw trait 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 splitnum produces.

Traits§

Lang
The per-language behaviour that base.py leaves 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_cardinal for 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. Returns None where Python falls off the loop and implicitly returns None (value larger than every card).

Type Aliases§

Result