{"record":{"id":"40185b2162259303","repo":"Humanizr/Humanizer","slug":"unrecognized-number-word-unrecognizedword-40185b","errorCode":null,"errorMessage":"Unrecognized number word: {unrecognizedWord}","messagePattern":"Unrecognized number word: (.+?)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Humanizer/Localisation/WordsToNumber/ContractedScaleWordsToNumberConverter.cs","lineNumber":27,"sourceCode":"/// walks the token stream from left to right. Contracted tens and teens such as <c>puluh</c> and\n/// <c>belas</c> are interpreted as structural operators over the current accumulated value rather\n/// than as plain additive words. Locale data can therefore express native high-range phrases and\n/// parse them back through the same token map.\n/// </summary>\nclass ContractedScaleWordsToNumberConverter(ContractedScaleWordsToNumberProfile profile) : GenderlessWordsToNumberConverter\n{\n    /// <summary>\n    /// Immutable parser profile emitted from locale YAML. It owns the literal minus word and the\n    /// cardinal token dictionary used by the state machine below.\n    /// </summary>\n    readonly ContractedScaleWordsToNumberProfile 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":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/Humanizr/Humanizer/blob/ffc2b77c0f30d2fb176875841424379319d0ae9b/src/Humanizer/Localisation/WordsToNumber/ContractedScaleWordsToNumberConverter.cs#L9-L45","documentation":"This ArgumentException is thrown by ContractedScaleWordsToNumberConverter.Convert (the throwing entry point) when TryConvert fails to parse the input. This converter handles Malay-style contracted scale systems where tokens like 'puluh' (tens) and 'belas' (teens) act as structural operators. The error fires when the normalized phrase contains a token absent from the locale's cardinal dictionary, meaning the phrase cannot be composed into a number.","triggerScenarios":"Calling \"words\".ToNumber(culture) for a contracted-scale locale with a phrase containing a word not in the locale's Cardinals token map, or a structural token used in an unsupported position.","commonSituations":"Free-text user input fed directly to ToNumber; locale mismatch (words from a different language); a typo or non-standard spelling not covered by the locale's normalization; using a scale or teen word the locale YAML did not register.","solutions":["Use TryToNumber(words, out value, culture, out unrecognizedWord) for user-facing input so parse failures return false instead of throwing.","Validate that the culture matches the language of the input words.","Normalize or constrain input to the locale's known vocabulary before parsing.","Inspect the unrecognizedWord output to guide the user to correct the input."],"exampleFix":"// before\nlong value = text.ToNumber(new CultureInfo(\"ms\"));\n\n// after\nif (!text.TryToNumber(out var value, new CultureInfo(\"ms\"), out var bad))\n    Console.WriteLine($\"Could not parse; 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(culture);\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 culture matches the input's language.","Normalize input before parsing if the source is unstructured text.","Inspect the unrecognizedWord to guide the user to correct the input."],"tags":["argumentexception","words-to-number","contracted-scale","unrecognized-word","parsing"],"backgroundTag":null,"analyzedSha":"ffc2b77c0f30d2fb176875841424379319d0ae9b","analyzedAt":"2026-08-13T21:42:34.584Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}