Humanizr/Humanizer · error · ArgumentException
Unrecognized number word: {unrecognizedWord}
Error message
Unrecognized number word: {unrecognizedWord} What it means
VigesimalCompoundWordsToNumberConverter.Convert throws this ArgumentException at line 15 when TryConvert cannot parse the phrase under the base-20 + scale grammar. It serves languages combining vigesimal (base-20) constructions with ordinary scale words. Only Convert raises it; the Try overloads return false with the unrecognized token.
Source
Thrown at src/Humanizer/Localisation/WordsToNumber/VigesimalCompoundWordsToNumberConverter.cs:15
namespace Humanizer;
/// <summary>
/// Parses languages that combine base-20 constructions with ordinary scale words.
/// </summary>
internal class VigesimalCompoundWordsToNumberConverter(VigesimalCompoundWordsToNumberProfile profile) : GenderlessWordsToNumberConverter
{
readonly VigesimalCompoundWordsToNumberProfile 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 = TokenMapWordsToNumberNormalizer.Normalize(words, TokenMapNormalizationProfile.LowercaseReplacePeriodsWithSpaces);View on GitHub (pinned to ffc2b77c0f)
Solutions
- Switch to TryToNumber(words, out var n, culture, out var bad) and handle false.
- Use the reported bad token to correct the phrase or culture.
- Pre-clean input and confirm the locale matches the phrase's vigesimal grammar.
Example fix
// before
var n = phrase.ToNumber(culture);
// after
if (phrase.TryToNumber(out var n, culture, out var bad))
Use(n);
else
Warn($"unrecognized: {bad}"); Defensive patterns
Strategy: validation
Validate before calling
if (!words.TryToNumber(out var n, culture, out var unrecognized))
return Result.Fail($"unrecognized token: {unrecognized}");
return Result.Ok(n); Try / catch
try { var n = words.ToNumber(culture); }
catch (ArgumentException ex) when (ex.Message.StartsWith("Unrecognized number word"))
{ /* handle */ } Prevention
- Use TryToNumber for untrusted input.
- Match the culture's vigesimal grammar to the phrase.
- Inspect the unrecognized token for diagnostics.
- Pre-clean input before parsing.
When it happens
Trigger: Calling ToNumber with tokens outside the locale's vigesimal compound map; foreign words, misspellings, or unsupported ordinals. Fires at line 15 when TryConvert returns false.
Common situations: Wrong culture for the phrase; user free text; base-20 forms (e.g. French/Danish-style) the map does not cover; leftover punctuation after 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/80855387a626c71f.
Report an issue: GitHub.