{"record":{"id":"6aa537313c3a8efd","repo":"stanfordnlp/CoreNLP","slug":"unable-to-find-sentences-in-annotation-6aa537","errorCode":null,"errorMessage":"unable to find sentences in: ${annotation}","messagePattern":"unable to find sentences in: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/pipeline/SentenceAnnotator.java","lineNumber":106,"sourceCode":"        List<CoreMap> failedSentences = wrapper.joinWithTimeout();\n        while (wrapper.peek()) {\n          wrapper.poll();\n        }\n        if (failedSentences != null) {\n          for (CoreMap failed : failedSentences) {\n            doOneFailedSentence(annotation, failed);\n          }\n        }\n      } else {\n        for (CoreMap sentence : annotation.get(CoreAnnotations.SentencesAnnotation.class)) {\n          if (Thread.interrupted()) {\n            throw new RuntimeInterruptedException();\n          }\n          doOneSentence(annotation, sentence);\n        }\n      }\n    } else {\n      throw new IllegalArgumentException(\"unable to find sentences in: \" + annotation);\n    }\n  }\n\n  protected abstract int nThreads();\n\n  /**\n   * The maximum time to run this annotator for, in milliseconds.\n   */\n  protected abstract long maxTime();\n\n  /** annotation is included in case there is global information we care about */\n  protected abstract void doOneSentence(Annotation annotation, CoreMap sentence);\n\n  /**\n   * Fills in empty annotations for trees, tags, etc if the annotator\n   * failed or timed out.  Not supposed to do major processing.\n   *\n   * @param annotation The whole Annotation object, in case it is needed for context.","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/pipeline/SentenceAnnotator.java#L88-L124","documentation":"SentenceAnnotator's annotate() dispatches per-sentence work (optionally threaded) but requires the Annotation to already contain SentencesAnnotation; subclasses like ParserAnnotator run after sentence splitting. When the key is missing it throws IllegalArgumentException because a prerequisite annotator was not run.","triggerScenarios":"Running annotators that extend SentenceAnnotator (e.g. parse, sentiment, nlu) on an Annotation without SentencesAnnotation — typically when 'ssplit' is missing from the pipeline or annotate() is called directly.","commonSituations":"Pipelines like annotators=tokenize,parse (missing ssplit), calling SentenceAnnotator subclasses on a raw Annotation in tests, or clearing the annotation between stages.","solutions":["Include 'ssplit' (and 'tokenize') before the sentence-level annotator: annotators=tokenize,ssplit,parse.","Populate CoreAnnotations.SentencesAnnotation manually when feeding pre-segmented text.","Run WordsToSentencesAnnotator explicitly if annotating incrementally outside StanfordCoreNLP."],"exampleFix":"// before\nprops.setProperty(\"annotators\", \"tokenize,parse\");\n// after\nprops.setProperty(\"annotators\", \"tokenize,ssplit,parse\");","handlingStrategy":"validation","validationCode":"if (!annotation.containsKey(CoreAnnotations.SentencesAnnotation.class)) {\n  throw new IllegalStateException(\"Sentence-level annotator requires SentencesAnnotation; add ssplit to the pipeline\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  annotator.annotate(annotation);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"unable to find sentences in\")) {\n    wordsToSentences.annotate(annotation);\n    annotator.annotate(annotation);\n  } else throw e;\n}","preventionTips":["Include ssplit before any SentenceAnnotator subclass (parse, sentiment, depparse).","Avoid pipelines like tokenize,parse — ssplit is mandatory.","For pre-segmented input, build SentencesAnnotation manually before annotation."],"tags":["corenlp","pipeline","missing-annotation","configuration"],"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"}