INNER CODE UNIT · Python
_tag_slug
LiuMengxuan04/shushu-internship-tool · skills/shushu-internship-tool/scripts/shushu_internship_tool/candidate_score.py:153
def _tag_slug(value: Any) -> str:
text = str(value or "").strip().lower()
text = text.replace("_", "-").replace("+", "-")
text = re.sub(r"[\s/]+", "-", text)
text = re.sub(r"[^a-z0-9.#\-一-鿿]+", "", text)
text = re.sub(r"-+", "-", text).strip("-")
return text
def canonicalize_tags(values: Any) -> set[str]:
return {tag for value in normalize_list(values) if (tag := _tag_slug(value))}
def _collect_taste_tags(data: dict[str, Any], keys: tuple[str, ...]) -> set[str]:
tags: set[str] = set()
for key in keys:
tags.update(canonicalize_tags(data.get(key)))
return tags