stanfordnlp/CoreNLP · error · IllegalArgumentException
: Invalid options key in constructor: %n
Error message
%s: Invalid options key in constructor: %s%n
What it means
SpanishLexer's options-based constructor accepts only a fixed set of option keys (e.g. spanishTokenization, splitVerbs, splitNouns, invertible, strictTreebank3, untokenizable, etc.). When a key is passed that does not match any known option name, the constructor throws this IllegalArgumentException. It is a fail-fast guard against misspelled or unsupported tokenizer options.
Solutions
- Check the option key spelling against the recognized keys in SpanishLexer's constructor and fix the typo.
- Remove the unknown key if it is not supported by SpanishLexer (it may belong to a different tokenizer such as PTBTokenizer).
- If configuring via CoreNLP properties, update the tokenize.options value to only SpanishLexer-supported keys.
- Consult the CoreNLP tokenizer documentation for the current list of supported Spanish options after a version upgrade.
Example fix
// before
new SpanishLexer("spanishTokenizaton=true, invertible=true");
// after
new SpanishLexer("spanishTokenization=true, invertible=true"); Defensive patterns
Strategy: validation
Validate before calling
Set<String> allowed = new HashSet<>(Arrays.asList("spanishTokenization", "splitVerbs", "splitNouns", "splitAll", "coptainCappedWords", "quoteStyle", "invertible", "strictTreebank3", "untokenizable", "tokenizeNLs"));
for (String key : options.split(",")) {
String k = key.substring(0, key.indexOf('=') >= 0 ? key.indexOf('=') : key.length()).trim();
if (!allowed.contains(k)) throw new IllegalArgumentException("Unknown SpanishLexer option: " + k);
} Try / catch
try {
lexer = new SpanishLexer(options);
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("Invalid options key")) {
log.error("Bad tokenizer option key, check tokenize.options: " + e.getMessage());
}
throw e;
} Prevention
- Copy option keys from the official SpanishLexer/CoreNLP docs, not from other tokenizers.
- Keep tokenize.options strings short and review each key against the constructor's recognized set.
- Unit-test pipeline properties at startup so a bad key fails immediately, not mid-corpus.
When it happens
Trigger: Calling new SpanishLexer(String options) (or the LexedTokenFactory variant) with a properties/option string containing a key that is not in the lexer's recognized option list, e.g. "latinNormalization" instead of a supported key.
Common situations: Typos in pipeline properties (e.g. tokenize.options in a Stanford CoreNLP configuration), copying options meant for PTBTokenizer into SpanishLexer, or upgrading CoreNLP where an option was removed/renamed.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- Not a valid dashes style:
- FrenchLexer: Invalid option value in constructor: :
- Unknown clique: " + clique
- Not a valid ellipses style:
- FrenchLexer: the invertible option requires a…
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/abf106f3e62aa234.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/international/spanish/process/SpanishLexer.java:14188
case "allDelete":
untokenizable = UntokenizableOptions.ALL_DELETE;
break;
case "noneKeep":
untokenizable = UntokenizableOptions.NONE_KEEP;
break;
case "firstKeep":
untokenizable = UntokenizableOptions.FIRST_KEEP;
break;
case "allKeep":
untokenizable = UntokenizableOptions.ALL_KEEP;
break;
default:
throw new IllegalArgumentException("SpanishLexer: Invalid option value in constructor: " + key + ": " + value);
}
} else if ("strictTreebank3".equals(key)) {
strictTreebank3 = val;
} else {
throw new IllegalArgumentException(String.format("%s: Invalid options key in constructor: %s%n", this.getClass().getName(), key));
}
}
// this.seenUntokenizableCharacter = false; // unnecessary, it's default initialized
if (invertible) {
if ( ! (tf instanceof CoreLabelTokenFactory)) {
throw new IllegalArgumentException("SpanishLexer: the invertible option requires a CoreLabelTokenFactory");
}
prevWord = (CoreLabel) tf.makeToken("", 0, 0);
prevWordAfter = new StringBuilder();
}
}
/** Turn on to find out how things were tokenized. */
private static final boolean DEBUG = false;
/** A logger for this class */
private static final Redwood.RedwoodChannels logger = Redwood.channels(SpanishLexer.class);View on GitHub (pinned to 1b7edd19c4)