en_us_normalization.production.verbalize.OrdinalFst

class en_us_normalization.production.verbalize.OrdinalFst(cardinal: Optional[CardinalFst] = None)[source]

Finite state transducer for verbalizing ordinal. It pretty much reuses verbalization from cardinal, rewriting last word or only ending of it. If number ends with 1-9 or 12, the whole last word has to be modified. This is done using mapping from files:

  • ordinals/digit.tsv

  • ordinals/teen.tsv

For others, grammar just appends “th” or rewrites “ty” to “tieth”.

Examples of input/output strings:

  • ordinal|order:13| -> thirteenth

  • ordinal|order:21| -> twenty first

__init__(cardinal: Optional[CardinalFst] = None)[source]

constructor of ordinal verbalization transducer

Parameters
cardinal: CardinalFst

reusing cardinal to expand numbers to words.

get_ordinal_expanding_fst()[source]

helper function that provides and fst to expand ordinals. can be reused by other semiotic classes. simply attach to your own FST or cross with permissive FST to limit number of digits for expansion.