stanfordnlp/CoreNLP · error · UnsupportedOperationException
This language does not support GrammaticalStructures or…
Error message
This language does not support GrammaticalStructures or dependencies
What it means
AbstractTreebankParserParams is the base class for language-specific treebank parameter objects; only English and Chinese implement dependency/GrammaticalStructure support. The default implementation of readGrammaticalStructureFromFile throws UnsupportedOperationException to signal the selected language's parser does not support grammatical structures or dependencies.
Solutions
- Use the English or Chinese treebank parser params/model, which implement grammatical structures
- Generate dependencies with an external tool (e.g. a UDPipe/CoreNLP depparse pipeline) for the unsupported language
- Remove dependency-extraction steps from the pipeline when using unsupported languages
Example fix
// before Options op = new Options(); op.tlpParams = new ArabicTreebankParserParams(); GrammaticalStructure gs = params.readGrammaticalStructureFromFile(f); // after Options op = new Options(); op.tlpParams = new EnglishTreebankParserParams(); GrammaticalStructure gs = params.readGrammaticalStructureFromFile(f);
Defensive patterns
Strategy: validation
Validate before calling
if (!(tlpParams instanceof EnglishTreebankParserParams) && !(tlpParams instanceof ChineseTreebankParserParams)) {
throw new UnsupportedOperationException("dependencies not supported for " + tlpParams.getClass().getName());
} Type guard
function supportsGrammaticalStructures(params) { return params.supportsGrammaticalStructures(); } Try / catch
try {
List<GrammaticalStructure> gss = params.readGrammaticalStructureFromFile(file);
} catch (UnsupportedOperationException e) {
log.info("dependency extraction unsupported for this language: " + e.getMessage());
} Prevention
- Only request grammatical structures for English or Chinese models
- Check treebankLanguagePack().grammarSupported() before dependency conversion
- Use language-appropriate dependency tooling for other languages
When it happens
Trigger: Calling readGrammaticalStructureFromFile on a treebank parser params instance for a language other than English or Chinese (e.g. -tLParam edu.stanford.nlp.parser.lexparser.ArabicTreebankParserParams, German, French, Arabic).
Common situations: Running dependency-extraction tooling (e.g. SemanticGraph / GrammaticalStructureFactory pipelines) against a non-English/non-Chinese parser model.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- BiLexPCFGParser doesn't support k best parses
- BiLexPCFGParser doesn't support best parses
- BiLexPCFGParser doesn't support k sampled parses
- No GrammaticalStructureFactory (typed dependencies)…
- LogPrior.getSigmaSquaredM is undefined for any prior but…
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/24870f073fdaad4f.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/parser/lexparser/AbstractTreebankParserParams.java:478
@Override
public String apply(TregexMatcher m) {
String punc = m.getNode(key).value();
String punctClass = PunctEquivalenceClasser.getPunctClass(punc);
return punctClass.equals("") ? "" : annotationMark + punctClass;
}
@Override
public String toString() { return "AnnotatePunctuationFunction"; }
private static final long serialVersionUID = 1L;
}
@Override
public List<GrammaticalStructure>
readGrammaticalStructureFromFile(String filename)
{
throw new UnsupportedOperationException("This language does not support GrammaticalStructures or dependencies");
}
@Override
public GrammaticalStructure getGrammaticalStructure(Tree t,
Predicate<String> filter,
HeadFinder hf) {
throw new UnsupportedOperationException("This language does not support GrammaticalStructures or dependencies");
}
/**
* By default, parsers are assumed to not support dependencies.
* Only English and Chinese do at present.
*/
@Override
public boolean supportsBasicDependencies() {
return false;
}
View on GitHub (pinned to 1b7edd19c4)