stanfordnlp/CoreNLP · warning
No document date specified
Error message
No document date specified
What it means
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.
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.
Example fix
// before Annotation ann = new Annotation(text); pipeline.annotate(ann); // after Annotation ann = new Annotation(text); ann.set(CoreAnnotations.DocDateAnnotation.class, "2024-01-15"); pipeline.annotate(ann);
Defensive patterns
Strategy: validation
Validate before calling
if (annotation.get(CoreAnnotations.DocDateAnnotation.class) == null && annotation.get(CoreAnnotations.CalendarAnnotation.class) == null) {
throw new IllegalArgumentException("Set DocDateAnnotation (e.g. yyyy-MM-dd) before running SUTime");
} Type guard
String docDate = annotation.get(CoreAnnotations.DocDateAnnotation.class);
if (docDate == null) { Calendar cal = annotation.get(CoreAnnotations.CalendarAnnotation.class); if (cal == null) { /* no anchor: relative times unreliable */ } } Prevention
- 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
When it happens
Trigger: Running pipeline.annotate on an Annotation without setting CoreAnnotations.DocDateAnnotation and without a CalendarAnnotation, while SUTime is part of the pipeline.
Common situations: 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.
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
- WARNING: No document date specified
- Caught bad number:
- Could not parse date string
- Could not parse date string
- e
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/c3dddd99ee6eac61.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/time/TimeAnnotator.java:200
}
public TimeAnnotator(String name, Properties props) {
this(name, props, false);
}
public TimeAnnotator(String name, Properties props, boolean quiet) {
timexExtractor = new TimeExpressionExtractorImpl(name, props);
this.quiet = quiet;
}
@Override
public void annotate(Annotation annotation) {
SUTime.TimeIndex timeIndex = new SUTime.TimeIndex();
String docDate = annotation.get(CoreAnnotations.DocDateAnnotation.class);
if (docDate == null) {
Calendar cal = annotation.get(CoreAnnotations.CalendarAnnotation.class);
if (cal == null) {
if ( ! quiet) { log.warn("No document date specified"); }
} else {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd:hh:mm:ss");
docDate = dateFormat.format(cal.getTime());
}
}
List<CoreMap> allTimeExpressions; // initialized below = null;
List<CoreMap> sentences = annotation.get(CoreAnnotations.SentencesAnnotation.class);
if (sentences != null) {
allTimeExpressions = new ArrayList<>();
List<CoreMap> allNumerics = new ArrayList<>();
for (CoreMap sentence: sentences) {
// make sure that token character offsets align with the actual sentence text
// They may not align due to token normalizations, such as "(" to "-LRB-".
CoreMap alignedSentence = NumberSequenceClassifier.alignSentence(sentence);
// uncomment the next line for verbose dumping of tokens....
// log.info("SENTENCE: " + ((ArrayCoreMap) sentence).toShorterString());
List<CoreMap> timeExpressions =
timexExtractor.extractTimeExpressionCoreMaps(alignedSentence, docDate, timeIndex);View on GitHub (pinned to 1b7edd19c4)