{"record":{"id":"c3dddd99ee6eac61","repo":"stanfordnlp/CoreNLP","slug":"no-document-date-specified","errorCode":null,"errorMessage":"No document date specified","messagePattern":"No document date specified","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/edu/stanford/nlp/time/TimeAnnotator.java","lineNumber":200,"sourceCode":"  }\n\n  public TimeAnnotator(String name, Properties props) {\n    this(name, props, false);\n  }\n\n  public TimeAnnotator(String name, Properties props, boolean quiet) {\n    timexExtractor = new TimeExpressionExtractorImpl(name, props);\n    this.quiet = quiet;\n  }\n\n  @Override\n  public void annotate(Annotation annotation) {\n    SUTime.TimeIndex timeIndex = new SUTime.TimeIndex();\n    String docDate = annotation.get(CoreAnnotations.DocDateAnnotation.class);\n    if (docDate == null) {\n      Calendar cal = annotation.get(CoreAnnotations.CalendarAnnotation.class);\n      if (cal == null) {\n        if ( ! quiet) { log.warn(\"No document date specified\"); }\n      } else {\n        SimpleDateFormat dateFormat = new SimpleDateFormat(\"yyyy-MM-dd:hh:mm:ss\");\n        docDate = dateFormat.format(cal.getTime());\n      }\n    }\n    List<CoreMap> allTimeExpressions; // initialized below = null;\n    List<CoreMap> sentences = annotation.get(CoreAnnotations.SentencesAnnotation.class);\n    if (sentences != null) {\n      allTimeExpressions = new ArrayList<>();\n      List<CoreMap> allNumerics = new ArrayList<>();\n      for (CoreMap sentence: sentences) {\n        // make sure that token character offsets align with the actual sentence text\n        // They may not align due to token normalizations, such as \"(\" to \"-LRB-\".\n        CoreMap alignedSentence =  NumberSequenceClassifier.alignSentence(sentence);\n        // uncomment the next line for verbose dumping of tokens....\n        // log.info(\"SENTENCE: \" + ((ArrayCoreMap) sentence).toShorterString());\n        List<CoreMap> timeExpressions =\n          timexExtractor.extractTimeExpressionCoreMaps(alignedSentence, docDate, timeIndex);","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/time/TimeAnnotator.java#L182-L218","documentation":"TimeAnnotator (SUTime) anchors relative time expressions to a reference document date taken from the DocDateAnnotation (or CalendarAnnotation). If neither is present it logs 'No document date specified' (unless quiet) and continues, but relative expressions like 'yesterday' or 'last week' will resolve incorrectly or remain unresolved.","triggerScenarios":"Running pipeline.annotate on an Annotation without setting CoreAnnotations.DocDateAnnotation and without a CalendarAnnotation, while SUTime is part of the pipeline.","commonSituations":"Building Annotation from raw text without the docdate property; forgetting -docdate option in the pipeline; processing news or logs where relative dates matter; tests that omit document date setup.","solutions":["Set the document date before annotating: annotation.set(CoreAnnotations.DocDateAnnotation.class, \"2024-01-15\") or use the docdate pipeline property.","Provide a CalendarAnnotation as an alternative reference date.","Set quiet=true only if you intentionally want no date and accept unresolved relative times.","Preprocess text to include a dateline or extract the document date from metadata and inject it."],"exampleFix":"// before\nAnnotation ann = new Annotation(text);\npipeline.annotate(ann);\n// after\nAnnotation ann = new Annotation(text);\nann.set(CoreAnnotations.DocDateAnnotation.class, \"2024-01-15\");\npipeline.annotate(ann);","handlingStrategy":"validation","validationCode":"if (annotation.get(CoreAnnotations.DocDateAnnotation.class) == null && annotation.get(CoreAnnotations.CalendarAnnotation.class) == null) {\n  throw new IllegalArgumentException(\"Set DocDateAnnotation (e.g. yyyy-MM-dd) before running SUTime\");\n}","typeGuard":"String docDate = annotation.get(CoreAnnotations.DocDateAnnotation.class);\nif (docDate == null) { Calendar cal = annotation.get(CoreAnnotations.CalendarAnnotation.class); if (cal == null) { /* no anchor: relative times unreliable */ } }","tryCatchPattern":null,"preventionTips":["Always set the docdate pipeline property or DocDateAnnotation for SUTime pipelines","Extract document dates from metadata/datelines during preprocessing","Use quiet=false in development so missing dates surface early","Write a smoke test asserting DocDateAnnotation is present before time annotation"],"tags":["nlp","sutime","time","missing-metadata"],"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"}