"""Normalisation de texte partagée par l'import (accents, casse, découpage).""" import re import unicodedata _SKILL_SEPARATORS = re.compile(r"[;,/\n]+") _MULTI_UNDERSCORE = re.compile(r"_+") def normalize(value: str) -> str: """Minuscule, sans accents, espaces réduits.""" lowered = unicodedata.normalize("NFKD", (value or "").strip().lower()) stripped = "".join(c for c in lowered if not unicodedata.combining(c)) return " ".join(stripped.split()) def slug_code(value: str) -> str: """Code stable pour une compétence : MAJUSCULES, séparateurs en `_`.""" base = normalize(value).upper() chars = [c if c.isalnum() else "_" for c in base] return _MULTI_UNDERSCORE.sub("_", "".join(chars)).strip("_") def split_skills(value: str) -> list[str]: parts = (p.strip() for p in _SKILL_SEPARATORS.split(value or "")) return [p for p in parts if p]