stanfordnlp/CoreNLP · error · IllegalArgumentException
Not a valid dashes style:
Error message
Not a valid dashes style:
What it means
PTBLexer options parsing rejects an unknown value for the 'dashes' option. The value string is converted to a LexerUtils.DashesEnum constant via valueOf; if it does not name a valid enum constant, an IllegalArgumentException is thrown. This guards against silent misconfiguration of dash tokenization behavior.
Solutions
- Use a valid DashesEnum value (e.g. 'none', 'ptb3', 'unicode') in the options string
- Check LexerUtils.DashesEnum for the exact accepted constants and their spellings
- Trim/case-insensitively normalize the value before passing (valueOf already uppercases, so spelling matters more than case)
Example fix
// before PTBTokenizer coreLabelTokenizer = new PTBTokenizer<>(reader, "dashes=hyphens", false); // after PTBTokenizer coreLabelTokenizer = new PTBTokenizer<>(reader, "dashes=ptb3", false);
Defensive patterns
Strategy: validation
Validate before calling
Set<String> valid = Arrays.stream(LexerUtils.DashesEnum.values()).map(Enum::name).collect(Collectors.toSet());
if (!valid.contains(value.trim().toUpperCase(Locale.ROOT))) throw new IllegalArgumentException("bad dashes option: " + value); Try / catch
try {
tokenizer = new PTBTokenizer<>(reader, factory, options);
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("Not a valid dashes style")) { /* fallback to default 'dashes=ptb3' or surface config error */ }
throw e;
} Prevention
- Keep option values in constants/enums, never hand-typed strings
- Unit-test your options strings at startup rather than at runtime
- Match enum spelling exactly (valueOf is case-normalized but not typo-tolerant)
When it happens
Trigger: Calling PTBLexer (or PTBTokenizer with options) with 'dashes' set to a string that is not a DashesEnum name, e.g. options string 'dashes=hyphens' or 'dashes=emdash' (valid values are typically 'none', 'ptb3', 'unicode').
Common situations: Copy-pasting tokenizer options from old documentation or blog posts; typos in the option value; assuming free-text dash styles are accepted; migrating configs between CoreNLP versions where enum names changed.
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
- PTBLexer: Invalid option value in constructor:
- PTBLexer: Invalid options key in constructor:
- PTBLexer: the invertible option requires a…
- WordsToSentencesAnnotator: unable to find words/tokens in:
- ArabicLexer: the invertible option requires a…
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/ce1eb097d533452d.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/process/PTBLexer.flex:216
throw new IllegalArgumentException ("Not a valid quotes style: " + value);
}
} else if ("splitAssimilations".equals(key)) {
splitAssimilations = val;
} else if ("splitHyphenated".equals(key)) {
splitHyphenated = val;
} else if ("splitForwardSlash".equals(key)) {
splitForwardSlash = 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)