stanfordnlp/CoreNLP · error · IllegalArgumentException

ChineseUtils: Unknown parameter option

Error message

ChineseUtils: Unknown parameter option

What it means

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.

Solutions

  1. Use only the named constants defined in ChineseUtils (e.g. LEAVE, ASCII, FULLWIDTH, DELETE) for ascii and spaceChar
  2. Check your values against MAX_LEGAL before calling normalize
  3. Remove any -1/undefined sentinel usage and pass a legal constant instead

Example fix

// before
String norm = ChineseUtils.normalize(in, -1, ChineseUtils.ASCII, ChineseUtils.LEAVE);
// after
String norm = ChineseUtils.normalize(in, ChineseUtils.LEAVE, ChineseUtils.ASCII, ChineseUtils.LEAVE);
Defensive patterns

Strategy: validation

Validate before calling

if (ascii < 0 || ascii > ChineseUtils.MAX_LEGAL || spaceChar < 0 || spaceChar > ChineseUtils.MAX_LEGAL)
  throw new IllegalArgumentException("ascii/spaceChar out of legal range before normalize()");

Try / catch

try {
  String norm = ChineseUtils.normalize(in, ascii, spaceChar, midDot);
} catch (IllegalArgumentException e) {
  // fall back to safe constants
  norm = ChineseUtils.normalize(in, ChineseUtils.LEAVE, ChineseUtils.LEAVE, midDot);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/522b7f89bf8e8dc1. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/trees/international/pennchinese/ChineseUtils.java:97

   *      if it is ASCII then map them from the Chinese Full Width range
   *      to ASCII values, and if it is FULLWIDTH then do the reverse.
   *  @param spaceChar For characters that satisfy Character.isSpaceChar(),
   *      if this is ChineseUtils.LEAVE, then do nothing,
   *      if it is ASCII then map them to the space character U+0020, and
   *      if it is FULLWIDTH then map them to U+3000.
   *  @param midDot For a set of 7 characters that are roughly middle dot characters,
   *      if this is ChineseUtils.LEAVE, then do nothing,
   *      if it is NORMALIZE then map them to the extended Latin character U+00B7, and
   *      if it is FULLWIDTH then map them to U+30FB.
   *  @return The in String normalized according to the other arguments.
   */
  public static String normalize(String in,
                                 int ascii,
                                 int spaceChar,
                                 int midDot) {
    if (ascii < 0 || ascii > MAX_LEGAL ||
        spaceChar < 0 || spaceChar > MAX_LEGAL) {
      throw new IllegalArgumentException("ChineseUtils: Unknown parameter option");
    }
    if (ONLY_BMP) {
      return normalizeBMP(in, ascii, spaceChar, midDot);
    } else {
      return normalizeUnicode(in, ascii, spaceChar, midDot);
    }
  }


  private static String normalizeBMP(String in, int ascii, int spaceChar, int midDot) {
    StringBuilder out = new StringBuilder();
    int len = in.length();
    for (int i = 0; i < len; i++) {
      char cp = in.charAt(i);
      if (Character.isHighSurrogate(cp)) {
        if (i + 1 < len) {
          log.warn("ChineseUtils.normalize warning: non-BMP codepoint U+" +
                  Integer.toHexString(Character.codePointAt(in, i)) + " in " + in);

View on GitHub (pinned to 1b7edd19c4)