{"record":{"id":"c335b3d33548b585","repo":"stanfordnlp/CoreNLP","slug":"no-binarized-parse-tree-perhaps-it-s-not-supporte","errorCode":null,"errorMessage":"No binarized parse tree (perhaps it's not supported in this language?)","messagePattern":"No binarized parse tree \\(perhaps it's not supported in this language\\?\\)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/simple/Document.java","lineNumber":1020,"sourceCode":"        CoreMap sentence = ann.get(CoreAnnotations.SentencesAnnotation.class).get(i);\n        Collection<RelationTriple> triples = sentence.get(CoreAnnotations.KBPTriplesAnnotation.class);\n        sentences.get(i).updateKBP(triples.stream().map(serializer::toProto));\n      }\n    }\n    // Return\n    haveRunKBP = true;\n    return this;\n  }\n\n\n  synchronized Document runSentiment(Properties props) {\n    if (this.sentences != null && ! this.sentences.isEmpty() && this.sentences.get(0).rawSentence().hasSentiment()) {\n        return this;\n    }\n    // Run prerequisites\n    runParse(props);\n    if (this.sentences != null && ! this.sentences.isEmpty() && ! this.sentences.get(0).rawSentence().hasBinarizedParseTree()) {\n      throw new IllegalStateException(\"No binarized parse tree (perhaps it's not supported in this language?)\");\n    }\n    // Run annotator\n    Annotation ann = asAnnotation(true);\n    Supplier<Annotator> sentiment = (props == EMPTY_PROPS || props == SINGLE_SENTENCE_DOCUMENT) ? defaultSentiment : getOrCreate(STANFORD_SENTIMENT, props, () -> backend.sentiment(props, STANFORD_SENTIMENT));\n    sentiment.get().annotate(ann);\n    // Update data\n    synchronized (serializer) {\n      for (int i = 0; i < sentences.size(); ++i) {\n        CoreMap sentence = ann.get(CoreAnnotations.SentencesAnnotation.class).get(i);\n        String sentimentClass = sentence.get(SentimentCoreAnnotations.SentimentClass.class);\n        sentences.get(i).updateSentiment(sentimentClass);\n      }\n    }\n    // Return\n    return this;\n  }\n\n  /**","sourceCodeStart":1002,"sourceCodeEnd":1038,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/simple/Document.java#L1002-L1038","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nString s = doc.sentiment();\n// after\nif (doc.sentences().get(0).rawSentence().hasBinarizedParseTree()) {\n  String s = doc.sentiment();\n}","handlingStrategy":"validation","validationCode":"boolean ok = doc.sentences().stream().findFirst()\n    .map(s -> s.rawSentence().hasBinarizedParseTree())\n    .orElse(false);\nif (!ok) throw new IllegalStateException(\"Run sentiment only when a binarized parse tree exists\");","typeGuard":"boolean canSentiment(Document doc) {\n  return doc.sentences() != null && !doc.sentences().isEmpty()\n      && doc.sentences().get(0).rawSentence().hasBinarizedParseTree();\n}","tryCatchPattern":"try {\n  doc.sentiment();\n} catch (IllegalStateException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"binarized parse tree\")) {\n    log.warn(\"Sentiment requires a binarized parse tree; not available for this language/parser\");\n  } else throw e;\n}","preventionTips":["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."],"tags":["nlp","sentiment","parse-tree","prerequisite"],"backgroundTag":"missing-prerequisite-state","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}