INNER CODE UNIT · Python
taste_score
LiuMengxuan04/shushu-internship-tool · skills/shushu-internship-tool/scripts/shushu_internship_tool/candidate_score.py:235
def taste_score(candidate: dict[str, Any], taste_text: str | None) -> tuple[int, list[str], list[str], list[str]]:
prefer_tags, user_avoid_tags = parse_user_taste(taste_text)
if not (prefer_tags or user_avoid_tags):
return 0, [], [], []
positive_tags = canonicalize_tags([
*normalize_list(candidate.get("taste_tags")),
*normalize_list(candidate.get("tags")),
])
project_avoid_tags = canonicalize_tags([
*normalize_list(candidate.get("avoid_tags")),
*positive_tags,
])
matches = _ordered_intersection(sorted(positive_tags - user_avoid_tags), prefer_tags)
mismatches = _ordered_intersection(sorted(project_avoid_tags), user_avoid_tags)
points = min(USER_PREFERENCE_MAX_SCORE, len(matches) * 2) - min(4, len(mismatches) * 2)