feat(normalizer): roman-numeral month matcher

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-05-25 13:38:32 +02:00
parent b43dd6cdd4
commit 7edc002ebb
2 changed files with 25 additions and 1 deletions

View File

@@ -116,8 +116,26 @@ def _match_numeric(s):
return None
_ROMAN_RE = re.compile(r"(\d{1,2})\.\s*([IVXLC]+)\.?\s*(\d{2,4})", re.I)
def _match_roman(s):
m = _ROMAN_RE.fullmatch(s)
if not m:
return None
day = int(m.group(1))
month = config.ROMAN_MONTHS.get(m.group(2).lower())
year = expand_year(m.group(3))
if not month or year is None:
return None
try:
return datetime.date(year, month, day).isoformat(), Precision.DAY
except ValueError:
return None
# Matchers are tried in order. Later tasks append to this list.
_MATCHERS = [_match_iso, _match_numeric]
_MATCHERS = [_match_iso, _match_numeric, _match_roman]
def parse_date(raw: str, date_overrides: dict | None = None) -> ParsedDate: