stanfordnlp/CoreNLP · error · IllegalArgumentException

Not a valid dashes style:

Error message

Not a valid dashes style: 

What it means

FrenchLexer throws this IllegalArgumentException when the 'dashes' option value does not match any constant of LexerUtils.DashesEnum. Like the ellipses option, the value is trimmed, uppercased and passed to Enum.valueOf; unrecognized values fail and are rethrown with this message. Thrown at lexer construction time.

Solutions

  1. Use a valid LexerUtils.DashesEnum constant name for the dashes option (e.g. "none", "unicode", "ptb").
  2. Inspect LexerUtils.DashesEnum in your CoreNLP version for the accepted values.
  3. Pre-validate the value with a try-catch around LexerUtils.DashesEnum.valueOf(value.trim().toUpperCase(Locale.ROOT)) before constructing the lexer.
  4. Fix typos: value matching is by enum name after trim+uppercase, no hyphens or extra words allowed.

Example fix

// before
props.put("dashes", "em-dash");
lex = new FrenchLexer(reader, tf, props);
// after
props.put("dashes", "ptb");
lex = new FrenchLexer(reader, tf, props);
Defensive patterns

Strategy: validation

Validate before calling

// before constructing FrenchLexer
String v = options.get("dashes");
if (v != null) {
  try { LexerUtils.DashesEnum.valueOf(v.trim().toUpperCase(Locale.ROOT)); }
  catch (IllegalArgumentException e) { throw new IllegalArgumentException("bad dashes value: " + v); }
}

Try / catch

try {
  lex = new FrenchLexer(reader, tf, options);
} catch (IllegalArgumentException e) {
  if (e.getMessage().contains("Not a valid dashes style")) {
    options.put("dashes", "ptb");
    lex = new FrenchLexer(reader, tf, options);
  } else throw e;
}

Prevention

When it happens

Trigger: Constructing FrenchLexer with an options map containing key="dashes" and a value such as "hyphen" or "em-dash" instead of a valid DashesEnum constant (typically NONE, UNICODE, PTB).

Common situations: Hand-written tokenizer options in a Stanford CoreNLP pipeline properties file; porting English PTBTokenizer dash options to FrenchLexer; typos or version drift where enum constants were renamed between CoreNLP releases.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at src/edu/stanford/nlp/international/french/process/FrenchLexer.flex:155

        } else if ("normalizeAmpersandEntity".equals(key)) {
          normalizeAmpersandEntity = val;
        } else if ("normalizeFractions".equals(key)) {
          normalizeFractions = val;
        } else if ("normalizeParentheses".equals(key)) {
          normalizeParentheses = val;
        } else if ("normalizeOtherBrackets".equals(key)) {
          normalizeOtherBrackets = val;
        } else if ("ellipses".equals(key)) {
          try {
            ellipsisStyle = LexerUtils.EllipsesEnum.valueOf(value.trim().toUpperCase(Locale.ROOT));
          } catch (IllegalArgumentException iae) {
            throw new IllegalArgumentException ("Not a valid ellipses style: " + value);
          }
        } else if ("dashes".equals(key)) {
          try {
            dashesStyle = LexerUtils.DashesEnum.valueOf(value.trim().toUpperCase(Locale.ROOT));
          } catch (IllegalArgumentException iae) {
            throw new IllegalArgumentException ("Not a valid dashes style: " + value);
          }
        } else if ("escapeForwardSlashAsterisk".equals(key)) {
          escapeForwardSlashAsterisk = val;
        } else if ("untokenizable".equals(key)) {
          switch (value) {
            case "noneDelete":
              untokenizable = UntokenizableOptions.NONE_DELETE;
              break;
            case "firstDelete":
              untokenizable = UntokenizableOptions.FIRST_DELETE;
              break;
            case "allDelete":
              untokenizable = UntokenizableOptions.ALL_DELETE;
              break;
            case "noneKeep":
              untokenizable = UntokenizableOptions.NONE_KEEP;
              break;
            case "firstKeep":

View on GitHub (pinned to 1b7edd19c4)