{"record":{"id":"173ae9c49f1d2eac","repo":"stanfordnlp/CoreNLP","slug":"unable-to-find-sentences-in-annotation","errorCode":null,"errorMessage":"unable to find sentences in: \" + annotation","messagePattern":"unable to find sentences in: \" \\+ annotation","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/pipeline/BinarizerAnnotator.java","lineNumber":56,"sourceCode":"  public BinarizerAnnotator(String annotatorName, Properties props) {\n    this.tlppClass = props.getProperty(annotatorName + \".tlppClass\", DEFAULT_TLPP_CLASS);\n    TreebankLangParserParams tlpp = ReflectionLoading.loadByReflection(tlppClass);\n    this.binarizer = TreeBinarizer.simpleTreeBinarizer(tlpp.headFinder(), tlpp.treebankLanguagePack());\n  }\n\n  public String signature(String annotatorName, Properties props) {\n    // String tlppClass = props.getProperty(annotatorName + \".tlppClass\", DEFAULT_TLPP_CLASS);\n    return tlppClass;\n  }\n\n  @Override\n  public void annotate(Annotation annotation) {\n    if (annotation.containsKey(CoreAnnotations.SentencesAnnotation.class)) {\n      for (CoreMap sentence : annotation.get(CoreAnnotations.SentencesAnnotation.class)) {\n        doOneSentence(sentence);\n      }\n    } else {\n      throw new RuntimeException(\"unable to find sentences in: \" + annotation);\n    }\n  }\n\n  private void doOneSentence(CoreMap sentence) {\n    Tree tree = sentence.get(TreeCoreAnnotations.TreeAnnotation.class);\n    Tree binarized;\n    if (isBinarized(tree)) {\n      binarized = tree;\n    } else {\n      binarized = binarizer.transformTree(tree);\n    }\n    Trees.convertToCoreLabels(binarized);\n    sentence.set(TreeCoreAnnotations.BinarizedTreeAnnotation.class, binarized);\n  }\n\n  /**\n   * Recursively check that a tree is not already binarized.\n   */","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/pipeline/BinarizerAnnotator.java#L38-L74","documentation":"BinarizerAnnotator.annotate() expects the Annotation to already contain sentence-level annotations (SentencesAnnotation). When none are present it cannot iterate and throws this RuntimeException. The binarizer operates per sentence, so sentence splitting must run first.","triggerScenarios":"Running the binarizer annotator on an Annotation before tokenize/ssplit has produced CoreAnnotations.SentencesAnnotation, or after an upstream annotator failed to populate it.","commonSituations":"Omitting 'ssplit' (or 'tokenize,ssplit') before the binarizer in the annotators list; pipeline ordering mistakes when composing annotators manually.","solutions":["Add 'tokenize,ssplit' before the binarizer in the 'annotators' property so sentences exist first","Verify with annotation.get(CoreAnnotations.SentencesAnnotation.class) != null before calling annotate","Fix upstream annotators that should populate SentencesAnnotation"],"exampleFix":"// before\nprops.setProperty(\"annotators\", \"binarizer\");\n// after\nprops.setProperty(\"annotators\", \"tokenize,ssplit,binarizer\");","handlingStrategy":"validation","validationCode":"if (annotation.get(CoreAnnotations.SentencesAnnotation.class) == null) {\n  throw new IllegalStateException(\"Run tokenize+ssplit before BinarizerAnnotator\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  binarizer.annotate(annotation);\n} catch (RuntimeException e) {\n  if (e.getMessage().startsWith(\"unable to find sentences\")) {\n    // rerun pipeline with tokenize,ssplit first\n  } else throw e;\n}","preventionTips":["Order annotators: tokenize,ssplit before the binarizer","Use StanfordCoreNLP's requires() machinery instead of hand-built pipelines"],"tags":["stanford-corenlp","missing-prerequisite","pipeline-order","sentences"],"backgroundTag":"missing-required-config-field","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"}