{"record":{"id":"45b5601c78b26480","repo":"stanfordnlp/CoreNLP","slug":"cannot-run-openie-without-a-parse-tree","errorCode":null,"errorMessage":"Cannot run OpenIE without a parse tree!","messagePattern":"Cannot run OpenIE without a parse tree!","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/naturalli/OpenIE.java","lineNumber":470,"sourceCode":"  public void annotateSentence(CoreMap sentence, Map<CoreLabel, List<CoreLabel>> canonicalMentionMap) {\n    List<CoreLabel> tokens = sentence.get(CoreAnnotations.TokensAnnotation.class);\n    if (tokens.size() < 2) {\n\n      // Short sentence. Skip annotating it.\n      sentence.set(NaturalLogicAnnotations.RelationTriplesAnnotation.class, Collections.emptyList());\n      if (!stripEntailments) {\n        sentence.set(NaturalLogicAnnotations.EntailedSentencesAnnotation.class, Collections.emptySet());\n      }\n\n    } else {\n\n      // Get the dependency tree\n      SemanticGraph originalParse = sentence.get(SemanticGraphCoreAnnotations.EnhancedPlusPlusDependenciesAnnotation.class);\n      if (originalParse == null) {\n        originalParse = sentence.get(SemanticGraphCoreAnnotations.BasicDependenciesAnnotation.class);\n      }\n      if (originalParse == null) {\n        throw new IllegalStateException(\"Cannot run OpenIE without a parse tree!\");\n      }\n      // Clean the tree\n      SemanticGraph parse = new SemanticGraph(originalParse);\n      Util.cleanTree(parse, originalParse);\n\n      // Resolve Coreference\n      SemanticGraph canonicalizedParse = parse;\n      if (resolveCoref && !canonicalMentionMap.isEmpty()) {\n        canonicalizedParse = canonicalizeCoref(parse, canonicalMentionMap);\n      }\n\n      // Run OpenIE\n      // (clauses)\n      List<SentenceFragment> clauses = clausesInSentence(canonicalizedParse, true);  // note: uses coref-canonicalized parse\n      // (entailment)\n      Set<SentenceFragment> fragments = entailmentsFromClauses(clauses);\n      // (segment)\n      List<RelationTriple> extractions = segmenter.extract(parse, tokens);  // note: uses non-coref-canonicalized parse!","sourceCodeStart":452,"sourceCodeEnd":488,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/naturalli/OpenIE.java#L452-L488","documentation":"annotateSentence() requires a dependency parse: it first tries EnhancedPlusPlusDependenciesAnnotation, then BasicDependenciesAnnotation. If both are absent it cannot build the SemanticGraph needed for relation extraction, so it throws an IllegalStateException. OpenIE is a downstream annotator that depends on a parsing annotator running first.","triggerScenarios":"Running the openie annotator in a StanfordCoreNLP pipeline without a parser (parse or depparse), or applying OpenIE to CoreMaps/Annotations that were never parsed.","commonSituations":"Pipeline configured as \"tokenize,ssplit,pos,lemma,openie\" (missing depparse); feeding pre-tokenized annotations that skipped parsing; using a custom annotator chain that drops dependency annotations.","solutions":["Add a dependency parser to the pipeline: annotators = \"tokenize,ssplit,pos,lemma,depparse,natlog,openie\".","Verify the input annotations contain EnhancedPlusPlusDependenciesAnnotation (or BasicDependenciesAnnotation) before calling annotateSentence.","If using 'parse' instead of 'depparse', ensure the parse output is converted to dependency annotations the annotator reads."],"exampleFix":"// before\nprops.setProperty(\"annotators\", \"tokenize,ssplit,pos,lemma,openie\");\n// after\nprops.setProperty(\"annotators\", \"tokenize,ssplit,pos,lemma,depparse,natlog,openie\");","handlingStrategy":"validation","validationCode":"if (sentence.get(SemanticGraphCoreAnnotations.EnhancedPlusPlusDependenciesAnnotation.class) == null\n    && sentence.get(SemanticGraphCoreAnnotations.BasicDependenciesAnnotation.class) == null) {\n  throw new IllegalArgumentException(\"Run depparse (or parse) before OpenIE\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  openie.annotate(sentence);\n} catch (IllegalStateException e) {\n  log.warn(\"Skipping sentence without dependency parse\");\n}","preventionTips":["Include depparse (and natlog) before openie in the annotator chain","Don't feed raw pre-tokenized text straight into OpenIE","Assert dependency annotations exist in pipeline integration tests"],"tags":["missing-annotation","openie","precondition","pipeline"],"backgroundTag":"missing-required-argument","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}