stanfordnlp/CoreNLP · error · IllegalStateException
Bad WordShapeClassifier
Error message
Bad WordShapeClassifier
What it means
WordShapeClassifier.wordShape switches on the named shaper; if the shape classifier name does not map to any known scheme (DIGITS, CHINESE, CLUSTER1, etc.), the default branch throws IllegalStateException. It indicates an unknown/unsupported word-shaping scheme name was passed.
Solutions
- Check the spelling of the shape classifier name against WordShapeClassifier's documented constants (e.g. "chinese", "cluster1", "digits")
- Remove or correct the wordShape entry in your properties file
- Use a known default like "dutch"/"chinese" only as documented; otherwise omit wordShape
- Upgrade CoreNLP if the shaper name is from a newer version
Example fix
// before
props.setProperty("wordShape", "brad");
// after
props.setProperty("wordShape", "chinese"); Defensive patterns
Strategy: validation
Validate before calling
Set<String> valid = Set.of("chinese","cluster1","digits");
if (!valid.contains(shapeName)) throw new IllegalArgumentException("unknown wordShape: " + shapeName); Try / catch
try {
shape = WordShapeClassifier.wordShape(word, shapeName);
} catch (IllegalStateException e) {
shape = WordShapeClassifier.wordShape(word, "chinese");
} Prevention
- Copy shaper names only from documented WordShapeClassifier constants
- Lowercase the shape option before use
- Pin CoreNLP version so property files match supported names
When it happens
Trigger: Calling wordShape(str, shapeName) with a name not registered in the classifier lookup, e.g. a typo or a shaper name from a different model/props file (like a feature config specifying wordShape=foo).
Common situations: Typo in the wordShape property of an NER/CRF classifier config; using a shaper name valid in a newer/older Stanford CoreNLP version; passing a raw option string without normalization.
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
- At least two of lang (" + lang + "), openClassTags (length…
- Call next() before calling remove()!
- Could not read Regex mapping
- Either logic is broken or Gabor can't code.
- Error processing :Unknown attribute : from line
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/8b9ac92040362fb9.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/process/WordShapeClassifier.java:194
return wordShapeJenny1(inStr, knownLCWords);
case WORDSHAPECHRIS2:
return wordShapeChris2(inStr, false, knownLCWords);
case WORDSHAPECHRIS2USELC:
return wordShapeChris2(inStr, false, knownLCWords);
case WORDSHAPECHRIS3:
return wordShapeChris2(inStr, true, knownLCWords);
case WORDSHAPECHRIS3USELC:
return wordShapeChris2(inStr, true, knownLCWords);
case WORDSHAPECHRIS4:
return wordShapeChris4(inStr, false, knownLCWords);
case WORDSHAPEDIGITS:
return wordShapeDigits(inStr);
case WORDSHAPECHINESE:
return wordShapeChinese(inStr);
case WORDSHAPECLUSTER1:
return wordShapeCluster1(inStr);
default:
throw new IllegalStateException("Bad WordShapeClassifier");
}
}
/**
* A fairly basic 5-way classifier, that notes digits, and upper
* and lower case, mixed, and non-alphanumeric.
*
* @param s String to find word shape of
* @return Its word shape: a 5 way classification
*/
private static String wordShapeDan1(String s) {
boolean digit = true;
boolean upper = true;
boolean lower = true;
boolean mixed = true;
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (!Character.isDigit(c)) {View on GitHub (pinned to 1b7edd19c4)