stanfordnlp/CoreNLP · warning
Parsing of sentence failed, possibly because of out of…
Error message
Parsing of sentence failed, possibly because of out of memory. Will ignore and continue: ${words} What it means
ParserAnnotator catches NoSuchParseException during doOneSentence and logs this warning instead of propagating. The parse of the sentence failed, likely because the parser exhausted memory while parsing; the sentence is skipped and annotation continues. This is a resilience mechanism so one bad sentence does not abort an entire document.
Solutions
- Increase JVM heap: java -Xmx4g (or more) when running the pipeline
- Set -parse.maxlen (e.g. 100) so overly long sentences are skipped before the parser attempts them
- Split very long sentences during preprocessing (split on semicolons/newlines)
- Log the sentence text and exclude/retry it individually to isolate the offender
- Reduce kBest (k-best parse count) if you configured a large value
Example fix
// before java -cp stanford-corenlp.jar edu.stanford.nlp.pipeline.StanfordCoreNLP -annotators tokenize,ssplit,parse -file input.txt // after java -Xmx8g -cp stanford-corenlp.jar edu.stanford.nlp.pipeline.StanfordCoreNLP -annotators tokenize,ssplit,parse -parse.maxlen 100 -file input.txt
Defensive patterns
Strategy: try-catch
Validate before calling
if (sentence.split("\\s+").length > maxSentenceLength) {
throw new IllegalArgumentException("Sentence too long for parser: " + sentence.length());
} Try / catch
try {
pipeline.annotate(annotation);
} catch (Throwable t) {
if (t instanceof OutOfMemoryError) {
log.warn("Parser ran out of memory on sentence; skipping");
} else {
throw t;
}
} Prevention
- Run the JVM with generous -Xmx heap
- Set -parse.maxlen to skip overly long sentences
- Pre-split long sentences in preprocessing
- Monitor memory when batch-annotating large corpora
When it happens
Trigger: Annotating a document with the 'parse' annotator when one sentence is so syntactically complex/long that the probabilistic parser (Levin/lexparser) throws NoSuchParseException, commonly under heap pressure.
Common situations: Processing long sentences from legal/academic text with default heap; running CoreNLP in memory-constrained containers; batch-annotating large corpora where one sentence blows the stack/heap.
Related errors
- CANNOT EVEN CREATE ARRAYS OF ORIGINAL SIZE!!!
- CANNOT EVEN CREATE ARRAYS OF ORIGINAL SIZE!!
- : Does not support parse operation.
- : No 1best segmentation available
- No model specified for Parser annotator
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/1bfb6b2b6801f024.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/pipeline/ParserAnnotator.java:370
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);
trees.add(tree);
}
}
}
} catch (OutOfMemoryError e) {
log.error(e); // Beware that we can now get an OOM in logging, too.
log.warn("Parsing of sentence ran out of memory (length=" + words.size() + "). " +
"Will ignore and try to continue.");
} catch (NoSuchParseException e) {
log.warn("Parsing of sentence failed, possibly because of out of memory. " +
"Will ignore and continue: " +
SentenceUtils.listToString(words));
}
return trees;
}
@Override
public Set<Class<? extends CoreAnnotation>> requires() {
if (parser.requiresTags()) {
return Collections.unmodifiableSet(new ArraySet<>(Arrays.asList(
CoreAnnotations.TextAnnotation.class,
CoreAnnotations.TokensAnnotation.class,
CoreAnnotations.ValueAnnotation.class,
CoreAnnotations.OriginalTextAnnotation.class,
CoreAnnotations.CharacterOffsetBeginAnnotation.class,
CoreAnnotations.CharacterOffsetEndAnnotation.class,
CoreAnnotations.IndexAnnotation.class,
CoreAnnotations.SentencesAnnotation.class,View on GitHub (pinned to 1b7edd19c4)