Spell place slugs and names without accent stumps and capitalised small words

Gaspésie came out as gasp-sie, Lion's Head as lion-s-head and Forks of The Credit kept a
capital T.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Sonnet 5.5 committed 2026-11-20 10:52:10 -07:00
1 parent 44fbb0405b
commit 2fbce06f42
2 files changed
+15 -1

No files matched your search

+4 -1
View File
@@ -178,7 +178,10 @@ class Source:
def slugify(name):
import unicodedata
s = re.sub(r"\([^)]*\)", "", name.lower())
s = unicodedata.normalize("NFKD", s).encode("ascii", "ignore").decode("ascii")
s = re.sub(r"['\u2019]", "", s)
s = re.sub(r"[^a-z0-9]+", "-", s).strip("-")
return re.sub(r"-+", "-", s)
@@ -296,7 +299,7 @@ def _clean_cpcad_name(name):
name = re.sub(r"\s+Of Canada$", "", name, flags=re.I)
if name.isupper():
name = name.title()
name = re.sub(r"\s(And|Of|The|Du|De)\s", lambda m: m.group(0).lower(), name)
name = re.sub(r"(?<=\s)(And|Of|The|Du|De)(?=\s)", lambda m: m.group(0).lower(), name)
return name.strip()