Words-to-number engine reference
Orientation
Choose a parser engine only after mapping the language's token normalization, cardinal composition, scales, and ordinal behavior. Render-side number words use a separate engine catalogue.
Example
surfaces:
number:
parse:
engine: 'token-map'
normalizationProfile: 'LowercaseRemovePeriods'
cardinalMap:
one: 1
two: 2
Words-To-Number Engines
Every released locale root declares decimalMarker beside engine under
surfaces.number.parse. WordsToDecimalNumber parses the integer and
fractional digit phrases with that locale's existing words-to-number engine.
Whitespace-delimited engines require token boundaries around the marker and
fractional digits; East Asian positional engines may use their authored joined
forms. Regional variants inherit only through their declared same-language,
same-script variantOf chain.
compound-scale
Fields:
cardinalMaptenslargeScalesignoredTokennegativePrefixesordinalNumberToWordsKindsequenceMultiplierThreshold
Notes:
cardinalMapmaps plain tokens to values.tensis the ordered tens vocabulary used by the shared parser.largeScalesis the ordered scale-token list.ignoredTokenis a single token skipped during parsing.ordinalNumberToWordsKindlinks to anumber.wordsprofile whose ordinal outputs can be mined for parsing support.sequenceMultiplierThresholdchanges how adjacent values are multiplied versus added.ordinalNumberToWordsKindmay useselfwhen ordinal parsing should be derived from the locale's ownnumber.wordsblock at generation time.
contracted-scale
Fields:
minusWordcardinalMap
east-asian-positional
Fields:
digitssmallUnitslargeUnitsnegativePrefixesordinalPrefixordinalSuffixordinalMap
greedy-compound
Fields:
cardinalMapnegativePrefixesordinalAbbreviationSuffixesordinalNumberToWordsKindcharactersToRemovecharactersToReplaceWithSpacetextReplacementslowercaseremoveDiacritics
Notes:
- This engine normalizes aggressively, then greedily matches compound pieces.
textReplacementsis an ordered replacement table applied before tokenization.charactersToRemoveandcharactersToReplaceWithSpaceshould stay narrowly scoped to normalization, not spelling correction.
inverted-tens
Fields:
cardinalMapunitMaptensTokenstensLinkerscaleTokensordinalMapordinalNumberToWordsKindnegativePrefixesignoredTokensordinalSuffixesunitPartReplacementsallowInvariantIntegerInput
linking-affix
Fields:
cardinalMapteenPrefixteenBaseValuelinkedSuffixesignoredTokensnegativePrefixes
scale-leading-compound (parser)
Fields:
unitsMaptensMapscalesconjunctionWordterminalRemainderConjunctionWordminusWordordinalPrefixordinalSuffixordinalMap
Nested scales fields:
valuename
Notes:
- This parser is the
number.parsecounterpart to the scale-leading renderer used by Hausa (ha) and Swahili (sw). It accepts scale names before their count tokens and tokenizes multi-word unit and scale phrases. - Unlike the render-side
unitsMapandtensMaparrays, parser maps are token-to-number dictionaries. Include every spelling variant that should parse. scalesmust be ordered from larger to smaller values, and each larger value must be divisible by the next smaller value.conjunctionWordjoins tens-plus-units and terminal remainders.terminalRemainderConjunctionWordcan override the terminal-remainder phrase and falls back toconjunctionWordwhen omitted.- Exact ordinal phrases belong in
ordinalMap; otherwise the parser can stripordinalPrefix/ordinalSuffixand parse the remaining cardinal phrase.
prefixed-tens-scale
Fields:
cardinalMaptensMapscalesprefixedTensnegativePrefixes
suffix-scale
Fields:
cardinalMapbareScaleMapscaleshundredSingularTokenhundredPluralTokentensSuffixTokenteenSuffixTokennegativePrefixes
token-map
Fields:
normalizationProfilecardinalMapordinalMapordinalScaleMapgluedOrdinalScaleSuffixesgluedScaleSuffixescompositeScaleMapnegativePrefixesnegativeSuffixesordinalPrefixesignoredTokensleadingTokenPrefixesToTrimmultiplierTokenstokenSuffixesToStripordinalAbbreviationSuffixesteenSuffixTokenshundredSuffixTokensallowTerminalOrdinalTokenuseHundredMultiplierallowInvariantIntegerInputteenBaseValuehundredSuffixValueunitTokenMinValueunitTokenMaxValuehundredSuffixMinValuehundredSuffixMaxValuescaleThresholdordinalGenderVariantordinalNumberToWordsKind
Notes:
- This is the most declarative parsing engine.
ordinalMapholds exact ordinal tokens.ordinalScaleMapholds ordinal scale words such as "millionth".gluedOrdinalScaleSuffixessupports glued ordinal forms where the scale is expressed as a suffix.gluedScaleSuffixessupports glued cardinal forms where a cardinal count is immediately followed by a scale suffix.compositeScaleMapsupports composite multi-token scales.ordinalGenderVariantis validated as token-map metadata when present. Do not rely on it by itself to create parseable ordinal tokens; token-map parsing recognizes explicit ordinal maps and the prefix/suffix rules emitted intoTokenMapWordsToNumberRules.ordinalNumberToWordsKind: 'self'is an authoring alias for the current locale's generated number-to-words profile. The generator normalizes that alias to the concrete locale profile key, but token-map locales should still author the ordinal lexemes they need to parse inordinalMap,ordinalScaleMap,gluedOrdinalScaleSuffixes, orcompositeScaleMapunless the token-map emitter is extended to synthesize additional ordinal maps.normalizationProfileis the first field to pick for a new locale because it determines how aggressively the generated parser cleans incoming text before tokenization. The same normalization is applied to explicit ordinal tokens.cardinalMapis the authoritative literal-token dictionary for this engine. If a cardinal token should parse, it must appear here; ordinal tokens must appear in one of the explicit ordinal/scale maps or be covered by the documented prefix/suffix rules.
vigesimal-compound
Fields:
cardinalMapordinalMapnegativePrefixesignoredTokensvigesimalLeadingTokenvigesimalFollowerTokensvigesimalValueteenLeaderTokenteenLeaderBases
Pitfall
A number-to-words engine does not imply a matching parser. Prove cardinal and ordinal parsing independently, including normalization and ambiguous tokens.
Version notes
These parser engines are the accepted main/preview contracts. Historical
branches may expose fewer engines or handwritten converters.