Answer prose round 1 and product-owner round 1: CheckIdentifier's doc counts a bound name, FuncCall and the grammar doc say PathRead and identifiers, the Layout's list.go, name.go and data-import rows read on one pass, the locality row says a postort with no street is dropped, geo.py's docs name what they take, well_cased says what it drops, and item 61 names the next steps to share

This commit is contained in:
2026-10-07 02:21:37 +02:00
committed by Lillem4n
parent 2431edeab0
commit c2147d2282
8 changed files with 24 additions and 22 deletions
+3 -1
View File
@@ -137,6 +137,8 @@ def population_of(name, municipality, tatorter, municipalities, population):
def well_cased(name):
"""Whether each word of name is capitalised: GeoNames also spells some postorter, such as STOCKHOLM and örebro, in
capitals or lower case."""
return all(part[:1].isupper() and (len(part) == 1 or not part.isupper()) for part in re.split(r"[ -]", name))
@@ -155,7 +157,7 @@ def localities(codes, tatorter, municipalities, population):
continue
lat, lon = point
out[name] = {"name": name, "municipality": municipality, "population": population_of(name, municipality, tatorter, municipalities, population), "lat": f"{lat:.4f}", "lon": f"{lon:.4f}", "codes": kept}
print(f"municipality by {dict(how)}; {len(by_locality) - len(out)} postorter dropped", file=sys.stderr)
print(f"municipality by {dict(how)}; {len(by_locality) - len(out)} postorter dropped before streets", file=sys.stderr)
return out
+5 -4
View File
@@ -10,7 +10,8 @@ CACHE = Path(__file__).resolve().parent / "cache"
def parser(doc, country, **own):
"""The options every country's import takes and the script's own, keyed by name with "_" for "-", in name order."""
"""A parser for the options every country's import takes, plus the script's own: each keyword names one option, with
"_" standing for "-"."""
options = {"cache": {"default": str(CACHE)}, "out": {"default": str(DATA / country)}, "streets_per_locality": {"type": int, "default": 10}, **own}
p = argparse.ArgumentParser(description=doc.splitlines()[0])
for name in sorted(options):
@@ -63,8 +64,8 @@ class Nearest:
def top_streets(count, per_locality, column):
"""Per locality, the per_locality street names counted most in count, keyed (locality, name), ties by name; each
row holds its count in column."""
"""count maps (locality, street name) to a count. Per locality, the per_locality names counted most, ties broken by
name, each row holding its count under column."""
of = collections.defaultdict(list)
for (locality, name), n in count.items():
of[locality].append((n, name))
@@ -72,7 +73,7 @@ def top_streets(count, per_locality, column):
def with_streets(places, named):
"""The places named holds streets for; each other one is logged as dropped."""
"""The places that named holds streets for; logs each other place as dropped."""
for key, place in places.items():
if key not in named:
label = key if key == place["name"] else f"{key} {place['name']}"