sms-classifier-api / app /utils.py
cmeneses99's picture
Refactor: reorganize into core/, api/, web/, templates/
84bb476
raw
history blame contribute delete
441 Bytes
import unicodedata
from pathlib import Path
_TEMPLATES = Path(__file__).parent / "templates"
def normalize(text: str) -> str:
"""Lowercase and strip accents for cache-key normalization."""
text = text.lower()
text = unicodedata.normalize("NFD", text)
return "".join(c for c in text if unicodedata.category(c) != "Mn")
def read_static(filename: str) -> str:
return (_TEMPLATES / filename).read_text(encoding="utf-8")