{"record":{"id":"ddd47c28fdd6592f","repo":"stanfordnlp/CoreNLP","slug":"unable-to-find-sentences-in-annotation-ddd47c","errorCode":null,"errorMessage":"unable to find sentences in: ${annotation}","messagePattern":"unable to find sentences in: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/pipeline/QuantifiableEntityNormalizingAnnotator.java","lineNumber":116,"sourceCode":"    if (VERBOSE) {\n      timer.start();\n      log.info(\"Normalizing quantifiable entities...\");\n    }\n    if (annotation.containsKey(CoreAnnotations.SentencesAnnotation.class)) {\n      List<CoreMap> sentences = annotation.get(CoreAnnotations.SentencesAnnotation.class);\n      for (CoreMap sentence : annotation.get(CoreAnnotations.SentencesAnnotation.class)) {\n        List<CoreLabel> tokens = sentence.get(CoreAnnotations.TokensAnnotation.class);\n        annotateTokens(tokens);\n      }\n      if (VERBOSE) {\n        timer.stop(\"done.\");\n        log.info(\"output: \" + sentences + '\\n');\n      }\n    } else if (annotation.containsKey(CoreAnnotations.TokensAnnotation.class)) {\n      List<CoreLabel> tokens = annotation.get(CoreAnnotations.TokensAnnotation.class);\n      annotateTokens(tokens);\n    } else {\n      throw new RuntimeException(\"unable to find sentences in: \" + annotation);\n    }\n  }\n\n  private <TOKEN extends CoreLabel> void annotateTokens(List<TOKEN> tokens) {\n    // Make a copy of the tokens before annotating because QuantifiableEntityNormalizer may change the POS too\n    List<CoreLabel> words = new ArrayList<>();\n    for (CoreLabel token : tokens) {\n      CoreLabel word = new CoreLabel();\n      word.setWord(token.word());\n      word.setNER(token.ner());\n      word.setTag(token.tag());\n\n      // copy fields potentially set by SUTime\n      NumberSequenceClassifier.transferAnnotations(token, word);\n\n      words.add(word);\n    }\n    doOneSentence(words);","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/pipeline/QuantifiableEntityNormalizingAnnotator.java#L98-L134","documentation":"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.","triggerScenarios":"Calling annotate(Annotation) on a bare annotation created without running the tokenizer/SSplit annotators first, so no SentencesAnnotation or TokensAnnotation exists.","commonSituations":"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.","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()."],"exampleFix":"// before\nProperties props = new Properties();\nprops.setProperty(\"annotators\", \"quantify\");\n// after\nprops.setProperty(\"annotators\", \"tokenize,ssplit,quantify\");","handlingStrategy":"validation","validationCode":"if (!annotation.containsKey(CoreAnnotations.SentencesAnnotation.class)\n    && !annotation.containsKey(CoreAnnotations.TokensAnnotation.class)) {\n  throw new IllegalStateException(\"Run tokenize,ssplit before QuantifiableEntityNormalizingAnnotator\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  annotator.annotate(annotation);\n} catch (RuntimeException e) {\n  if (e.getMessage().startsWith(\"unable to find sentences in\")) {\n    pipeline.annotate(annotation); // rerun full pipeline incl. tokenize/ssplit\n  } else throw e;\n}","preventionTips":["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."],"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"}