{"record":{"id":"fa06d58b18b3b00a","repo":"stanfordnlp/CoreNLP","slug":"bad-number-put-into-wordtonumber-word-is-fa06d5","errorCode":null,"errorMessage":"Bad number put into wordToNumber.  Word is: \\\"\" + curPart + \"\\\", originally part of \\\"\" + originalString + \"\\\", piece # \" + curIndex","messagePattern":"Bad number put into wordToNumber\\.  Word is: \\\\\"\" \\+ curPart \\+ \"\\\\\", originally part of \\\\\"\" \\+ originalString \\+ \"\\\\\", piece # \" \\+ curIndex","errorType":"exception","errorClass":"NumberFormatException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ie/NumberNormalizer.java","lineNumber":374,"sourceCode":"      Matcher m = alphaPattern.matcher(curPart);\n      if (m.find()) {\n        // Some part of the word has alpha characters\n        Number curNum;\n        if (word2NumMap.containsKey(curPart)) {\n          curNum = word2NumMap.get(curPart);\n        } else if (ordWord2NumMap.containsKey(curPart)) {\n          if (curIndex == numWords-1){\n            curNum = ordWord2NumMap.get(curPart);\n          } else {\n            throw new NumberFormatException(\"Error in wordToNumber function.\");\n          }\n        } else if (curIndex > 0 && (curPart.endsWith(\"ths\") || curPart.endsWith(\"rds\"))) {\n          // Fractions?\n          curNum = ordWord2NumMap.get(curPart.substring(0, curPart.length()-1));\n          if (curNum != null) {\n            curNum = 1/curNum.doubleValue();\n          } else {\n            throw new NumberFormatException(\"Bad number put into wordToNumber.  Word is: \\\"\" + curPart + \"\\\", originally part of \\\"\" + originalString + \"\\\", piece # \" + curIndex);\n          }\n        } else if (Character.isDigit(curPart.charAt(0)) || curPart.charAt(0) == '.') {\n          if (curPart.endsWith(\"th\") || curPart.endsWith(\"rd\") || curPart.endsWith(\"nd\") || curPart.endsWith(\"st\")) {\n            curPart = curPart.substring(0, curPart.length()-2).trim();\n          }\n          curNum = parseNumberPart(curPart, originalString, curIndex);\n        } else {\n          throw new NumberFormatException(\"Bad number put into wordToNumber.  Word is: \\\"\" + curPart + \"\\\", originally part of \\\"\" + originalString + \"\\\", piece # \" + curIndex);\n        }\n        numFields[curIndex] = curNum;\n      } else {\n        // Word is all numeric\n        Matcher matcher = digitsPatternExtended.matcher(curPart);\n        if (matcher.matches()) {\n          numFields[curIndex] = parseNumberPart(curPart, originalString, curIndex);\n        } else if (numPattern.matcher(curPart).matches()) {\n          numFields[curIndex] = new BigDecimal(curPart);\n        } else {","sourceCodeStart":356,"sourceCodeEnd":392,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ie/NumberNormalizer.java#L356-L392","documentation":"wordToNumber treats pieces ending in 'ths'/'rds' (mid-string) as fractions by stripping the final 's' and looking up ordWord2NumMap; if the lookup misses it throws NumberFormatException naming the piece, original string, and piece index. This is the fractional-word guard inside the multi-piece branch.","triggerScenarios":"A mid-string piece ending in 'ths' or 'rds' whose base form is not in the ordinal map, e.g. 'sixteenths' combined with other pieces, or misspelled ordinals like 'oneths'.","commonSituations":"Tokenizing unusual numeric phrases ('thirds half'), ordinal forms not present in the built-in word map (rare fractions like 'fifths' in some versions), or text with typos.","solutions":["Rewrite the fraction into numeric form ('three fourths' -> '0.75') before normalization.","Catch NumberFormatException and leave the token unnormalized.","Verify the ordinal spelling is supported by ordWord2NumMap (fourths, thirds, halves, etc.)."],"exampleFix":"// before\nNumber n = NumberNormalizer.wordToNumber(\"sevens ths\");\n// after\nNumber n = NumberNormalizer.wordToNumber(\"0.75\"); // pre-normalized fraction","handlingStrategy":"try-catch","validationCode":"static boolean isKnownFractionWord(String part) {\n  return part.matches(\"(half|halves|third|thirds|fourth|fourths|fifth|fifths|...)s?\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  Number n = NumberNormalizer.wordToNumber(input);\n} catch (NumberFormatException e) {\n  Number n = null; // unsupported fraction word; skip\n}","preventionTips":["Use only fraction spellings present in the ordinal word map.","Pre-convert unusual fractions to decimal form.","Catch NumberFormatException and leave tokens unnormalized."],"tags":["nlp","number-format","parsing","java"],"backgroundTag":"invalid-argument-format","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}