Skip to content

dates: keep OCR years and prefer overlapping month-first dates - #43

Open
charan-rathore wants to merge 1 commit into
awlevin:mainfrom
charan-rathore:fix/ocr-date-overlap
Open

charan-rathore wants to merge 1 commit into
awlevin:mainfrom
charan-rathore:fix/ocr-date-overlap

Conversation

@charan-rathore

Copy link
Copy Markdown
Contributor

Summary

Fixes #37. OCR can omit the space after a comma in Jun 18,2026, causing the parser to drop the year and roll a past event into next year. The date regex now accepts a comma with or without following whitespace.

A stray digit before Apr 30, 2026 can make 1 Apr the first match. When that day-first match has no year and an overlapping month-first date begins at its month, first_date uses the month-first match. Otherwise, it keeps the first date in the text.

Checks

  • uv run --no-sync ruff check .: passed.
  • uv run --no-sync ruff format --check .: passed.
  • uv run --no-sync pytest -q: 616 passed, 3 skipped, 1 xfailed on Linux.
  • Regression tests cover both OCR examples, unchanged range and day-first formats, ordinary multi-date text, and the resulting classifier date hints.

Caveat

No live OCR or classifier-provider replay was run. The date-hint test uses fake items from the test suite.

Instinct assisted.

@charan-rathore

Copy link
Copy Markdown
Contributor Author

This is green on CI and conflict-free on my end. Is there anything you'd like changed before it can land? Happy to adjust.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dates: year after a comma without a space is dropped; a stray digit before a month wins

1 participant