INNER CODE UNIT · Python
_parse_explicit_tag_lines
LiuMengxuan04/shushu-internship-tool · skills/shushu-internship-tool/scripts/shushu_internship_tool/candidate_score.py:185
def _parse_explicit_tag_lines(text: str) -> tuple[set[str], set[str]]:
prefer: set[str] = set()
avoid: set[str] = set()
consumed_patterns = [*EXPLICIT_PREFER_KEYS, *EXPLICIT_AVOID_KEYS]
line_pattern = re.compile(
rf"(?im)^\s*({'|'.join(re.escape(key) for key in consumed_patterns)})\s*[:=]\s*(.+)$"
)
for match in line_pattern.finditer(text):
key = match.group(1).lower()
raw_values = match.group(2).strip().strip("[]{}()")
values = normalize_list(raw_values.replace('"', "").replace("'", ""))
if key in EXPLICIT_AVOID_KEYS:
avoid.update(canonicalize_tags(values))
else:
prefer.update(canonicalize_tags(values))
return prefer, avoid