{"record":{"id":"80ec6db9b2db34a5","repo":"stanfordnlp/CoreNLP","slug":"cannot-run-natural-logic-forward-entailment-withou","errorCode":null,"errorMessage":"Cannot run Natural Logic forward entailment without polarity annotations set. See \" + NaturalLogicAnnotator.class.getSimpleName()","messagePattern":"Cannot run Natural Logic forward entailment without polarity annotations set\\. See \" \\+ NaturalLogicAnnotator\\.class\\.getSimpleName\\(\\)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/naturalli/ForwardEntailer.java","lineNumber":76,"sourceCode":"  public ForwardEntailer(NaturalLogicWeights weights) {\n    this(Integer.MAX_VALUE, Integer.MAX_VALUE, weights);\n  }\n\n  /**\n   * Create a new search problem instance, given a sentence (possibly fragment), and the corresponding\n   * parse tree.\n   *\n   * @param parseTree The original tree of the sentence we are beginning with\n   * @param truthOfPremise The truth of the premise. In most applications, this will just be true.\n   *\n   * @return A new search problem instance.\n   */\n  @Override\n  public ForwardEntailerSearchProblem apply(SemanticGraph parseTree, Boolean truthOfPremise) {\n    for (IndexedWord vertex : parseTree.vertexSet()) {\n      CoreLabel token = vertex.backingLabel();\n      if (token != null && !token.containsKey(NaturalLogicAnnotations.PolarityAnnotation.class)) {\n        throw new IllegalArgumentException(\"Cannot run Natural Logic forward entailment without polarity annotations set. See \" + NaturalLogicAnnotator.class.getSimpleName());\n      }\n    }\n    return new ForwardEntailerSearchProblem(parseTree, truthOfPremise, maxResults, maxTicks, weights);\n  }\n}\n","sourceCodeStart":58,"sourceCodeEnd":82,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/naturalli/ForwardEntailer.java#L58-L82","documentation":"ForwardEntailer.apply() requires every token in the parse tree to carry the NaturalLogicAnnotations.PolarityAnnotation, which is produced upstream by the NaturalLogicAnnotator. If any token lacks the annotation, the premise cannot be projected through natural logic, so apply() throws an IllegalArgumentException before creating the search problem.","triggerScenarios":"Calling ForwardEntailer.apply(parseTree, truth) on a SemanticGraph from a pipeline that did not run NaturalLogicAnnotator (polarity annotation missing on at least one token).","commonSituations":"See trigger scenarios.","solutions":["Add \"natlog\" to the StanfordCoreNLP pipeline properties after lemma/depparse: e.g. new StanfordCoreNLP(PropertiesUtils.asProperties(\"annotators\", \"tokenize,ssplit,pos,lemma,depparse,natlog\")).","Verify tokens contain PolarityAnnotation before calling apply(): check token.containsKey(NaturalLogicAnnotations.PolarityAnnotation.class).","If building CoreMaps manually, run NaturalLogicAnnotator over the document first, or populate polarity annotations yourself."],"exampleFix":"// before\nProperties props = new Properties();\nprops.setProperty(\"annotators\", \"tokenize,ssplit,pos,lemma,parse\");\n// after\nprops.setProperty(\"annotators\", \"tokenize,ssplit,pos,lemma,parse,natlog\");","handlingStrategy":"validation","validationCode":"boolean hasPolarity = parseTree.vertexSet().stream()\n    .allMatch(v -> v.backingLabel() == null || v.backingLabel().containsKey(NaturalLogicAnnotations.PolarityAnnotation.class));\nif (!hasPolarity) throw new IllegalArgumentException(\"Run NaturalLogicAnnotator (natlog) first\");","typeGuard":null,"tryCatchPattern":"try {\n  entailer.apply(parseTree, true);\n} catch (IllegalArgumentException e) {\n  throw new IllegalStateException(\"Pipeline missing natlog annotator: \" + e.getMessage(), e);\n}","preventionTips":["Always include \"natlog\" in the annotator list before openie/entailment","Run depparse before natlog so polarity propagation has a parse","Spot-check annotations for PolarityAnnotation in unit tests"],"tags":["missing-annotation","naturalli","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"}