Humanizr/Humanizer · error · ArgumentException
Unrecognized number word
Error message
Unrecognized number word: {unrecognizedWord} What it means
This ArgumentException is thrown by LinkedVigesimalWordsToNumberConverter.Convert (the throwing entry point) when TryConvert returns false. This converter handles linked-vigesimal number words where scale nouns appear before their count words (e.g. Welsh, Breton, Irish style). The error fires when the input phrase contains a token that cannot be matched as an exact word, ordinal, scale name, scale count, or terminal remainder joiner. The unrecognized word or full input is included in the message.
Solutions
- Use TryToNumber(words, out value, culture, out unrecognizedWord) for user-facing or untrusted input.
- Verify the input phrase follows the locale's grammar: scale noun, then count, optionally joined by a remainder word.
- Inspect the unrecognizedWord to locate the first unmatched token.
- Ensure the culture matches the language of the words and that the locale has full vocabulary coverage.
Example fix
// before
long value = phrase.ToNumber(new CultureInfo("cy"));
// after
if (!phrase.TryToNumber(out var value, new CultureInfo("cy"), out var bad))
Console.WriteLine($"Unrecognized: {bad}"); Defensive patterns
Strategy: try-catch
Validate before calling
bool canParse = words.TryToNumber(out var value, culture, out var unrecognized);
if (!canParse)
Console.WriteLine($"Unrecognized: {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("cy"));
}
catch (ArgumentException ex) when (ex.Message.Contains("Unrecognized number word"))
{
return 0;
} Prevention
- Use TryToNumber for user-facing or untrusted input.
- Verify the input phrase follows the locale's scale-noun-before-count grammar.
- Inspect the unrecognizedWord to locate the first unmatched token.
- Ensure the culture matches the language and the locale has full vocabulary coverage.
When it happens
Trigger: Calling "words".ToNumber(culture) for a linked-vigesimal locale with a phrase containing a token not in the locale's exact-words dictionary, ordinal map, or scale vocabulary, or a phrase whose structure does not match the scale-noun-before-count grammar.
Common situations: Free-text user input with misspellings or words from a different language; locale mismatch; ordinal phrases not authored in the locale's ordinal map; scale count words outside the locale's range; input with Unicode or diacritic differences the normalizer does not handle; phrases where the terminal remainder joiner is missing or incorrect.
Related errors
- Unrecognized number word
- Unrecognized number word
- Unrecognized number word
- Unrecognized number word
- Unrecognized number word
AI-assisted analysis of Humanizr/Humanizer@ffc2b77c0f (2026-08-13).
Data as JSON: /api/errors/3e5a7d0b800a9e65.
Report an issue: GitHub.
Appendix: source
Thrown at src/Humanizer/Localisation/WordsToNumber/LinkedVigesimalWordsToNumberConverter.cs:15
namespace Humanizer;
/// <summary>
/// Parses linked-vigesimal words with scale nouns before their count words.
/// </summary>
internal class LinkedVigesimalWordsToNumberConverter(LinkedVigesimalWordsToNumberProfile profile) : GenderlessWordsToNumberConverter
{
readonly LinkedVigesimalWordsToNumberProfile 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))
{
parsedValue = default;
unrecognizedWord = words ?? string.Empty;
return false;
}View on GitHub (pinned to ffc2b77c0f)