stanfordnlp/CoreNLP · error · IllegalArgumentException
FrenchLexer: Invalid option value in constructor:
Error message
FrenchLexer: Invalid option value in constructor:
What it means
FrenchLexer throws this IllegalArgumentException when an option value passed to the constructor is not one of the accepted literals for that key. The clearest case is the 'untokenizable' option, whose switch only accepts noneDelete, noneInsert, firstDelete, firstKeep, and allKeep; any other value reaches the default branch. Unlike unknown keys (which are only logged to stderr), invalid values for a known key abort construction.
Solutions
- Set untokenizable to exactly one of: noneDelete, noneInsert, firstDelete, firstKeep, allKeep.
- Check the constructor source in FrenchLexer.flex for the accepted values of the option key you are using.
- Validate options against the known key/value vocabulary before construction.
- Note the exception message includes both key and value: "FrenchLexer: Invalid option value in constructor: <key>: <value>" — use it to locate the offending entry.
Example fix
// before
props.put("untokenizable", "deleteAll");
// after
props.put("untokenizable", "noneDelete"); Defensive patterns
Strategy: validation
Validate before calling
java.util.Set<String> ok = new java.util.HashSet<>(java.util.Arrays.asList(
"noneDelete","noneInsert","firstDelete","firstKeep","allKeep"));
String v = options.get("untokenizable");
if (v != null && !ok.contains(v))
throw new IllegalArgumentException("untokenizable must be one of " + ok + ", got: " + v); Try / catch
try {
lex = new FrenchLexer(reader, tf, options);
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("FrenchLexer: Invalid option value in constructor")) {
// log key/value from message, fix options, retry once
options.put("untokenizable", "noneDelete");
lex = new FrenchLexer(reader, tf, options);
} else throw e;
} Prevention
- Use camelCase exactly as documented for option values.
- Keep a whitelisted vocabulary for each option key in your config loader.
- Fail fast in tests that construct the lexer with your production option maps.
When it happens
Trigger: new FrenchLexer(reader, tf, options) with a known option key whose value is wrong, e.g. "untokenizable" -> "keepAll" or "deleteAll" instead of the exact strings the switch expects.
Common situations: Misremembering the option vocabulary (e.g. writing "all-delete" instead of "allDelete"); reusing PTBTokenizer's untokenizable spellings that differ; properties files edited by hand or generated by other tooling.
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 ellipses style:
- Not a valid dashes style:
- FrenchLexer: the invertible option requires a CoreLabelToken
- Not a valid ellipses style:
- Not a valid dashes style:
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/8287aa896bd36dbf.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/international/french/process/FrenchLexer.flex:180
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":
untokenizable = UntokenizableOptions.FIRST_KEEP;
break;
case "allKeep":
untokenizable = UntokenizableOptions.ALL_KEEP;
break;
default:
throw new IllegalArgumentException("FrenchLexer: Invalid option value in constructor: " + key + ": " + value);
}
} else if ("strictTreebank3".equals(key)) {
strictTreebank3 = val;
} else {
System.err.printf("%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("FrenchLexer: the invertible option requires a CoreLabelTokenFactory");
}
prevWord = (CoreLabel) tf.makeToken("", 0, 0);
prevWordAfter = new StringBuilder();
}
}
View on GitHub (pinned to 1b7edd19c4)