navi/backend/services/navi_places
malice ea495dd45e
navi-places: name-based wikivoyage article discovery (#30)
Places without an OSM wikivoyage tag (the entire current dataset -- 0 of placex
rows carry the tag, vs 32,862 wikipedia) never got a local Wikivoyage link even
when the article exists in the mirror by name. This implements the long-standing
discover_wikivoyage_article stub (a never-finished placeholder ported verbatim
from recon -- not disabled for any flaw) so a place name can resolve to a local
Kiwix article.

- wiki_rewrite.py: discover_wikivoyage_article(name, ...) normalizes the name to
  a MediaWiki title and runs it through the existing check_kiwix_has_article
  ('wikivoyage', ...) path -- same catalog discovery, HEAD probe, and positive
  cache as tag rewriting. Returns (kiwix_url, "local") on a HEAD 200, else
  (None, None). No public fallback: without an OSM tag we can't confirm a public
  Wikivoyage article exists, so a name miss yields no link rather than a guessed
  (possibly dead) public URL.
- place_detail._enrich_wiki_links: after the tag-rewrite loop, when extratags has
  no wikivoyage value, attempt name-based discovery on result["name"] and, on a
  local hit, set extratags["wikivoyage"] + sources.wiki_rewrites["wikivoyage"] =
  "local". Tag rewrite always wins when a tag is present (discovery only fills the
  gap). Gated by the existing has_wiki_rewriting flag (discovery lives inside that
  already-enabled, flag-gated function) -- no new flag / cross-repo profile edit;
  the docstring-only has_wiki_discovery flag was never defined in any profile.

Tests (test_place.py): finds-local (HEAD 200 -> local URL + source), 404 ->
no link / no source, and runs-only-when-tag-missing (tag present -> tag rewrite
wins, discovery not consulted). Full navi-places suite: 18 passed.

Co-authored-by: Matt <mj@k7zvx.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 09:55:48 -06:00
..
tests navi-places: name-based wikivoyage article discovery (#30) 2026-05-26 09:55:48 -06:00
__init__.py Add navi-places service (extraction #5) (#5) 2026-05-22 17:00:06 -06:00
admin.py decouple: read wiki_index.db directly in navi-places (drop /api/wiki-enrich HTTP) 2026-05-23 19:17:53 -06:00
app.py decouple: move /api/wiki-rewrite logic from recon to navi-places 2026-05-23 21:12:27 -06:00
config.py Add navi-places service (extraction #5) (#5) 2026-05-22 17:00:06 -06:00
google_places.py Add navi-places service (extraction #5) (#5) 2026-05-22 17:00:06 -06:00
osm_categories.py Add navi-places service (extraction #5) (#5) 2026-05-22 17:00:06 -06:00
overture.py Add navi-places service (extraction #5) (#5) 2026-05-22 17:00:06 -06:00
place_cache.py Add navi-places service (extraction #5) (#5) 2026-05-22 17:00:06 -06:00
place_detail.py navi-places: name-based wikivoyage article discovery (#30) 2026-05-26 09:55:48 -06:00
place_route.py Add navi-places service (extraction #5) (#5) 2026-05-22 17:00:06 -06:00
wiki_index.py decouple: read wiki_index.db directly in navi-places (drop /api/wiki-enrich HTTP) 2026-05-23 19:17:53 -06:00
wiki_rewrite.py navi-places: name-based wikivoyage article discovery (#30) 2026-05-26 09:55:48 -06:00