{"record":{"id":"a33a40e8291f03c2","repo":"Humanizr/Humanizer","slug":"unrecognized-number-word-unrecognizedword-a33a40","errorCode":null,"errorMessage":"Unrecognized number word: {unrecognizedWord}","messagePattern":"Unrecognized number word: (.+?)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Humanizer/Localisation/WordsToNumber/InvertedTensWordsToNumberConverter.cs","lineNumber":23,"sourceCode":"/// scales, ordinals, and optional ignored glue words in the same phrase.\n/// </summary>\n/// <remarks>\n/// The parser normalizes the input first, removes one configured negative prefix, then resolves\n/// either an exact ordinal token or a cardinal phrase composed from compact compounds and scale\n/// words. The profile captures all locale-specific vocabulary so the algorithm can stay structural.\n/// </remarks>\ninternal class InvertedTensWordsToNumberConverter(InvertedTensWordsToNumberProfile profile) : GenderlessWordsToNumberConverter\n{\n    const int MaximumParseDepth = 128;\n\n    readonly InvertedTensWordsToNumberProfile profile = profile;\n\n    /// <inheritdoc />\n    public override long Convert(string words)\n    {\n        if (!TryConvert(words, out var parsedValue, out var unrecognizedWord))\n        {\n            throw new ArgumentException($\"Unrecognized number word: {unrecognizedWord}\");\n        }\n\n        return parsedValue;\n    }\n\n    /// <inheritdoc />\n    public override bool TryConvert(string words, out long parsedValue) =>\n        TryConvert(words, out parsedValue, out _);\n\n    /// <inheritdoc />\n    public override bool TryConvert(string words, out long parsedValue, out string? unrecognizedWord)\n    {\n        if (string.IsNullOrWhiteSpace(words))\n        {\n            throw new ArgumentException(\"Input words cannot be empty.\");\n        }\n\n        var normalized = Normalize(words);","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/Humanizr/Humanizer/blob/ffc2b77c0f30d2fb176875841424379319d0ae9b/src/Humanizer/Localisation/WordsToNumber/InvertedTensWordsToNumberConverter.cs#L5-L41","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nlong value = text.ToNumber(new CultureInfo(\"nl\"));\n\n// after\nif (!text.TryToNumber(out var value, new CultureInfo(\"nl\"), out var bad))\n    Console.WriteLine($\"Unknown token: {bad}\");","handlingStrategy":"try-catch","validationCode":"bool canParse = words.TryToNumber(out var value, culture, out var unrecognized);\nif (!canParse)\n    Console.WriteLine($\"Unknown token: {unrecognized}\");","typeGuard":"static bool LooksLikeNumberWords(string words, CultureInfo culture) =>\n    !string.IsNullOrWhiteSpace(words) && words.TryToNumber(out _, culture, out _);","tryCatchPattern":"try\n{\n    return words.ToNumber(new CultureInfo(\"nl\"));\n}\ncatch (ArgumentException ex) when (ex.Message.Contains(\"Unrecognized number word\"))\n{\n    return 0;\n}","preventionTips":["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."],"tags":["argumentexception","words-to-number","inverted-tens","unrecognized-word","parsing"],"backgroundTag":null,"analyzedSha":"ffc2b77c0f30d2fb176875841424379319d0ae9b","analyzedAt":"2026-08-13T21:42:34.584Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}