Humanizr/Humanizer · error · ArgumentException
Unrecognized number word: {unrecognizedWord}
Error message
Unrecognized number word: {unrecognizedWord} What it means
This ArgumentException is thrown by InvertedTensWordsToNumberConverter.Convert when TryConvert fails. This converter handles locales whose compound tens place the unit before the tens token (e.g. Dutch-style 'eenentwintig' for 21). The error fires when the normalized phrase contains a token not in the locale's cardinal map, unit map, scale tokens, or ordinal map, and structural splitting (tens-linker decomposition, scale splitting, ordinal-suffix stripping) cannot resolve it.
Source
Thrown at src/Humanizer/Localisation/WordsToNumber/InvertedTensWordsToNumberConverter.cs:23
/// scales, ordinals, and optional ignored glue words in the same phrase.
/// </summary>
/// <remarks>
/// The parser normalizes the input first, removes one configured negative prefix, then resolves
/// either an exact ordinal token or a cardinal phrase composed from compact compounds and scale
/// words. The profile captures all locale-specific vocabulary so the algorithm can stay structural.
/// </remarks>
internal class InvertedTensWordsToNumberConverter(InvertedTensWordsToNumberProfile profile) : GenderlessWordsToNumberConverter
{
const int MaximumParseDepth = 128;
readonly InvertedTensWordsToNumberProfile profile = profile;
/// <inheritdoc />
public override long Convert(string words)
{
if (!TryConvert(words, out var parsedValue, out var unrecognizedWord))
{
throw new ArgumentException($"Unrecognized number word: {unrecognizedWord}");
}
return parsedValue;
}
/// <inheritdoc />
public override bool TryConvert(string words, out long parsedValue) =>
TryConvert(words, out parsedValue, out _);
/// <inheritdoc />
public override bool TryConvert(string words, out long parsedValue, out string? unrecognizedWord)
{
if (string.IsNullOrWhiteSpace(words))
{
throw new ArgumentException("Input words cannot be empty.");
}
var normalized = Normalize(words);View on GitHub (pinned to ffc2b77c0f)
Solutions
- Use TryToNumber(words, out value, culture, out unrecognizedWord) for any input that may contain errors.
- Verify the locale's unit-part replacements and ordinal suffixes cover the input forms.
- Check the unrecognizedWord output to locate the failing token and guide correction.
- Ensure the culture matches the language of the words.
Example fix
// before
long value = text.ToNumber(new CultureInfo("nl"));
// after
if (!text.TryToNumber(out var value, new CultureInfo("nl"), out var bad))
Console.WriteLine($"Unknown token: {bad}"); Defensive patterns
Strategy: try-catch
Validate before calling
bool canParse = words.TryToNumber(out var value, culture, out var unrecognized);
if (!canParse)
Console.WriteLine($"Unknown token: {unrecognized}"); Type guard
static bool LooksLikeNumberWords(string words, CultureInfo culture) =>
!string.IsNullOrWhiteSpace(words) && words.TryToNumber(out _, culture, out _); Try / catch
try
{
return words.ToNumber(new CultureInfo("nl"));
}
catch (ArgumentException ex) when (ex.Message.Contains("Unrecognized number word"))
{
return 0;
} Prevention
- Use TryToNumber for any input that may contain unknown tokens.
- Verify the locale's unit-part replacements and ordinal suffixes cover the input forms.
- Ensure the culture matches the language of the words.
- Inspect the unrecognizedWord to locate the failing token.
When it happens
Trigger: Calling "words".ToNumber(culture) for an inverted-tens locale with a phrase containing a word not in the locale's vocabulary, a tens compound with an unknown linker, or a scale token the locale did not register.
Common situations: User-typed free-text input with misspellings or non-standard spellings; locale mismatch; compound words where the unit or tens fragment does not match after unit-part replacements; ordinal stems with suffixes not configured; Unicode or diacritic differences not handled by normalization.
Related errors
- Unrecognized number word: {unrecognizedWord}
- Unrecognized number word: {unrecognizedWord}
- Unrecognized number word: {unrecognizedWord}
- Unrecognized number word: {unrecognizedWord}
- Unrecognized number word: {unrecognizedWord}
AI-assisted analysis of Humanizr/Humanizer@ffc2b77c0f (2026-08-13).
Data as JSON: /api/errors/a33a40e8291f03c2.
Report an issue: GitHub.