{"record":{"id":"1bfb6b2b6801f024","repo":"stanfordnlp/CoreNLP","slug":"parsing-of-sentence-failed-possibly-because-of-ou","errorCode":null,"errorMessage":"Parsing of sentence failed, possibly because of out of memory.  Will ignore and continue: ${words}","messagePattern":"Parsing of sentence failed, possibly because of out of memory\\.  Will ignore and continue: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/edu/stanford/nlp/pipeline/ParserAnnotator.java","lineNumber":370,"sourceCode":"        if (scoredObjects == null || scoredObjects.size() < 1) {\n          log.warn(\"Parsing of sentence failed.  \" +\n              \"Will ignore and continue: \" +\n              SentenceUtils.listToString(words));\n        } else {\n          for (ScoredObject<Tree> so : scoredObjects) {\n            // -10000 denotes unknown words\n            Tree tree = so.object();\n            tree.setScore(so.score() % -10000.0);\n            trees.add(tree);\n          }\n        }\n      }\n    } catch (OutOfMemoryError e) {\n      log.error(e); // Beware that we can now get an OOM in logging, too.\n      log.warn(\"Parsing of sentence ran out of memory (length=\" + words.size() + \").  \" +\n              \"Will ignore and try to continue.\");\n    } catch (NoSuchParseException e) {\n      log.warn(\"Parsing of sentence failed, possibly because of out of memory.  \" +\n              \"Will ignore and continue: \" +\n              SentenceUtils.listToString(words));\n    }\n    return trees;\n  }\n\n  @Override\n  public Set<Class<? extends CoreAnnotation>> requires() {\n    if (parser.requiresTags()) {\n      return Collections.unmodifiableSet(new ArraySet<>(Arrays.asList(\n          CoreAnnotations.TextAnnotation.class,\n          CoreAnnotations.TokensAnnotation.class,\n          CoreAnnotations.ValueAnnotation.class,\n          CoreAnnotations.OriginalTextAnnotation.class,\n          CoreAnnotations.CharacterOffsetBeginAnnotation.class,\n          CoreAnnotations.CharacterOffsetEndAnnotation.class,\n          CoreAnnotations.IndexAnnotation.class,\n          CoreAnnotations.SentencesAnnotation.class,","sourceCodeStart":352,"sourceCodeEnd":388,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/pipeline/ParserAnnotator.java#L352-L388","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\njava -cp stanford-corenlp.jar edu.stanford.nlp.pipeline.StanfordCoreNLP -annotators tokenize,ssplit,parse -file input.txt\n// after\njava -Xmx8g -cp stanford-corenlp.jar edu.stanford.nlp.pipeline.StanfordCoreNLP -annotators tokenize,ssplit,parse -parse.maxlen 100 -file input.txt","handlingStrategy":"try-catch","validationCode":"if (sentence.split(\"\\\\s+\").length > maxSentenceLength) {\n  throw new IllegalArgumentException(\"Sentence too long for parser: \" + sentence.length());\n}","typeGuard":null,"tryCatchPattern":"try {\n  pipeline.annotate(annotation);\n} catch (Throwable t) {\n  if (t instanceof OutOfMemoryError) {\n    log.warn(\"Parser ran out of memory on sentence; skipping\");\n  } else {\n    throw t;\n  }\n}","preventionTips":["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"],"tags":["nlp","parser","out-of-memory","java"],"backgroundTag":"out-of-memory","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}