{"record":{"id":"522b7f89bf8e8dc1","repo":"stanfordnlp/CoreNLP","slug":"chineseutils-unknown-parameter-option","errorCode":null,"errorMessage":"ChineseUtils: Unknown parameter option","messagePattern":"ChineseUtils: Unknown parameter option","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/trees/international/pennchinese/ChineseUtils.java","lineNumber":97,"sourceCode":"   *      if it is ASCII then map them from the Chinese Full Width range\n   *      to ASCII values, and if it is FULLWIDTH then do the reverse.\n   *  @param spaceChar For characters that satisfy Character.isSpaceChar(),\n   *      if this is ChineseUtils.LEAVE, then do nothing,\n   *      if it is ASCII then map them to the space character U+0020, and\n   *      if it is FULLWIDTH then map them to U+3000.\n   *  @param midDot For a set of 7 characters that are roughly middle dot characters,\n   *      if this is ChineseUtils.LEAVE, then do nothing,\n   *      if it is NORMALIZE then map them to the extended Latin character U+00B7, and\n   *      if it is FULLWIDTH then map them to U+30FB.\n   *  @return The in String normalized according to the other arguments.\n   */\n  public static String normalize(String in,\n                                 int ascii,\n                                 int spaceChar,\n                                 int midDot) {\n    if (ascii < 0 || ascii > MAX_LEGAL ||\n        spaceChar < 0 || spaceChar > MAX_LEGAL) {\n      throw new IllegalArgumentException(\"ChineseUtils: Unknown parameter option\");\n    }\n    if (ONLY_BMP) {\n      return normalizeBMP(in, ascii, spaceChar, midDot);\n    } else {\n      return normalizeUnicode(in, ascii, spaceChar, midDot);\n    }\n  }\n\n\n  private static String normalizeBMP(String in, int ascii, int spaceChar, int midDot) {\n    StringBuilder out = new StringBuilder();\n    int len = in.length();\n    for (int i = 0; i < len; i++) {\n      char cp = in.charAt(i);\n      if (Character.isHighSurrogate(cp)) {\n        if (i + 1 < len) {\n          log.warn(\"ChineseUtils.normalize warning: non-BMP codepoint U+\" +\n                  Integer.toHexString(Character.codePointAt(in, i)) + \" in \" + in);","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/trees/international/pennchinese/ChineseUtils.java#L79-L115","documentation":"ChineseUtils.normalize(in, ascii, spaceChar, midDot) maps characters using option constants for ascii and spaceChar handling. If either option is negative or exceeds MAX_LEGAL, the method rejects the call with this IllegalArgumentException before dispatching to normalizeBMP/normalizeUnicode. It signals an invalid normalization mode constant rather than bad input text.","triggerScenarios":"Calling ChineseUtils.normalize with an ascii or spaceChar argument outside the range [0, MAX_LEGAL], typically from hand-rolled integer flags, misremembered constant values, or -1 used as a 'no conversion' sentinel.","commonSituations":"Callers passing -1 as a sentinel, copying option ints from another library's constants, or code written against an older constant set whose values shifted between library versions.","solutions":["Use only the named constants defined in ChineseUtils (e.g. LEAVE, ASCII, FULLWIDTH, DELETE) for ascii and spaceChar","Check your values against MAX_LEGAL before calling normalize","Remove any -1/undefined sentinel usage and pass a legal constant instead"],"exampleFix":"// before\nString norm = ChineseUtils.normalize(in, -1, ChineseUtils.ASCII, ChineseUtils.LEAVE);\n// after\nString norm = ChineseUtils.normalize(in, ChineseUtils.LEAVE, ChineseUtils.ASCII, ChineseUtils.LEAVE);","handlingStrategy":"validation","validationCode":"if (ascii < 0 || ascii > ChineseUtils.MAX_LEGAL || spaceChar < 0 || spaceChar > ChineseUtils.MAX_LEGAL)\n  throw new IllegalArgumentException(\"ascii/spaceChar out of legal range before normalize()\");","typeGuard":null,"tryCatchPattern":"try {\n  String norm = ChineseUtils.normalize(in, ascii, spaceChar, midDot);\n} catch (IllegalArgumentException e) {\n  // fall back to safe constants\n  norm = ChineseUtils.normalize(in, ChineseUtils.LEAVE, ChineseUtils.LEAVE, midDot);\n}","preventionTips":["Only pass named constants, never raw ints or -1 sentinels","Centralize normalization calls in one helper that pins legal constants","Check constants against MAX_LEGAL after upgrading the library"],"tags":["java","validation","normalization"],"backgroundTag":"invalid-argument-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"}