Connector calls, semantic rules, and DuckDB memory keep long runs stable, and stream retry stops chats from stalling. Co-authored-by: Cursor <cursoragent@cursor.com>
13 lines
438 B
Python
13 lines
438 B
Python
"""Shared normalization for Persian business text."""
|
||
|
||
from __future__ import annotations
|
||
|
||
_DIGITS = str.maketrans("۰۱۲۳۴۵۶۷۸۹٠١٢٣٤٥٦٧٨٩", "01234567890123456789")
|
||
|
||
|
||
def normalize_text(value: str) -> str:
|
||
text = value.replace("\u200c", "").replace("\u200d", "")
|
||
text = text.replace("ي", "ی").replace("ك", "ک").replace("ة", "ه")
|
||
text = text.translate(_DIGITS)
|
||
return " ".join(text.strip().split())
|