fix: prioritize media URL classification

This commit is contained in:
ik
2026-09-13 08:46:42 +07:00
parent 0b7df7f721
commit 3547598d37
6 changed files with 19 additions and 9 deletions
+4 -2
View File
@@ -41,12 +41,14 @@ def _kind(url: str, label: str | None, context: str) -> str:
value = f"{label or ''} {context}".casefold()
if "/flags/" in path or "/themes/" in path or path.endswith(("/logo.png", "/logo.svg")):
return "reference"
# A structural tackle path is stronger evidence than words in a product
# name (for example, bait named "Краб и рыба").
if re.search(r"(?:^|[/_-])(?:bait|lure|rig|rod|reel|hook|tackle|köder|rute|rolle)(?:[/_.-]|$)", path):
return "tackle"
if re.search(r"/(?:fish|fishes|fische|species)/", path) or re.search(r"/(?:fish|species)[_-]", path) or "/media/fische/" in value or any(word in value for word in ("рыба ", "fish: ", "fisch: ")):
return "fish"
if re.search(r"/(?:maps?|levels?|lakes?|waterbodies)/", path) or "/media/levels/" in value or any(word in value for word in ("карта ", "map of ", "gewässerkarte")):
return "waterbody"
if re.search(r"(?:^|[/_-])(?:bait|lure|rig|rod|reel|hook|tackle|köder|rute|rolle)(?:[/_.-]|$)", path):
return "tackle"
return "reference"