stanfordnlp/CoreNLP · error · IllegalArgumentException
Invalid value for useUnknownWordSignatures:
Error message
Invalid value for useUnknownWordSignatures:
What it means
EnglishUnknownWordModel's constructor validates the unknown word signature level (unknownLevel, inherited from UnknownWordModel defaults). If it falls below MIN_UNKNOWN or above MAX_UNKNOWN, the constructor throws IllegalArgumentException 'Invalid value for useUnknownWordSignatures: <level>'.
Solutions
- Set useUnknownWordSignatures to a supported value (within MIN_UNKNOWN..MAX_UNKNOWN, e.g. the default used by English parser models)
- Check the Options/LexOptions source of the unknownLevel and correct it before constructing the model
- If loading from a serialized model, regenerate options with a supported level
Example fix
// before op.lexOptions.useUnknownWordSignatures = 9; // out of range // after op.lexOptions.useUnknownWordSignatures = 5; // supported level
Defensive patterns
Strategy: validation
Validate before calling
int level = op.lexOptions.useUnknownWordSignatures; if (level < MIN_UNKNOWN || level > MAX_UNKNOWN) throw new IllegalArgumentException("useUnknownWordSignatures out of range: " + level); Type guard
boolean isValidUnknownLevel(int v) { return v >= MIN_UNKNOWN && v <= MAX_UNKNOWN; } Try / catch
try { new EnglishUnknownWordModel(op, lex, wordIndex, tagIndex, unSeen); } catch (IllegalArgumentException e) { op.lexOptions.useUnknownWordSignatures = DEFAULT_UNKNOWN; retry(); } Prevention
- Validate options loaded from serialized/edited files before model construction
- Use documented default values for useUnknownWordSignatures
When it happens
Trigger: Building an EnglishUnknownWordModel when the configured unknown/signature level option (useUnknownWordSignatures) is outside the supported enum-like range, typically due to a bad value in parser options or a training file that recorded an invalid level.
Common situations: Hand-edited parser options or serialized option files carrying an unsupported unknownLevel; experimental settings pushing the level past the supported max.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Both parse.model and parse.executable properties must be…
- Unknown parser type: " + parserType + " (currently…
- Unknown LogPriorType:
- unsupported language
- no sieve type specified
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/c84af6403c3dc42a.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/parser/lexparser/EnglishUnknownWordModel.java:71
private static final boolean DEBUG_UWM = false;
protected final boolean smartMutation;
protected final int unknownSuffixSize;
protected final int unknownPrefixSize;
protected final String wordClassesFile;
private static final int MIN_UNKNOWN = 0;
private static final int MAX_UNKNOWN = 8;
public EnglishUnknownWordModel(Options op, Lexicon lex,
Index<String> wordIndex,
Index<String> tagIndex,
ClassicCounter<IntTaggedWord> unSeenCounter) {
super(op, lex, wordIndex, tagIndex, unSeenCounter, null, null, null);
if (unknownLevel < MIN_UNKNOWN || unknownLevel > MAX_UNKNOWN) {
throw new IllegalArgumentException("Invalid value for useUnknownWordSignatures: " + unknownLevel);
}
this.smartMutation = op.lexOptions.smartMutation;
this.unknownSuffixSize = op.lexOptions.unknownSuffixSize;
this.unknownPrefixSize = op.lexOptions.unknownPrefixSize;
wordClassesFile = op.lexOptions.wordClassesFile;
}
/**
* This constructor creates an UWM with empty data structures. Only
* use if loading in the data separately, such as by reading in text
* lines containing the data.
*/
public EnglishUnknownWordModel(Options op, Lexicon lex,
Index<String> wordIndex,
Index<String> tagIndex) {
this(op, lex, wordIndex, tagIndex, new ClassicCounter<>());
}
View on GitHub (pinned to 1b7edd19c4)