File size: 196 Bytes
b227dc8
 
 
 
 
 
 
1
2
3
4
5
6
7
8
import re

def normalize_text(text):
    text = text.lower()
    text = re.sub(r"\b\d+\b", "<n>", text)
    text = re.sub(r"[^a-z0-9<> ]+", " ", text)
    return re.sub(r"\s+", " ", text).strip()