Drop six places from the pages and the records, and widen the twin rule to ranges
The deny-list in tools/place_trails.py now names, with a reason beside each, the Longfellow Mountains, Finger Lakes, Gore Range, Mosquito Range, Great Western Divide and Russian Wilderness. They are removed from places.toml and from every record that named them, history entries included, so nothing is left to link to. A range that holds exactly the trails of a park and shares its name stem (Great Smoky Mountains and Great Smoky Mountains National Park, Olympic Mountains and Olympic National Park) now gets no page either, in the tool and in the builder, and is removed from records the same way. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3b745f706c
commit
75e5de5c16
31 files changed
+127
-316
No files matched your search
+22
-5
@@ -143,13 +143,29 @@ def _doubled(park_name, wild_name):
|
||||
return bool(_core(a)) and _core(a) == _core(b)
|
||||
|
||||
|
||||
_STEM_FILLER = {"national", "provincial", "park", "parks", "preserve", "wilderness", "area",
|
||||
"and", "the", "of", "mountains", "mountain", "range", "ranges"}
|
||||
|
||||
|
||||
def _stem(name):
|
||||
return {w for w in str(name).lower().replace("-", " ").split() if w not in _STEM_FILLER}
|
||||
|
||||
|
||||
def _same_stem(park_name, range_name):
|
||||
"""True when a park and a mountain range have the same name once the kind words are
|
||||
taken away: Olympic National Park and Olympic Mountains, Great Smoky Mountains National
|
||||
Park and Great Smoky Mountains. Grand Teton National Park and the Teton Range do not."""
|
||||
a, b = _stem(park_name), _stem(range_name)
|
||||
return bool(a) and a == b
|
||||
|
||||
|
||||
def collect(records, registry):
|
||||
"""(kind, slug) -> info for every place with a page: PAGE_MIN or more trails.
|
||||
|
||||
An info holds kind, slug, key ("<kind>/<slug>"), name, where, box, records, path
|
||||
and title_name. A wilderness area that holds exactly the trails of a national park
|
||||
of much the same name gets no page: one page for the one set, under the park. The
|
||||
registry normally already leaves such a wilderness out; the builder stays safe."""
|
||||
and title_name. A wilderness area or a mountain range that holds exactly the
|
||||
trails of a park of much the same name gets no page: one page for the one set, under
|
||||
the park. The registry normally already leaves such a place out; the builder stays safe."""
|
||||
mem = membership(records, registry)
|
||||
out = {}
|
||||
for (kind, slug), recs in mem.items():
|
||||
@@ -163,10 +179,11 @@ def collect(records, registry):
|
||||
out[(kind, slug)] = info
|
||||
parks = [i for i in out.values() if i["kind"] == "park"]
|
||||
for key, info in list(out.items()):
|
||||
if info["kind"] != "wilderness":
|
||||
if info["kind"] not in ("wilderness", "range"):
|
||||
continue
|
||||
ids = {r["id"] for r in info["records"]}
|
||||
if any({r["id"] for r in p["records"]} == ids and _doubled(p["name"], info["name"])
|
||||
same = _doubled if info["kind"] == "wilderness" else _same_stem
|
||||
if any({r["id"] for r in p["records"]} == ids and same(p["name"], info["name"])
|
||||
for p in parks):
|
||||
del out[key]
|
||||
return out
|
||||
|
||||
@@ -104,6 +104,26 @@ class CollectTest(unittest.TestCase):
|
||||
recs.append(rec(4, ("wilderness", "example", "track")))
|
||||
self.assertIn(("wilderness", "example"), places.collect(recs, reg))
|
||||
|
||||
def test_a_range_gets_no_page_when_a_park_of_the_same_stem_holds_the_same_trails(self):
|
||||
park = entry("park", "olympic-national-park", "Olympic National Park", where=("WA",))
|
||||
rng = entry("range", "olympic-mountains", "Olympic Mountains", where=("WA",))
|
||||
other = entry("range", "teton-range", "Teton Range", where=("WY",))
|
||||
gt = entry("park", "grand-teton-national-park", "Grand Teton National Park")
|
||||
reg = registry(park, rng, other, gt)
|
||||
recs = [rec(i, ("park", "olympic-national-park", "track"),
|
||||
("range", "olympic-mountains", "track"),
|
||||
("park", "grand-teton-national-park", "track"),
|
||||
("range", "teton-range", "track")) for i in (1, 2, 3)]
|
||||
got = places.collect(recs, reg)
|
||||
self.assertIn(("park", "olympic-national-park"), got)
|
||||
self.assertNotIn(("range", "olympic-mountains"), got)
|
||||
# Grand Teton and the Teton Range do not share a stem: both keep their pages
|
||||
self.assertIn(("park", "grand-teton-national-park"), got)
|
||||
self.assertIn(("range", "teton-range"), got)
|
||||
# a range with a different set of trails keeps its page
|
||||
recs.append(rec(4, ("range", "olympic-mountains", "track")))
|
||||
self.assertIn(("range", "olympic-mountains"), places.collect(recs, reg))
|
||||
|
||||
def test_records_are_a_to_z(self):
|
||||
reg = registry(WIND)
|
||||
recs = [rec(1, ("range", "wind-river-range", "track"), name="Zebra Trail"),
|
||||
|
||||
Reference in new issue
Block a user