{"record":{"id":"9aa13ede9dbf9ba0","repo":"stanfordnlp/CoreNLP","slug":"chineseutils-unsupported-parameter-option-ascii","errorCode":null,"errorMessage":"ChineseUtils: Unsupported parameter option: ascii=","messagePattern":"ChineseUtils: Unsupported parameter option: ascii=","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/trees/international/pennchinese/ChineseUtils.java","lineNumber":142,"sourceCode":"              cub == Character.UnicodeBlock.SUPPLEMENTARY_PRIVATE_USE_AREA_B) {\n        EncodingPrintWriter.err.println(\"ChineseUtils.normalize warning: private use area codepoint U+\" + Integer.toHexString(cp) + \" in \" + in);\n      }\n      boolean delete = false;\n      switch (ascii) {\n        case LEAVE:\n          break;\n        case ASCII:\n          if (cp >= '\\uFF01' && cp <= '\\uFF5E') {\n            cp -= (0xFF00 - 0x0020);\n          }\n          break;\n        case FULLWIDTH:\n          if (cp >= '\\u0021' && cp <= '\\u007E') {\n            cp += (0xFF00 - 0x0020);\n          }\n          break;\n        default:\n          throw new IllegalArgumentException(\"ChineseUtils: Unsupported parameter option: ascii=\" + ascii);\n      }\n      switch (spaceChar) {\n        case LEAVE:\n          break;\n        case ASCII:\n          if (Character.isSpaceChar(cp)) {\n            cp = ' ';\n          }\n          break;\n        case FULLWIDTH:\n          if (Character.isSpaceChar(cp)) {\n            cp = '\\u3000';\n          }\n          break;\n        case DELETE:\n          if (Character.isSpaceChar(cp)) {\n            delete = true;\n          }","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/trees/international/pennchinese/ChineseUtils.java#L124-L160","documentation":"Inside ChineseUtils.normalizeBMP, the per-codepoint conversion switches on the ascii option; any value not matching a known case (LEAVE/ASCII/FULLWIDTH etc.) reaches the default branch and throws this IllegalArgumentException. It means the ascii normalization mode is a constant the BMP normalizer does not implement — a legal-but-unknown constant passes normalize's range check and only fails here.","triggerScenarios":"Calling ChineseUtils.normalize (or normalizeBMP directly) with an ascii value that is within [0, MAX_LEGAL] but not one of the recognized mode constants, so the switch falls through to default.","commonSituations":"Passing a raw integer that passes the range guard but maps to no case in the switch, or constants mixed from different library versions.","solutions":["Pass one of the documented ascii constants from ChineseUtils (e.g. ASCII, FULLWIDTH, LEAVE) instead of a raw int","Log the ascii value at the failure point to identify the bad constant in your caller","Upgrade/synchronize your code and Stanford ChineseUtils versions so constants match"],"exampleFix":"// before\nint asciiMode = 3; // unknown to the switch\nString norm = ChineseUtils.normalize(in, asciiMode, spaceChar, midDot);\n// after\nString norm = ChineseUtils.normalize(in, ChineseUtils.FULLWIDTH, spaceChar, midDot);","handlingStrategy":"validation","validationCode":"Set<Integer> legalAscii = Set.of(ChineseUtils.LEAVE, ChineseUtils.ASCII, ChineseUtils.FULLWIDTH);\nif (!legalAscii.contains(asciiMode)) throw new IllegalArgumentException(\"unknown ascii mode: \" + asciiMode);","typeGuard":null,"tryCatchPattern":"try {\n  String norm = ChineseUtils.normalize(in, asciiMode, spaceChar, midDot);\n} catch (IllegalArgumentException e) {\n  if (!e.getMessage().contains(\"ascii=\")) throw e;\n  norm = ChineseUtils.normalize(in, ChineseUtils.LEAVE, spaceChar, midDot);\n}","preventionTips":["Use ChineseUtils' named constants exclusively","Avoid hardcoding mode ints copied from older scripts","Re-check constants when upgrading the Stanford parser library"],"tags":["java","validation","normalization"],"backgroundTag":"invalid-enum-value","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"}