stanfordnlp/CoreNLP · error · IllegalArgumentException
Not a valid dashes style
Error message
Not a valid dashes style: ${value} What it means
SpanishLexer's constructor accepts a 'dashes' option controlling how dash characters are tokenized, mapped to LexerUtils.DashesEnum via Enum.valueOf. Any value that is not a valid DashesEnum constant (after trim/uppercase) causes this IllegalArgumentException naming the offending value.
Solutions
- Set a valid DashesEnum value such as 'dashes=unicode', 'dashes=delete', or 'dashes=leave' (match LexerUtils.DashesEnum for your version).
- Inspect LexerUtils.DashesEnum to confirm accepted constants in the version in use.
- Pre-validate the value in config loading code and reject bad tokens early.
- Catch IllegalArgumentException around lexer construction and log the offending key/value.
Example fix
// before new SpanishLexer(reader, "dashes=em-dash"); // after new SpanishLexer(reader, "dashes=unicode");
Defensive patterns
Strategy: validation
Validate before calling
String v = value.trim().toUpperCase(Locale.ROOT);
boolean ok = java.util.Arrays.stream(LexerUtils.DashesEnum.values())
.anyMatch(e -> e.name().equals(v));
if (!ok) throw new IllegalArgumentException("Bad dashes option: " + value); Type guard
static boolean isValidDashesStyle(String value) {
if (value == null) return false;
String v = value.trim().toUpperCase(Locale.ROOT);
for (LexerUtils.DashesEnum e : LexerUtils.DashesEnum.values())
if (e.name().equals(v)) return true;
return false;
} Try / catch
try {
lexer = new SpanishLexer(reader, options);
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("Not a valid dashes style")) {
lexer = new SpanishLexer(reader, options.replaceAll("dashes=[^,]*", "dashes=unicode"));
} else { throw e; }
} Prevention
- Mirror PTBTokenizer dash-option names exactly when copying configs.
- Validate all lexer options in one pass before construction.
- Avoid building option strings by fragile string concatenation.
When it happens
Trigger: Constructing SpanishLexer with options 'dashes=<value>' where value is not a DashesEnum name (e.g. 'hyphen', 'em-dash', '', or an alias removed in the current version).
Common situations: Reusing PTBTokenizer 'dashes' settings that differ; hand-edited tokenizer properties files; migrating between CoreNLP versions where enum constant names changed; whitespace/encoding artifacts in the value string (leading/trailing chars are trimmed, but inner junk is not).
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
- SpanishLexer: Invalid option value in constructor
- Not a valid ellipses style:
- TokenizerAnnotator: unknown tokenize.class property
- TokenizerAnnotator: unknown tokenize.language property
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/0253bdf41b8c384b.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/international/spanish/process/SpanishLexer.java:14158
} 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)