Skip to content

Commit dde69da

Browse files
bazilinskyyclaude
andcommitted
Locating: a region named like its town is that town when the title names nothing else
"FIER ALBANIA, SHETITJE ..." (ykSui8EUJ8Q) gave no locality: Fier is also a county, and a region alone was dropped. With exactly one region named, its country named too, and no other phrase finding a town, a city or town of exactly the region's name is taken. Kingston,New York (Kingston is also a Jamaican parish) and "ARTA news" stay unlocated. Of 300 random reviewed titles naming a region and a country, 43 gain a town, none wrong (Addis Ababa, Berlin, Namur, Strășeni, Como, Annaba, Hamburg). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 25b0a5e commit dde69da

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

‎propose_segments.py‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7074,6 +7074,7 @@ def usable(hit):
70747074
or named and common.get_iso2_country_code(common.correct_country(p)) not in codes]
70757075
# a state only qualifies the town named with it ("Palmerton, Pennsylvania"): as a place of its own it would
70767076
# be the anchor, or match some "Pennsylvania" road in another town; the town is looked up in it
7077+
regions = [p for p in phrases if _name_key(p) in states]
70777078
phrases = [p for p in phrases if _name_key(p) not in states] # a state alone is no locality
70787079
written = {}
70797080
if len(named) == 1 and any(_name_key(p) not in states for p in phrases):
@@ -7120,6 +7121,7 @@ def usable(hit):
71207121
# the text names no other ("Дорога на Евпаторию, Саки" stays Saki: XJif0QNAF_Q)
71217122
spelt = [(p, loc) for p, h in hits if not h and (loc := _spelt_otherwise(p, df, countries, home, only))]
71227123
found = False
7124+
towns = [p for p, h in hits if h and h[0]] # (for the regions below)
71237125
hits = [(p, h) for p, h in hits if usable(h)]
71247126
if len(hits) > 1:
71257127
anchor = max(hits, key=lambda ph: ph[1][6])
@@ -7154,6 +7156,18 @@ def usable(hit):
71547156
yield loc, phrase
71557157
for phrase, loc in spelt if not found else ():
71567158
yield loc, phrase
7159+
# ... and with nothing else found, a region of the name of its seat is that town, a city or town of exactly the
7160+
# name: "FIER ALBANIA, SHETITJE ..." (ykSui8EUJ8Q; user, 2026-11-27) named only the county of Fier, Elbasan and
7161+
# Tirana were found as mapping towns; "Bran, Brasov" keeps Brasov as Bran's county; only one region, and no phrase
7162+
# that found a town giving no locality: "Driving by Kingston,New York" (CharruaNYC 4qZ4ysfD8Zg; Kingston is also
7163+
# a parish of Jamaica) is no New York City; and only in a country the text names: "ARTA news" is no Arta, Greece
7164+
for phrase in regions if len(regions) == 1 and only and not found and not spelt and not towns else ():
7165+
hit = _osm_place(phrase, codes, (home[3], home[4]) if home else None)
7166+
if (hit and hit[0] and _name_key(hit[0]) == _name_key(phrase) and hit[7] in ('city', 'town') and usable(hit)
7167+
and hit[2] in only
7168+
and (loc := _hit_locality(hit, df, countries, named=True))):
7169+
yield loc, phrase
7170+
break
71577171

71587172

71597173
REGION_KM = 150 # see place_localities

0 commit comments

Comments
 (0)