From b43dd6cdd46d9d5bc7e8aefd8e59cc4eaaf3fac5 Mon Sep 17 00:00:00 2001 From: Marcel Date: Mon, 25 May 2026 13:36:48 +0200 Subject: [PATCH] =?UTF-8?q?fix(normalizer):=20keep=20Task=205=20scoped=20?= =?UTF-8?q?=E2=80=94=20drop=20year-only=20matcher=20(belongs=20to=20Task?= =?UTF-8?q?=208)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.7 --- tools/import-normalizer/dates.py | 11 +---------- tools/import-normalizer/tests/test_dates.py | 4 ++-- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/tools/import-normalizer/dates.py b/tools/import-normalizer/dates.py index 65449a52..0dc9aff4 100644 --- a/tools/import-normalizer/dates.py +++ b/tools/import-normalizer/dates.py @@ -116,17 +116,8 @@ def _match_numeric(s): return None -_YEAR_ONLY_RE = re.compile(r"\d{4}") - - -def _match_year_only(s): - if _YEAR_ONLY_RE.fullmatch(s): - return datetime.date(int(s), 1, 1).isoformat(), Precision.YEAR - return None - - # Matchers are tried in order. Later tasks append to this list. -_MATCHERS = [_match_iso, _match_numeric, _match_year_only] +_MATCHERS = [_match_iso, _match_numeric] def parse_date(raw: str, date_overrides: dict | None = None) -> ParsedDate: diff --git a/tools/import-normalizer/tests/test_dates.py b/tools/import-normalizer/tests/test_dates.py index 5a2a6f5b..8f6af99f 100644 --- a/tools/import-normalizer/tests/test_dates.py +++ b/tools/import-normalizer/tests/test_dates.py @@ -60,6 +60,6 @@ def test_parse_approx_marker_upgrades_precision(): assert r.precision == Precision.UNKNOWN # no month-name matcher until Task 7; full APPROX check in Task 8 def test_parse_leading_qualifier_is_approx(): - r = dates.parse_date("nach 1900") # "after 1900" -> year salvaged, but precision is APPROX not exact - assert r.iso == "1900-01-01" + r = dates.parse_date("nach 1.5.1900") # qualifier stripped, numeric date salvaged, precision APPROX + assert r.iso == "1900-05-01" assert r.precision == Precision.APPROX