stanfordnlp/CoreNLP · error · RuntimeException

unable to find sentences in

Error message

unable to find sentences in: ${annotation}

What it means

QuantifiableEntityNormalizingAnnotator.annotate expects the input Annotation to contain either the SentencesAnnotation (list of sentences) or, as fallback, TokensAnnotation. If neither key is present it cannot locate text to normalize and throws a RuntimeException.

Solutions

  1. Add 'tokenize' and 'ssplit' before this annotator in the pipeline properties, e.g. annotators=tokenize,ssplit,quantify.
  2. Ensure the Annotation passed to annotate() already contains SentencesAnnotation or TokensAnnotation.
  3. If processing pre-tokenized text, populate CoreAnnotations.TokensAnnotation yourself before calling annotate().

Example fix

// before
Properties props = new Properties();
props.setProperty("annotators", "quantify");
// after
props.setProperty("annotators", "tokenize,ssplit,quantify");
Defensive patterns

Strategy: validation

Validate before calling

if (!annotation.containsKey(CoreAnnotations.SentencesAnnotation.class)
    && !annotation.containsKey(CoreAnnotations.TokensAnnotation.class)) {
  throw new IllegalStateException("Run tokenize,ssplit before QuantifiableEntityNormalizingAnnotator");
}

Try / catch

try {
  annotator.annotate(annotation);
} catch (RuntimeException e) {
  if (e.getMessage().startsWith("unable to find sentences in")) {
    pipeline.annotate(annotation); // rerun full pipeline incl. tokenize/ssplit
  } else throw e;
}

Prevention

When it happens

Trigger: Calling annotate(Annotation) on a bare annotation created without running the tokenizer/SSplit annotators first, so no SentencesAnnotation or TokensAnnotation exists.

Common situations: Building an Annotation from raw text and adding 'quantify' (or 'dcoref' pipelines using it) to a StanfordCoreNLP pipeline without preceding 'tokenize,ssplit'; running annotators out of order or on a manually built Annotation.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at src/edu/stanford/nlp/pipeline/QuantifiableEntityNormalizingAnnotator.java:116

    if (VERBOSE) {
      timer.start();
      log.info("Normalizing quantifiable entities...");
    }
    if (annotation.containsKey(CoreAnnotations.SentencesAnnotation.class)) {
      List<CoreMap> sentences = annotation.get(CoreAnnotations.SentencesAnnotation.class);
      for (CoreMap sentence : annotation.get(CoreAnnotations.SentencesAnnotation.class)) {
        List<CoreLabel> tokens = sentence.get(CoreAnnotations.TokensAnnotation.class);
        annotateTokens(tokens);
      }
      if (VERBOSE) {
        timer.stop("done.");
        log.info("output: " + sentences + '\n');
      }
    } else if (annotation.containsKey(CoreAnnotations.TokensAnnotation.class)) {
      List<CoreLabel> tokens = annotation.get(CoreAnnotations.TokensAnnotation.class);
      annotateTokens(tokens);
    } else {
      throw new RuntimeException("unable to find sentences in: " + annotation);
    }
  }

  private <TOKEN extends CoreLabel> void annotateTokens(List<TOKEN> tokens) {
    // Make a copy of the tokens before annotating because QuantifiableEntityNormalizer may change the POS too
    List<CoreLabel> words = new ArrayList<>();
    for (CoreLabel token : tokens) {
      CoreLabel word = new CoreLabel();
      word.setWord(token.word());
      word.setNER(token.ner());
      word.setTag(token.tag());

      // copy fields potentially set by SUTime
      NumberSequenceClassifier.transferAnnotations(token, word);

      words.add(word);
    }
    doOneSentence(words);

View on GitHub (pinned to 1b7edd19c4)