en_us_normalization.production.verbalize.FractionFst
- class en_us_normalization.production.verbalize.FractionFst(cardinal: Optional[CardinalFst] = None, ordinal: Optional[OrdinalFst] = None)[source]
Finite state transducer for verbalizing fraction. Fraction consists of integer part, numerator and denominator. To expand integer part and numerator - cardinal transducer is reused. For denominator of the fraction however - ordinal transducer is needed.
There are few exception, when fraction (both numerator and denominator) is expanded as one word (for ex. 1/2 -> half)
Also some denominators (2, 3, 4) require custom expansion (halves, thirds, quarters).
When either numerator or denominator are “1” - this is also a special cases that has to be handled explicitly.
Examples of input/output strings:
fraction|integer_part:23|numerator:4|denominator:5| -> twenty three and four fifths
- __init__(cardinal: Optional[CardinalFst] = None, ordinal: Optional[OrdinalFst] = None)[source]