Link the obvious towns of the Unmapped list: 460 unlinked place texts down to 50

About 190 German towns (mostly 1KOMMA5°'s) and the German states, French,
Italian, Dutch, Asian and other towns, the ISO3 codes and German or French
country names boards write. Towns keep their marks through spelling groups.
The tests that used Paderborn, Jena and Überlingen as unknown towns use
Bopfingen, Lauchheim and Ellwangen instead. Left: names that are no place,
ambiguous ones (Halifax, Richmond, Victoria, Durham, Warwick) and bare codes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Opus 5.5 committed 2026-09-30 13:34:27 +02:00
1 parent 19401cfc7a
commit 3e3060ba50
6 files changed
+188 -85

No files matched your search

+10 -10
View File
@@ -83,7 +83,7 @@ def test_copenhagen_is_in_the_capital_region_in_denmark_in_europe() -> None:
("Copenhagen Office", ["Copenhagen"]),
("Malmö/Lund", ["Malmö", "Lund"]),
("Aalborg, Copenhagen, Kolding", ["Aalborg", "Copenhagen", "Kolding"]),
("Paderborn, Germany", ["Germany"]),
("Bopfingen, Germany", ["Germany"]),
("Skåne län, Sweden", ["Skåne"]),
("London, Ontario", ["Ontario"]),
("Bergen op Zoom, Netherlands", ["Netherlands"]),
@@ -117,7 +117,7 @@ def test_a_text_of_how_a_role_is_worked_is_no_place(text: str) -> None:
assert places.placeless(text)
@pytest.mark.parametrize("text", ["Oberkochen", "Remote, APAC", "Jena"])
@pytest.mark.parametrize("text", ["Oberkochen", "Remote, APAC", "Lauchheim"])
def test_a_text_with_a_name_is_a_place(text: str) -> None:
assert not places.placeless(text)
@@ -235,7 +235,7 @@ def uids(store: Store, *tokens: str) -> set[str]:
def several(store: Store) -> dict[str, str]:
lines = {"cph": "Copenhagen; London", "eu": "Berlin, Germany; Paris, France",
"malmo": "Malmö", "lund": "Lund, Skåne", "billund": "Billund",
"zeiss": "Oberkochen; Jena", "remote": "Remote (SE)", "ny": "New York, NY"}
"zeiss": "Oberkochen; Lauchheim", "remote": "Remote (SE)", "ny": "New York, NY"}
for key, line in lines.items():
upsert(store, posting(key, place=line))
return {key: posting(key).uid for key in lines}
@@ -312,10 +312,10 @@ def test_a_place_gate_matches_over_the_gazetteer(store: Store,
# ------------------------------------------------------------ unresolved texts
def test_unresolved_texts_are_listed_most_roles_first(store: Store) -> None:
for n, line in enumerate(("Oberkochen; Jena", "Oberkochen", "Remote", "Aalen; Berlin")):
for n, line in enumerate(("Oberkochen; Lauchheim", "Oberkochen", "Remote", "Aalen; Berlin")):
upsert(store, posting(str(n), place=line))
assert store.unresolved_places() == [("oberkochen", "Oberkochen", 2), ("aalen", "Aalen", 1),
("jena", "Jena", 1)]
("lauchheim", "Lauchheim", 1)]
assert store.unresolved_places(limit=1) == [("oberkochen", "Oberkochen", 2)]
@@ -344,12 +344,12 @@ def test_an_alias_links_what_it_names(store: Store) -> None:
def test_a_place_added_by_hand_is_resolved_and_found(store: Store) -> None:
upsert(store, posting("1", place="Oberkochen; Jena"))
upsert(store, posting("2", place="Paderborn, Germany"))
upsert(store, posting("1", place="Oberkochen; Lauchheim"))
upsert(store, posting("2", place="Bopfingen, Germany"))
oberkochen = store.add_place("Oberkochen", "city", "country:DE")
store.add_place("Paderborn", "city", "country:DE")
assert texts(store, posting("1").uid) == [(0, "Oberkochen", "Oberkochen"), (1, "Jena", "")]
assert texts(store, posting("2").uid) == [(0, "Paderborn, Germany", "Paderborn")]
store.add_place("Bopfingen", "city", "country:DE")
assert texts(store, posting("1").uid) == [(0, "Oberkochen", "Oberkochen"), (1, "Lauchheim", "")]
assert texts(store, posting("2").uid) == [(0, "Bopfingen, Germany", "Bopfingen")]
assert uids(store, "place:oberkochen") == {posting("1").uid}
assert store.gazetteer().country(oberkochen) == "DE"
with pytest.raises(ValueError):
+2 -1
View File
@@ -351,7 +351,8 @@ def test_null_columns_match_nothing_and_do_not_raise() -> None:
def test_every_region_has_names_and_towns() -> None:
germany = {"niedersachsen", "norddeutschland", "ostdeutschland", "suddeutschland"}
germany = {r.key for r in places._GERMANY}
assert {"niedersachsen", "bayern", "thuringen", "harz"} <= germany
assert set(REGIONS) == {"skane", "hovedstaden", "zealand", "oresund", "jutland",
"funen"} | germany
for key, region in REGIONS.items():
+7 -7
View File
@@ -275,12 +275,12 @@ def test_a_changed_table_maps_every_open_role_again_without_a_pull(store: Store)
def test_a_town_added_to_the_code_is_linked_at_the_next_prep(
store: Store, monkeypatch: pytest.MonkeyPatch) -> None:
store.upsert_role(item("1", places=[{"text": "Überlingen", "remote": None}]))
store.upsert_role(item("1", places=[{"text": "Ellwangen", "remote": None}]))
prep.run(store, tables=TABLES)
assert [p["text"] for p in store.unlinked_places()] == ["Überlingen"]
assert [p["text"] for p in store.unlinked_places()] == ["Ellwangen"]
assert row(store, "1")["country"] == ""
monkeypatch.setitem(models._CITIES, "uberlingen", "DE")
monkeypatch.setitem(models._CITIES, "ellwangen", "DE")
done = prep.run(store, tables=TABLES)
assert done.remapped
assert store.unlinked_places() == []
@@ -340,9 +340,9 @@ def test_app_prep_runs_and_lists_the_unmapped_words(
assert json.loads(capsys.readouterr().out)["read"] == 1
assert cli.main(["-c", str(path), "prep", "unmapped"]) == 0
assert capsys.readouterr().out.split() == ["seniority", "acme", "1", "grand", "poobah"]
Store(tmp_path / "roledesk.db").upsert_role(item("2", place="Überlingen"))
Store(tmp_path / "roledesk.db").upsert_role(item("2", place="Ellwangen"))
assert cli.main(["-c", str(path), "prep", "unlinked"]) == 0
assert capsys.readouterr().out.split() == ["1", "Überlingen", "-:1", "Acme"]
assert capsys.readouterr().out.split() == ["1", "Ellwangen", "-:1", "Acme"]
assert cli.main(["-c", str(path), "prep", "--remap"]) == 0
assert json.loads(capsys.readouterr().out)["remapped"] is True
@@ -371,11 +371,11 @@ def test_the_api_lists_the_unlinked_places(tmp_path: Path) -> None:
app = create_app(Config(server=ServerConfig(host="127.0.0.1", port=0),
database=tmp_path / "roledesk.db"))
app.state.store.upsert_role(item("1", place="Überlingen", country="DE"))
app.state.store.upsert_role(item("1", place="Ellwangen", country="DE"))
prep.run(app.state.store, tables=TABLES)
with TestClient(app) as client:
found = client.get("/api/prep/unlinked").json()
assert found == [{"fold": "uberlingen", "text": "Überlingen", "roles": 1,
assert found == [{"fold": "ellwangen", "text": "Ellwangen", "roles": 1,
"countries": [["DE", 1]], "companies": ["Acme"]}]
+1 -1
View File
@@ -60,7 +60,7 @@ def store(tmp_path: Path) -> Store:
("Wrocław", "PL"), # ł and đ do not decompose under NFKD
("Łódź, Poland", "PL"),
("Bogota, CO", "CO"), # a state code that is a country's too
("Paderborn, DE", ""), # ... is no US state without a US place
("Ellwangen, DE", ""), # ... is no US state without a US place
("Sliema, MT", ""),
("Casablanca, MA", "MA"),
("Cambridge, MA", "US"),