🐍 python normalizer

python

fukurou

the supreme coder
ADMIN
Python:
import re

_LEET = str.maketrans("013457@$", "oieastas")

def normalize(text: str) -> str:
    text = text.lower().translate(_LEET)
    text = re.sub(r"[^a-z\s]", "", text)
    text = re.sub(r"(.)\1+", r"\1", text)  # baaaanana -> banana
    return re.sub(r"\s+", " ", text).strip()
 
Top