stanfordnlp/CoreNLP · error · IllegalArgumentException

Not a valid quotes style

Error message

Not a valid quotes style: ${value}

What it means

PTBLexer's option parser accepts a "quotes" option whose value must be a name of the LexerUtils.QuotesEnum (e.g. UNICODE, ASCII). The value is upper-cased and passed to valueOf(); if it is not a valid enum constant, valueOf throws IllegalArgumentException and the lexer rethrows it with this message.

Solutions

  1. Check LexerUtils.QuotesEnum and use an exact constant name (case-insensitive), e.g. quotes=unicode or quotes=ascii.
  2. Fix typos/extra words in the option value in your properties or options string.
  3. If style names changed across CoreNLP versions, migrate to the enum names supported by your version.

Example fix

// before
props.setProperty("tokenize.options", "quotes=smart");
// after
props.setProperty("tokenize.options", "quotes=unicode");
Defensive patterns

Strategy: validation

Validate before calling

Set<String> valid = Arrays.stream(LexerUtils.QuotesEnum.values()).map(e -> e.name().toLowerCase(Locale.ROOT)).collect(Collectors.toSet());
if (!valid.contains(value.trim().toLowerCase(Locale.ROOT))) throw new IllegalArgumentException("quotes must be one of " + valid);

Try / catch

try { tokenize(text, "quotes=" + style); } catch (IllegalArgumentException e) { if (e.getMessage().contains("Not a valid quotes style")) { log.warn("bad quotes style, using unicode"); tokenize(text, "quotes=unicode"); } else throw e; }

Prevention

When it happens

Trigger: Calling PTBLexer/PTBTokenizer with option map entry key="quotes" and a value that is not a QuotesEnum constant, e.g. quotes=curly, quotes=", or a misspelling like quotes=unicodes.

Common situations: Typing a free-text token style in tokenizer options (e.g. in a properties file for StanfordCoreNLP with tokenize.options="quotes=smart"); version drift where an old style name was removed; case errors combined with non-enum words.

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


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/ec2dcf877e5066ac. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/process/PTBLexer.java:61123

          } 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)