from __future__ import annotations import re import unicodedata def norm_term(term: str) -> str: if not term: return "" text = unicodedata.normalize("NFKC", str(term)).casefold().strip() text = text.lstrip("*") text = text.replace("₂", "2").replace("₃", "3").replace("₁", "1").replace("₄", "4") text = text.replace("h₂", "h2").replace("h₃", "h3").replace("h₁", "h1").replace("h₄", "h4") text = re.sub(r"\s+", " ", text) return text