stanfordnlp/CoreNLP · error · IllegalArgumentException
Cannot run Natural Logic forward entailment without…
Error message
Cannot run Natural Logic forward entailment without polarity annotations set. See " + NaturalLogicAnnotator.class.getSimpleName()
What it means
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.
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.
Example fix
// before
Properties props = new Properties();
props.setProperty("annotators", "tokenize,ssplit,pos,lemma,parse");
// after
props.setProperty("annotators", "tokenize,ssplit,pos,lemma,parse,natlog"); Defensive patterns
Strategy: validation
Validate before calling
boolean hasPolarity = parseTree.vertexSet().stream()
.allMatch(v -> v.backingLabel() == null || v.backingLabel().containsKey(NaturalLogicAnnotations.PolarityAnnotation.class));
if (!hasPolarity) throw new IllegalArgumentException("Run NaturalLogicAnnotator (natlog) first"); Try / catch
try {
entailer.apply(parseTree, true);
} catch (IllegalArgumentException e) {
throw new IllegalStateException("Pipeline missing natlog annotator: " + e.getMessage(), e);
} Prevention
- 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
When it happens
Trigger: Calling ForwardEntailer.apply(parseTree, truth) on a SemanticGraph from a pipeline that did not run NaturalLogicAnnotator (polarity annotation missing on at least one token).
Common situations: See trigger scenarios.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Cannot run OpenIE without a parse tree!
- Unable to find words/tokens in
- unable to find sentences in
- unable to find sentences in
- Unable to find sentences in
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/80ec6db9b2db34a5.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/naturalli/ForwardEntailer.java:76
public ForwardEntailer(NaturalLogicWeights weights) {
this(Integer.MAX_VALUE, Integer.MAX_VALUE, weights);
}
/**
* Create a new search problem instance, given a sentence (possibly fragment), and the corresponding
* parse tree.
*
* @param parseTree The original tree of the sentence we are beginning with
* @param truthOfPremise The truth of the premise. In most applications, this will just be true.
*
* @return A new search problem instance.
*/
@Override
public ForwardEntailerSearchProblem apply(SemanticGraph parseTree, Boolean truthOfPremise) {
for (IndexedWord vertex : parseTree.vertexSet()) {
CoreLabel token = vertex.backingLabel();
if (token != null && !token.containsKey(NaturalLogicAnnotations.PolarityAnnotation.class)) {
throw new IllegalArgumentException("Cannot run Natural Logic forward entailment without polarity annotations set. See " + NaturalLogicAnnotator.class.getSimpleName());
}
}
return new ForwardEntailerSearchProblem(parseTree, truthOfPremise, maxResults, maxTicks, weights);
}
}
View on GitHub (pinned to 1b7edd19c4)