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
- Add 'tokenize' and 'ssplit' before this annotator in the pipeline properties, e.g. annotators=tokenize,ssplit,quantify.
- Ensure the Annotation passed to annotate() already contains SentencesAnnotation or TokensAnnotation.
- 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
- Always list tokenize,ssplit before quantify in the annotators property.
- When annotating incrementally, populate TokensAnnotation or SentencesAnnotation before calling the annotator.
- Use StanfordCoreNLP's requirement checking instead of invoking annotators directly.
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
- unable to find sentences in
- Unable to find sentences in
- annotator " " requires annotation " ". The usual…
- Unable to process annotators
- Invalid metric type for
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)