stanfordnlp/CoreNLP · error · IllegalArgumentException
Not a valid quotes style:
Error message
Not a valid quotes style:
What it means
PTBLexer's options parser throws this IllegalArgumentException when the "quotes" option value cannot be converted to a LexerUtils.QuotesEnum constant via valueOf (after trimming and uppercasing). Only enum-constant names like unicode, ascii, original are accepted. This typically happens when configuring the PTBTokenizer through properties (e.g. tokenize.options or tokenizer options in CoreNLP).
Solutions
- Set quotes to one of the valid enum names: unicode, ascii, or original (case-insensitive).
- Check LexerUtils.QuotesEnum in your Stanford CoreNLP version for the exact accepted values (they changed across versions).
- Remove the quotes option entirely to use the default behavior if customization isn't needed.
- Wrap tokenizer construction in try-catch for IllegalArgumentException and log the accepted values.
Example fix
// before
Properties props = new Properties();
props.setProperty("tokenize.options", "quotes=curly,untokenizable=noneDelete"); // throws
// after
props.setProperty("tokenize.options", "quotes=unicode,untokenizable=noneDelete"); Defensive patterns
Strategy: validation
Validate before calling
// Pre-validate the quotes option against the enum
static void checkQuotesOption(String value) {
try {
edu.stanford.nlp.process.LexerUtils.QuotesEnum.valueOf(value.trim().toUpperCase(java.util.Locale.ROOT));
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("quotes must be one of " + java.util.Arrays.toString(edu.stanford.nlp.process.LexerUtils.QuotesEnum.values()) + ", got: " + value);
}
} Try / catch
try {
PTBTokenizer<CoreLabel> tok = new PTBTokenizer<>(reader, options);
} catch (IllegalArgumentException e) {
logger.error("Bad tokenizer option (allowed quotes values: unicode, ascii, original): {}", e.getMessage());
throw e;
} Prevention
- Use only documented enum names: unicode, ascii, original
- Check the QuotesEnum of your exact CoreNLP version
- Validate tokenizer option strings at startup with a smoke tokenize
- Keep tokenizer options in one reviewed constants file
When it happens
Trigger: Setting the tokenizer option quotes=<value> (via PTBTokenizer constructor options string, CoreNLP properties token.quote or tokenize options) with a value that is not a valid LexerUtils.QuotesEnum name, e.g. quotes=smart or quotes=curly.
Common situations: CoreNLP server/properties files using a quotes value copied from outdated documentation; typos like quote (singular) style names; passing human-friendly labels instead of the exact enum constants (UNICODE, ASCII, ORIGINAL).
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 ellipses style:
- TokenizerAnnotator: unknown tokenize.class property ${tokCla
- TokenizerAnnotator: unknown tokenize.language property ${lan
- No valid tokenizer type provided. Use -tokenize.language, -t
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/7328398810d5867f.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/process/PTBLexer.flex:198
} else if ("americanize".equals(key)) {
americanize = val;
} else if ("normalizeSpace".equals(key)) {
normalizeSpace = val;
} else if ("normalizeAmpersandEntity".equals(key)) {
normalizeAmpersandEntity = val;
} else if ("normalizeCurrency".equals(key)) {
normalizeCurrency = val;
} else if ("normalizeFractions".equals(key)) {
normalizeFractions = val;
} else if ("normalizeParentheses".equals(key)) {
normalizeParentheses = val;
} else if ("normalizeOtherBrackets".equals(key)) {
normalizeOtherBrackets = val;
} else if ("quotes".equals(key)) {
try {
quoteStyle = LexerUtils.QuotesEnum.valueOf(value.trim().toUpperCase(Locale.ROOT));
} catch (IllegalArgumentException iae) {
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);View on GitHub (pinned to 1b7edd19c4)