stanfordnlp/CoreNLP · warning
Parsing of sentence failed. Will ignore and continue
Error message
Parsing of sentence failed. Will ignore and continue: ${words} What it means
ParserAnnotator's doOneSentence requests a parse for each sentence; when kBest == 1 and the parser returns null for getBestParse(), the annotator logs this warning with the sentence text and simply skips that sentence — no parse tree is added to the annotation, so downstream keys (tree/constituency parse) will be missing for that sentence.
Solutions
- Increase the parse maxlen (parse.maxlen or -maxLength option) if the failing sentences are simply too long.
- Log/inspect the sentence text from the warning to identify pathological inputs and filter or pre-process them (e.g., split overly long sentences).
- Check tokenizer/segmenter settings so sentences are not reduced to unparseable token sequences.
- If null parses are expected and acceptable, the behavior is already a safe skip; make downstream code handle sentences without a ConstituencyAnnotation.
Example fix
// before: default maxlen, long sentences return null parses
props.setProperty("annotators", "tokenize,ssplit,pos,parse");
// after
props.setProperty("annotators", "tokenize,ssplit,pos,parse");
props.setProperty("parse.maxlen", "100"); // raise the length limit Defensive patterns
Strategy: fallback
Validate before calling
// Pre-filter sentences that exceed the parser's max length
props.setProperty("parse.maxlen", "100");
sentences = sentences.stream()
.filter(s -> s.get(TokensAnnotation.class).size() <= 100)
.collect(Collectors.toList()); Try / catch
// After annotation, handle sentences with no parse tree
for (CoreMap sentence : doc.get(SentencesAnnotation.class)) {
Tree tree = sentence.get(TreeAnnotation.class);
if (tree == null) {
// sentence was skipped by ParserAnnotator; use fallback (e.g., dependency-only) logic
}
} Prevention
- Set parse.maxlen above the longest expected sentence, or split long sentences beforehand
- Check tokenization so sentences don't degrade to unparseable token sequences
- After annotation, null-check TreeAnnotation per sentence — the annotator silently skips failures
- Monitor how often this warning fires; a high rate points to a max length or tokenizer misconfiguration
When it happens
Trigger: The underlying parser (e.g., the LexicalizedParser/QueryResult wrapped in pq) fails to produce any parse for a sentence — commonly because the sentence exceeds the parser's maxLength configuration, or contains no parseable tokens after tokenization/filtering.
Common situations: Long sentences over parse maxlen (default limits cause null parses); sentences consisting only of unusual tokens/symbols; constrained parsing where constraints admit no tree; degenerate input like empty or single-garbage-token sentences.
Related errors
- Cannot find matching labelled span for
- Bad number put into wordToNumber. Word is: \"" + input +…
- Error in wordToNumber function.
- Bad number put into wordToNumber. Word is: \"" + curPart +…
- CORE: CoreLabel.initFromStrings: Can't handle
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/1a82a9cbeb4ddb74.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/pipeline/ParserAnnotator.java:342
&& sentence.get(CoreAnnotations.SentenceIndexAnnotation.class) != null) {
iw.setSentIndex(sentence.get(CoreAnnotations.SentenceIndexAnnotation.class));
}
}
}
}
private List<Tree> doOneSentence(List<ParserConstraint> constraints,
List<CoreLabel> words) {
ParserQuery pq = parser.parserQuery();
pq.setConstraints(constraints);
pq.parse(words);
List<Tree> trees = Generics.newLinkedList();
try {
// Use bestParse if kBest is set to 1.
if (this.kBest == 1) {
Tree t = pq.getBestParse();
if (t == null) {
log.warn("Parsing of sentence failed. " +
"Will ignore and continue: " +
SentenceUtils.listToString(words));
} else {
double score = pq.getBestScore();
t.setScore(score % -10000.0);
trees.add(t);
}
} else {
List<ScoredObject<Tree>> scoredObjects = pq.getKBestParses(this.kBest);
if (scoredObjects == null || scoredObjects.size() < 1) {
log.warn("Parsing of sentence failed. " +
"Will ignore and continue: " +
SentenceUtils.listToString(words));
} else {
for (ScoredObject<Tree> so : scoredObjects) {
// -10000 denotes unknown words
Tree tree = so.object();
tree.setScore(so.score() % -10000.0);View on GitHub (pinned to 1b7edd19c4)