{"record":{"id":"e3a5edf13dd1ba03","repo":"Humanizr/Humanizer","slug":"unrecognized-number-word-unrecognizedword-e3a5ed","errorCode":null,"errorMessage":"Unrecognized number word: {unrecognizedWord}","messagePattern":"Unrecognized number word: (.+?)","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Humanizer/Localisation/WordsToNumber/SuffixScaleWordsToNumberConverter.cs","lineNumber":19,"sourceCode":"namespace Humanizer;\n\n/// <summary>\n/// Parses languages that place scale words after the quantity they modify.\n/// </summary>\ninternal class SuffixScaleWordsToNumberConverter(SuffixScaleWordsToNumberProfile profile) : GenderlessWordsToNumberConverter\n{\n    const int MaximumParseDepth = 128;\n    const int ParseWorkPerCharacter = 32;\n    // Short ambiguous compounds need room to preserve the parser's historical backtracking order.\n    const int MinimumParseWork = 1_000_000;\n    readonly SuffixScaleWordsToNumberProfile 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        if (long.TryParse(words.Trim(), NumberStyles.Integer, CultureInfo.InvariantCulture, out parsedValue))","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/Humanizr/Humanizer/blob/ffc2b77c0f30d2fb176875841424379319d0ae9b/src/Humanizer/Localisation/WordsToNumber/SuffixScaleWordsToNumberConverter.cs#L1-L37","documentation":"SuffixScaleWordsToNumberConverter.Convert throws this ArgumentException at line 19 when TryConvert fails to map the phrase under the suffix-scale grammar. This converter also accepts a bare invariant integer (long.TryParse) as a fast path, and caps work via MinimumParseWork/ParseWorkPerCharacter. Only Convert raises it; Try overloads return false with the unrecognized token.","triggerScenarios":"Calling ToNumber with tokens outside the suffix-scale map that are also not a bare integer (the fast path), or inputs triggering the backtracking work budget. Fires at line 19 when TryConvert returns false.","commonSituations":"Wrong culture; user free text; pathological inputs relying on historical backtracking order; misspelled or foreign tokens.","solutions":["Use TryToNumber(words, out var n, culture, out var bad) instead of ToNumber.","Inspect bad and correct the phrase or culture.","For pure digit strings, pass them directly (the invariant-integer fast path avoids the grammar)."],"exampleFix":"// before\nvar n = phrase.ToNumber(culture);\n// after\nif (phrase.TryToNumber(out var n, culture, out var bad))\n    Use(n);\nelse\n    Warn($\"unrecognized: {bad}\");","handlingStrategy":"validation","validationCode":"if (!words.TryToNumber(out var n, culture, out var unrecognized))\n    return Result.Fail($\"unrecognized token: {unrecognized}\");\nreturn Result.Ok(n);","typeGuard":null,"tryCatchPattern":"try { var n = words.ToNumber(culture); }\ncatch (ArgumentException ex) when (ex.Message.StartsWith(\"Unrecognized number word\"))\n    { /* handle */ }","preventionTips":["Use TryToNumber for untrusted input.","For pure digit strings, pass them directly to use the invariant-integer fast path.","Match culture to phrase language.","Avoid pathological inputs that stress the backtracking work budget."],"tags":["words-to-number","suffix-scale","argumentexception","parsing","localization"],"backgroundTag":null,"analyzedSha":"ffc2b77c0f30d2fb176875841424379319d0ae9b","analyzedAt":"2026-08-13T21:42:34.584Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}