stanfordnlp/CoreNLP · error · IllegalArgumentException
Not a valid dashes style:
Error message
Not a valid dashes style:
What it means
FrenchLexer option parsing validates the 'dashes' option value by converting it to LexerUtils.DashesEnum via valueOf; if the string is not an enum constant name (case-insensitive) it rethrows an IllegalArgumentException. This guard ensures the lexer is only configured with a supported dashes style.
Solutions
- Use a valid LexerUtils.DashesEnum constant name (check LexerUtils for allowed values), e.g. 'dashes=short' or whichever constant exists
- Fix typos or casing (case is normalized via toUpperCase, so check spelling not case)
- Inspect LexerUtils.DashesEnum.values() to list valid values
- Validate the options string before constructing the lexer
Example fix
// before
new FrenchLexer("dashes=em-dash");
// after
new FrenchLexer("dashes=short"); Defensive patterns
Strategy: validation
Validate before calling
boolean dashesOk = java.util.Arrays.stream(LexerUtils.DashesEnum.values()).anyMatch(e -> e.name().equalsIgnoreCase(value));
if (!dashesOk) throw new IllegalArgumentException("Bad dashes option: " + value); Type guard
boolean isValidDashesStyle(String v) { return v != null && java.util.Arrays.stream(LexerUtils.DashesEnum.values()).anyMatch(e -> e.name().equalsIgnoreCase(v)); } Try / catch
try { lexer = new FrenchLexer(optionsString); } catch (IllegalArgumentException e) { log.error("Bad lexer option: " + e.getMessage()); throw new ConfigurationException(e); } Prevention
- List DashesEnum values before building the options string
- Copy option values from library docs/tests, not memory
- Centralize lexer option strings as constants
When it happens
Trigger: Calling the FrenchLexer(String) options constructor with 'dashes' set to a value not matching a DashesEnum constant, e.g. options string 'dashes=em-dash' or 'dashes=' (empty).
Common situations: Typo in option value, copying options from English PTBTokenizer that supports different styles, passing an empty or null value in the comma/semicolon-delimited options string.
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
- FrenchLexer: Invalid option value in constructor: :
- : Invalid options key in constructor: %n
- Unknown clique: " + clique
- Not a valid ellipses style:
- FrenchLexer: the invertible option requires a…
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/6d0a4209155ed830.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/international/french/process/FrenchLexer.java:12416
} 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)