SEO: values filter — trim cities in anti-LGBTQ countries, keep notable hubs (#102)
Add EXCLUDE_CC + KEEP_SLUGS to gen_cities.py: drop cities in countries that criminalize LGBTQ+ people (plus China, Pakistan, Indonesia by choice), except a hand-kept list of notable / tourist / high-English hubs — Lagos & Abuja; Nairobi & Mombasa; Cairo, Giza, Alexandria; Dubai & Abu Dhabi; Kuala Lumpur/Malacca/Kota Kinabalu/Kuching; Dar es Salaam/Zanzibar/Arusha; Casablanca/Fes/Rabat; Tehran; Jeddah; Baghdad; Kabul; 7 Pakistani cities (Karachi, Lahore, Islamabad, Faisalabad, Rawalpindi, Multan, Hyderabad); Jakarta + Surabaya + Bekasi; and China's 5 most English-friendly cities (Shanghai, Beijing, Shenzhen, Guangzhou, Chengdu). Removed slots backfill from the next-ranked non-excluded cities, so cities.json stays 1000. Flavor regenerated (prunes removed, fetches backfilled).
This commit is contained in:
parent
273ecd0d60
commit
235c910417
3 changed files with 4796 additions and 4919 deletions
7162
cities.json
7162
cities.json
File diff suppressed because it is too large
Load diff
2510
cities_flavor.json
2510
cities_flavor.json
File diff suppressed because it is too large
Load diff
|
|
@ -48,12 +48,47 @@ ENGLISH_EXTENDED_CC = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def _to_city(e, seen_slugs: set[str]) -> dict | None:
|
# Values filter: exclude cities in countries that criminalize LGBTQ+ people (plus
|
||||||
name, admin1, country, cc = e[_NAME], e[_ADMIN1], e[_COUNTRY], e[_CC]
|
# Pakistan and Indonesia by request), EXCEPT the individually-kept notable/tourist/
|
||||||
|
# high-English hubs in KEEP_SLUGS. Editable — regenerate cities.json after changes.
|
||||||
|
EXCLUDE_CC = {
|
||||||
|
"NG", "KE", "GH", "UG", "TZ", "ZM", "ZW", "MW", "SL", "LR", "GM", "ET", "SN", "CM", "EG",
|
||||||
|
"SA", "AE", "QA", "KW", "OM", "YE", "IR", "IQ", "SY", "AF", "BD", "LK", "MY", "BN", "MM",
|
||||||
|
"JM", "GD", "DM", "LC", "VC", "KN", "GY", "DZ", "MA", "LY", "SD", "SS", "ER", "MR",
|
||||||
|
"PK", "ID", "CN",
|
||||||
|
}
|
||||||
|
KEEP_SLUGS = {
|
||||||
|
"lagos-ng", "abuja-fct-ng", "kuala-lumpur-my", "malacca-melaka-my",
|
||||||
|
"kota-kinabalu-sabah-my", "kuching-sarawak-my", "nairobi-nairobi-county-ke",
|
||||||
|
"mombasa-mombasa-county-ke", "dar-es-salaam-dar-es-salaam-region-tz",
|
||||||
|
"zanzibar-zanzibar-urban-west-tz", "arusha-tz", "cairo-eg", "giza-eg", "alexandria-eg",
|
||||||
|
"dubai-ae", "abu-dhabi-ae", "casablanca-casablanca-settat-ma", "rabat-rabat-sale-kenitra-ma",
|
||||||
|
"fes-fes-meknes-ma", "accra-greater-accra-gh", "kumasi-ashanti-gh", "dhaka-dhaka-division-bd",
|
||||||
|
"kampala-central-region-ug", "dakar-sn", "lusaka-lusaka-province-zm", "harare-zw",
|
||||||
|
"yangon-mm", "colombo-western-province-lk", "kingston-jm", "addis-ababa-et", "tehran-ir",
|
||||||
|
"jeddah-mecca-region-sa", "baghdad-iq", "kabul-af", "karachi-sindh-pk", "multan-punjab-pk",
|
||||||
|
"lahore-punjab-pk", "hyderabad-sindh-pk", "islamabad-pk", "faisalabad-punjab-pk",
|
||||||
|
"rawalpindi-punjab-pk", "jakarta-id", "surabaya-east-java-id", "bekasi-west-java-id",
|
||||||
|
# China — only the 5 most English-friendly cities (per a where-to-speak-English guide).
|
||||||
|
"shanghai-cn", "beijing-cn", "shenzhen-guangdong-cn", "guangzhou-guangdong-cn", "chengdu-sichuan-cn",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def _base_slug(e) -> str:
|
||||||
|
name, admin1 = e[_NAME], e[_ADMIN1]
|
||||||
# Drop admin1 from the slug when it just repeats the city name
|
# Drop admin1 from the slug when it just repeats the city name
|
||||||
# (e.g. Tokyo/Tokyo, Singapore/Singapore) to avoid "tokyo-tokyo-jp".
|
# (e.g. Tokyo/Tokyo, Singapore/Singapore) to avoid "tokyo-tokyo-jp".
|
||||||
admin_part = admin1 if admin1 and slugify(admin1) != slugify(name) else ""
|
admin_part = admin1 if admin1 and slugify(admin1) != slugify(name) else ""
|
||||||
base = slugify(name, admin_part, cc or "")
|
return slugify(name, admin_part, e[_CC] or "")
|
||||||
|
|
||||||
|
|
||||||
|
def _excluded(e) -> bool:
|
||||||
|
return e[_CC] in EXCLUDE_CC and _base_slug(e) not in KEEP_SLUGS
|
||||||
|
|
||||||
|
|
||||||
|
def _to_city(e, seen_slugs: set[str]) -> dict | None:
|
||||||
|
name, admin1, country, cc = e[_NAME], e[_ADMIN1], e[_COUNTRY], e[_CC]
|
||||||
|
base = _base_slug(e)
|
||||||
if not base:
|
if not base:
|
||||||
return None
|
return None
|
||||||
slug = base
|
slug = base
|
||||||
|
|
@ -92,6 +127,8 @@ def build(n_global: int = 500, n_english: int = 250, n_extended: int = 250) -> l
|
||||||
break
|
break
|
||||||
if not pred(e):
|
if not pred(e):
|
||||||
continue
|
continue
|
||||||
|
if _excluded(e): # values filter (keeps KEEP_SLUGS); backfills the rest
|
||||||
|
continue
|
||||||
ident = (e[_NAME], e[_ADMIN1], e[_CC])
|
ident = (e[_NAME], e[_ADMIN1], e[_CC])
|
||||||
if ident in chosen_ids:
|
if ident in chosen_ids:
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue