feat(normalizer): parse_date dispatch + iso/numeric matchers
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -36,3 +36,25 @@ def test_expand_year():
|
||||
assert dates.expand_year("99") == 1899
|
||||
assert dates.expand_year("65") is None # 58..72 ambiguous
|
||||
assert dates.expand_year("x") is None
|
||||
|
||||
def test_parse_iso_and_empty():
|
||||
assert dates.parse_date("1910-04-23") == dates.ParsedDate("1910-04-23", Precision.DAY, "1910-04-23")
|
||||
assert dates.parse_date("") == dates.ParsedDate(None, Precision.UNKNOWN, "")
|
||||
assert dates.parse_date("?") == dates.ParsedDate(None, Precision.UNKNOWN, "?")
|
||||
|
||||
def test_parse_numeric_forms():
|
||||
assert dates.parse_date("15.2.1888").iso == "1888-02-15"
|
||||
assert dates.parse_date("13.5.09").iso == "1909-05-13"
|
||||
assert dates.parse_date("17/6. 1916").iso == "1916-06-17"
|
||||
assert dates.parse_date("11.10.08").iso == "1908-10-11"
|
||||
assert dates.parse_date("30.1.889").iso == "1889-01-30"
|
||||
assert dates.parse_date("15.2.1888").precision == Precision.DAY
|
||||
|
||||
def test_parse_numeric_unparseable():
|
||||
assert dates.parse_date("8.9.").precision == Precision.UNKNOWN # no year
|
||||
assert dates.parse_date("13.5.65").precision == Precision.UNKNOWN # ambiguous 2-digit year
|
||||
|
||||
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"
|
||||
|
||||
Reference in New Issue
Block a user