stanfordnlp/CoreNLP · error · RuntimeException
Model location not specified for true-case classifier!
Error message
Model location not specified for true-case classifier!
What it means
TrueCaseAnnotator's constructor resolves the true-case CRF classifier model from the 'truecase.model' property (defaulting to the bundled English model). If the resolved model location is null, it throws this RuntimeException while building the pipeline.
Solutions
- Set a valid 'truecase.model' property pointing at the classifier model file (e.g. the bundled English truecase model)
- Remove the empty/incorrect 'truecase.model' override so the built-in default model path is used
- Verify the property key spelling — a typo key like 'truecase.model ' (trailing space) can yield a null/blank resolution
- Ensure the model file exists at the given path (classpath or filesystem) before constructing the annotator
Example fix
// before
Properties props = new Properties();
props.setProperty("truecase.model", "");
// after
Properties props = new Properties();
props.setProperty("truecase.model", "edu/stanford/nlp/models/truecase/EnglishAll.untaased.caseless.ser.gz"); Defensive patterns
Strategy: validation
Validate before calling
String modelLoc = props.getProperty("truecase.model", DEFAULT_TRUECASE_MODEL);
if (modelLoc == null || modelLoc.trim().isEmpty())
throw new IllegalStateException("truecase.model must point to a classifier model file");
if (!new java.io.File(modelLoc).exists() && getClass().getResource("/" + modelLoc) == null)
throw new IllegalStateException("Truecase model not found: " + modelLoc); Try / catch
try {
annotators.add(new TrueCaseAnnotator(props));
} catch (RuntimeException e) {
if (e.getMessage().contains("Model location not specified")) {
log.error("Set 'truecase.model' to a valid model path or remove the empty override");
}
throw e;
} Prevention
- Never set truecase.model to an empty string; omit the key to use the default
- Verify model file existence (filesystem or classpath) before constructing the pipeline
- Centralize model path constants to avoid typos in keys
- Test pipeline construction in CI so missing models fail early
When it happens
Trigger: Constructing a TrueCaseAnnotator or requesting annotator 'truecase' with a properties object where truecase.model is set to an empty string or otherwise resolves to null, so no model path exists to load.
Common situations: Overriding 'truecase.model' with an empty value in a properties file, copying a partial property subset that drops the default, or programmatic Properties construction that blanks the key.
Related errors
- An error occurred while testing the tagger.
- annotator " " requires annotation " ". The usual…
- : Entry doesn't have overwriteable types , but entry type…
- : Ignoring duplicate entry: , old type = , new type =
- : Replacing duplicate entry (higher priority): old= , new=
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/dfcd2ac560dc39f3.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/pipeline/TrueCaseAnnotator.java:76
public TrueCaseAnnotator(String modelLoc,
String classBias,
String mixedCaseFileName,
boolean overwriteText,
boolean verbose) {
this.overwriteText = overwriteText;
this.verbose = verbose;
Properties props = PropertiesUtils.asProperties(
"loadClassifier", modelLoc,
"mixedCaseMapFile", mixedCaseFileName,
"classBias", classBias);
trueCaser = new CRFBiasedClassifier<>(props);
if (modelLoc != null) {
trueCaser.loadClassifierNoExceptions(modelLoc, props);
} else {
throw new RuntimeException("Model location not specified for true-case classifier!");
}
if (classBias != null) {
StringTokenizer biases = new java.util.StringTokenizer(classBias,",");
while (biases.hasMoreTokens()) {
StringTokenizer bias = new java.util.StringTokenizer(biases.nextToken(),":");
String cname = bias.nextToken();
double w = Double.parseDouble(bias.nextToken());
trueCaser.setBiasWeight(cname,w);
if (this.verbose) log.info("Setting bias for class " + cname + " to " + w);
}
}
// Load map containing mixed-case words:
// TODO:
// this file has some weirdness in it
// for example, 4 different interpretations of el-:
// EL-Dafla, el-Ela, El-Ein, EL-ALYView on GitHub (pinned to 1b7edd19c4)