stanfordnlp/CoreNLP · error · RuntimeException

unable to find sentences in: " + annotation

Error message

unable to find sentences in: " + annotation

What it means

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.

Solutions

  1. Add 'tokenize,ssplit' before the binarizer in the 'annotators' property so sentences exist first
  2. Verify with annotation.get(CoreAnnotations.SentencesAnnotation.class) != null before calling annotate
  3. Fix upstream annotators that should populate SentencesAnnotation

Example fix

// before
props.setProperty("annotators", "binarizer");
// after
props.setProperty("annotators", "tokenize,ssplit,binarizer");
Defensive patterns

Strategy: validation

Validate before calling

if (annotation.get(CoreAnnotations.SentencesAnnotation.class) == null) {
  throw new IllegalStateException("Run tokenize+ssplit before BinarizerAnnotator");
}

Try / catch

try {
  binarizer.annotate(annotation);
} catch (RuntimeException e) {
  if (e.getMessage().startsWith("unable to find sentences")) {
    // rerun pipeline with tokenize,ssplit first
  } else throw e;
}

Prevention

When it happens

Trigger: Running the binarizer annotator on an Annotation before tokenize/ssplit has produced CoreAnnotations.SentencesAnnotation, or after an upstream annotator failed to populate it.

Common situations: Omitting 'ssplit' (or 'tokenize,ssplit') before the binarizer in the annotators list; pipeline ordering mistakes when composing annotators manually.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/173ae9c49f1d2eac. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/pipeline/BinarizerAnnotator.java:56

  public BinarizerAnnotator(String annotatorName, Properties props) {
    this.tlppClass = props.getProperty(annotatorName + ".tlppClass", DEFAULT_TLPP_CLASS);
    TreebankLangParserParams tlpp = ReflectionLoading.loadByReflection(tlppClass);
    this.binarizer = TreeBinarizer.simpleTreeBinarizer(tlpp.headFinder(), tlpp.treebankLanguagePack());
  }

  public String signature(String annotatorName, Properties props) {
    // String tlppClass = props.getProperty(annotatorName + ".tlppClass", DEFAULT_TLPP_CLASS);
    return tlppClass;
  }

  @Override
  public void annotate(Annotation annotation) {
    if (annotation.containsKey(CoreAnnotations.SentencesAnnotation.class)) {
      for (CoreMap sentence : annotation.get(CoreAnnotations.SentencesAnnotation.class)) {
        doOneSentence(sentence);
      }
    } else {
      throw new RuntimeException("unable to find sentences in: " + annotation);
    }
  }

  private void doOneSentence(CoreMap sentence) {
    Tree tree = sentence.get(TreeCoreAnnotations.TreeAnnotation.class);
    Tree binarized;
    if (isBinarized(tree)) {
      binarized = tree;
    } else {
      binarized = binarizer.transformTree(tree);
    }
    Trees.convertToCoreLabels(binarized);
    sentence.set(TreeCoreAnnotations.BinarizedTreeAnnotation.class, binarized);
  }

  /**
   * Recursively check that a tree is not already binarized.
   */

View on GitHub (pinned to 1b7edd19c4)