stanfordnlp/CoreNLP · error · IllegalArgumentException
Unknown language <props.containsKey("language")>
Error message
Unknown language <props.containsKey("language")> What it means
DependencyParser's Config.setProperties() resolves the `language` property via getLanguage(). If no language property is given (or an unrecognized name is given) the resolved `language` ends up null, and this IllegalArgumentException is thrown. It indicates the parser could not determine which language configuration (treebank language pack, head rules, etc.) to use.
Solutions
- Set the `language` property to a known value, e.g. -language english (or the appropriate UD language name)
- Check accepted values in Config.getLanguage() / the Language enum and fix spelling/case
- If constructing Config programmatically, pass props.put("language", "english") before creating the parser
Example fix
// before
Properties props = new Properties();
DependencyParser parser = DependencyParser.train(props); // language missing
// after
Properties props = new Properties();
props.setProperty("language", "english");
DependencyParser parser = DependencyParser.train(props); Defensive patterns
Strategy: validation
Validate before calling
Properties props = new Properties();
if (props.getProperty("language") == null) props.setProperty("language", "english"); Try / catch
try {
DependencyParser parser = DependencyParser.train(props);
} catch (IllegalArgumentException e) {
props.setProperty("language", "english");
DependencyParser parser = DependencyParser.train(props);
} Prevention
- Always set `language` explicitly in parser properties
- Verify language names against Config.getLanguage()'s supported set
- Note the exception prints containsKey(true/false), not the bad value - log your props yourself
When it happens
Trigger: Instantiating DependencyParser/Config with a Properties object whose `language` key is missing or whose value getLanguage() doesn't recognize (note the message prints props.containsKey("language"), so it confusingly shows true/false).
Common situations: Typos in -language value (e.g. 'english' vs 'englishsd'); building a parser programmatically without setting language; copying config from another parser (e.g. stanford-parser) that used different language keys.
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
- Language does not support parsing!
- Parser requires words with part-of-speech tag annotations
- The dimension of embedding file does not match…
- At least two of lang (" + lang + "), openClassTags (length…
- Bad WordShapeClassifier
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/af709e25439af978.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/parser/nndep/Config.java:260
saveIntermediate = PropertiesUtils.getBool(props, "saveIntermediate", saveIntermediate);
unlabeled = PropertiesUtils.getBool(props, "unlabeled", unlabeled);
cPOS = PropertiesUtils.getBool(props, "cPOS", cPOS);
noPunc = PropertiesUtils.getBool(props, "noPunc", noPunc);
doWordEmbeddingGradUpdate = PropertiesUtils.getBool(props, "doWordEmbeddingGradUpdate", doWordEmbeddingGradUpdate);
// Runtime parsing options
sentenceDelimiter = PropertiesUtils.getString(props, "sentenceDelimiter", sentenceDelimiter);
tagger = PropertiesUtils.getString(props, "tagger.model", tagger);
String escaperClass = props.getProperty("escaper");
escaper = escaperClass != null ? ReflectionLoading.loadByReflection(escaperClass) : null;
// Language options
language = props.containsKey("language")
? getLanguage(props.getProperty("language"))
: language;
if (language == null) {
throw new IllegalArgumentException("Unknown language " + props.containsKey("language"));
}
if (language.params == null) {
throw new IllegalArgumentException("Language " + language + " does not support parsing!");
}
tlp = language.params.treebankLanguagePack();
preTokenized = PropertiesUtils.getBool(props, "tokenized", preTokenized);
// if a tlp was specified go with that
String tlpCanonicalName = props.getProperty("tlp");
if (tlpCanonicalName != null) {
try {
tlp = ReflectionLoading.loadByReflection(tlpCanonicalName);
System.err.println("Loaded TreebankLanguagePack: "+tlpCanonicalName);
} catch (Exception e) {
System.err.println("Error: Failed to load TreebankLanguagePack: "+tlpCanonicalName);
}
}
}View on GitHub (pinned to 1b7edd19c4)