TRIEM_AI / src /normalizer.py
rzvn1's picture
Configure Docker environment for Hugging Face Spaces deployment
b5b3b28
Raw
History Blame Contribute Delete
550 Bytes
import string
import re
def normalize_text(text):
if not text:
return ""
# Lowercase conversion
text = text.lower()
# Remove punctuation
text = text.translate(str.maketrans('', '', string.punctuation))
# Remove filler phrases
fillers = ["how can i", "please tell", "can you", "tell me"]
for filler in fillers:
text = text.replace(filler, "")
# Remove extra whitespace
text = re.sub(r'\s+', ' ', text)
# Strip whitespace
text = text.strip()
return text