stanfordnlp/CoreNLP · error · IllegalStateException
No binarized parse tree (perhaps it's not supported in this…
Error message
No binarized parse tree (perhaps it's not supported in this language?)
What it means
Document.sentiment() in stanford.nlp.simple requires a binarized constituency parse tree as a prerequisite for the sentiment annotator. After running the parse, if the first sentence's raw sentence has no binarized parse tree (because the parse model/annotator for that language doesn't produce one), it throws IllegalStateException telling you sentiment cannot proceed.
Solutions
- Run sentiment analysis only on documents/languages whose parser produces binarized parse trees (typically English).
- Verify the parse annotator is correctly configured and actually produces trees (check sentence.hasBinarizedParseTree() before calling sentiment).
- For languages without binarized parses, use an external sentiment tool instead of Document.sentiment().
- Check that props passed to sentiment() don't disable or alter the parse annotator.
Example fix
// before
String s = doc.sentiment();
// after
if (doc.sentences().get(0).rawSentence().hasBinarizedParseTree()) {
String s = doc.sentiment();
} Defensive patterns
Strategy: validation
Validate before calling
boolean ok = doc.sentences().stream().findFirst()
.map(s -> s.rawSentence().hasBinarizedParseTree())
.orElse(false);
if (!ok) throw new IllegalStateException("Run sentiment only when a binarized parse tree exists"); Type guard
boolean canSentiment(Document doc) {
return doc.sentences() != null && !doc.sentences().isEmpty()
&& doc.sentences().get(0).rawSentence().hasBinarizedParseTree();
} Try / catch
try {
doc.sentiment();
} catch (IllegalStateException e) {
if (e.getMessage() != null && e.getMessage().contains("binarized parse tree")) {
log.warn("Sentiment requires a binarized parse tree; not available for this language/parser");
} else throw e;
} Prevention
- Verify hasBinarizedParseTree() before calling sentiment().
- Restrict Document.sentiment() to languages whose parser produces binarized trees (typically English).
- Ensure the parse annotator is configured and not disabled by custom properties.
When it happens
Trigger: Calling sentiment() (or runSentiment) on a Document whose language/parser yields no binarized tree — e.g. ChineseDocument falling back to the constituency parser, or parse models without binarization — via props==EMPTY_PROPS or explicit properties.
Common situations: Using sentiment() on non-English documents whose parser doesn't produce binarized trees; misconfigured 'parse' annotator; pipeline where sentiment prerequisites (parse) succeed but produce no binarized tree.
Related errors
- No sentiment value for integer:
- Sentiment analysis is not implemented for Arabic
- Sentiment analysis is not implemented for Chinese
- Sentiment analysis is not implemented for French
- Sentiment analysis is not implemented for Spanish
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/c335b3d33548b585.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/simple/Document.java:1020
CoreMap sentence = ann.get(CoreAnnotations.SentencesAnnotation.class).get(i);
Collection<RelationTriple> triples = sentence.get(CoreAnnotations.KBPTriplesAnnotation.class);
sentences.get(i).updateKBP(triples.stream().map(serializer::toProto));
}
}
// Return
haveRunKBP = true;
return this;
}
synchronized Document runSentiment(Properties props) {
if (this.sentences != null && ! this.sentences.isEmpty() && this.sentences.get(0).rawSentence().hasSentiment()) {
return this;
}
// Run prerequisites
runParse(props);
if (this.sentences != null && ! this.sentences.isEmpty() && ! this.sentences.get(0).rawSentence().hasBinarizedParseTree()) {
throw new IllegalStateException("No binarized parse tree (perhaps it's not supported in this language?)");
}
// Run annotator
Annotation ann = asAnnotation(true);
Supplier<Annotator> sentiment = (props == EMPTY_PROPS || props == SINGLE_SENTENCE_DOCUMENT) ? defaultSentiment : getOrCreate(STANFORD_SENTIMENT, props, () -> backend.sentiment(props, STANFORD_SENTIMENT));
sentiment.get().annotate(ann);
// Update data
synchronized (serializer) {
for (int i = 0; i < sentences.size(); ++i) {
CoreMap sentence = ann.get(CoreAnnotations.SentencesAnnotation.class).get(i);
String sentimentClass = sentence.get(SentimentCoreAnnotations.SentimentClass.class);
sentences.get(i).updateSentiment(sentimentClass);
}
}
// Return
return this;
}
/**View on GitHub (pinned to 1b7edd19c4)