Mongoosetross's picture
Deploy Reverse Etymology Atlas
0e7a159 verified
Raw
History Blame Contribute Delete
487 Bytes
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