fix(normalizer): treat leading date qualifiers (nach/vor/…) as APPROX

_preprocess now sets approx=True when a leading marker is stripped; add
_match_year_only so bare years (e.g. "nach 1900" -> "1900") resolve to
1900-01-01/YEAR before being upgraded to APPROX. Strengthen
test_parse_approx_marker_upgrades_precision and add
test_parse_leading_qualifier_is_approx (11 tests, all pass).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-05-25 13:35:19 +02:00
parent df14e6b1ee
commit cff486dda7
2 changed files with 21 additions and 5 deletions

View File

@@ -56,5 +56,10 @@ def test_parse_numeric_unparseable():
def test_parse_approx_marker_upgrades_precision():
r = dates.parse_date("17.Nov (?) 1887") # month-name handled in a later task; here just the marker path
# after the marker is detected, a parsed date becomes APPROX (verified fully in Task 8)
assert r.raw == "17.Nov (?) 1887"
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"
assert r.precision == Precision.APPROX