stanfordnlp/CoreNLP · warning

DocDate regex failed to match against

Error message

DocDate regex failed to match against ${docID}

What it means

In regex mode, DocDateAnnotator applies a configured pattern to the document ID and expects to capture the date as group(1). When the pattern does not match the docID, it logs this warning and sets the doc date to the empty string, so temporal expressions will not be grounded to a document date.

Solutions

  1. Print/log the actual docID values and adjust docdate.pattern to match the real naming convention.
  2. Ensure the DocIDAnnotator (or equivalent) sets the document ID before DocDateAnnotator runs, otherwise the regex matches an empty string.
  3. Broaden the regex (e.g., allow both hyphenated and non-hyphenated dates, optional extensions) — the annotator already normalizes 8-digit dates via addHyphensToDate.
  4. Fall back to docdate.fixedDate or a mapping file if regex extraction is unreliable for the corpus.

Example fix

// before: pattern expects YYYYMMDD but filenames use YYYY-MM-DD
props.setProperty("docdate.regex.pattern", ".*?(\\d{8})\\.xml");

// after
props.setProperty("docdate.regex.pattern", ".*?(\\d{4}-\\d{2}-\\d{2}|\\d{8})(?:\\.xml)?$");
Defensive patterns

Strategy: fallback

Validate before calling

// Test the docdate regex against your actual doc IDs before running the pipeline
Pattern p = Pattern.compile(props.getProperty("docdate.regex.pattern"));
for (String docId : docIds) {
  if (!p.matcher(docId).matches()) log.warn("docdate pattern fails for: " + docId);
}

Prevention

When it happens

Trigger: annotate() runs with useRegex enabled and the docID (possibly empty when no DocIDAnnotator ran) does not match docdate.pattern, e.g., a pattern like '.*_(\d{8})\.xml' against IDs without a date suffix.

Common situations: Pattern written for a different filename convention than the actual doc IDs; doc IDs missing entirely because the docid annotation key was never set; date formats in filenames differing (e.g., 20130514 vs 2013-05-14, or two-digit years).

Related errors


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

Appendix: source

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

      docID = "";
    String foundDocDate;
    if (useMappingFile) {
      foundDocDate = docIDToDocDate.get(docID);
      if (foundDocDate == null) {
        log.warn("DocDate mapping file failed to match against " + docID);
        foundDocDate = "";
      }
    } else if (useFixedDate || usePresentDate) {
      foundDocDate = fixedDate;
    } else if (useRegex) {
      Matcher m = fileDocDatePattern.matcher(docID);
      if (m.matches()) {
        foundDocDate = m.group(1);
        if (foundDocDate.length() == 8 && DATE_NO_HYPHENS_PATTERN.matcher(foundDocDate).matches()) {
          foundDocDate = addHyphensToDate(foundDocDate);
        }
      } else {
        log.warn("DocDate regex failed to match against " + docID);
        foundDocDate = "";
      }
    } else {
      foundDocDate = "";
    }
    // check date has proper format
    Matcher properDateFormat = DATE_PROPER_FORMAT.matcher(foundDocDate);
    if (properDateFormat.matches()) {
      annotation.set(CoreAnnotations.DocDateAnnotation.class, foundDocDate);
    }
  }

  /** helper for return current date **/
  public String currentDate() {
    return new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime());
  }

  /** helper to add hyphens **/

View on GitHub (pinned to 1b7edd19c4)