stanfordnlp/CoreNLP · error · IllegalArgumentException
Not a valid dashes style:
Error message
Not a valid dashes style:
What it means
SpanishLexer throws this IllegalArgumentException when the 'dashes' option value does not match any constant of LexerUtils.DashesEnum. The value is trimmed, uppercased, and passed to Enum.valueOf; unrecognized names are rethrown with this message at lexer construction time.
Solutions
- Set dashes to a valid LexerUtils.DashesEnum constant name (e.g. "none", "unicode", "ptb").
- Verify the accepted values in LexerUtils.DashesEnum for your CoreNLP version.
- Validate the value with LexerUtils.DashesEnum.valueOf(value.trim().toUpperCase(Locale.ROOT)) in a try-catch before construction.
- Avoid hyphenated or descriptive values — only exact enum names are accepted.
Example fix
// before
props.put("dashes", "hyphens");
// after
props.put("dashes", "unicode"); Defensive patterns
Strategy: validation
Validate before calling
// before constructing SpanishLexer
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 SpanishLexer(reader, tf, options);
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("Not a valid dashes style")) {
options.put("dashes", "ptb");
lex = new SpanishLexer(reader, tf, options);
} else throw e;
} Prevention
- Use LexerUtils.DashesEnum constant names exactly; no hyphens or descriptions.
- Check LexerUtils source for your CoreNLP version before changing values.
- Share a single validated options-builder across your pipeline.
When it happens
Trigger: Constructing SpanishLexer with an options map entry key="dashes" and a value such as "hyphen", "emdash", or "dashes" instead of a valid DashesEnum constant (typically NONE, UNICODE, PTB).
Common situations: Hand-edited CoreNLP tokenizer properties; translating PTBTokenizer dash options into SpanishLexer without checking its enum vocabulary; typos or renamed constants across versions.
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
- Not a valid ellipses style:
- Not a valid dashes style:
- Not a valid ellipses style:
- Unknown LogPriorType:
- Not a valid ellipses style:
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/c2f99ff39d2398d1.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/international/spanish/process/SpanishLexer.flex:150
} 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)