fix(dictionary): strip Latin romanization debris from Russian translations and sanitize dictionary cache

This commit is contained in:
Antigravity committed 2026-10-06 23:08:54 +03:00
1 parent e371cdd4e5
commit 52db766b23
7 files changed
+109 -27

No files matched your search

+4 -9
View File
@@ -240,15 +240,10 @@ def clean_translation(trans: str) -> str:
"""Cleans up raw translation strings, removes slash phonetic residues and romanizations."""
if not trans:
return ""
t = re.sub(r"/[^/]+/?", "", trans)
parts = [p.strip() for p in re.split(r"[,;]\s*", t) if p.strip()]
clean_parts = []
for p in parts:
if re.search(r"[а-яА-ЯёЁ]", p):
clean_p = re.sub(r"[a-zA-ZáéíóúÁÉÍÓÚ]", "", p).strip()
if clean_p:
clean_parts.append(clean_p)
return ", ".join(clean_parts[:3]) if clean_parts else trans.split(",")[0].strip()
from app.dictionary import clean_russian_translation
cleaned = clean_russian_translation(trans)
parts = [p.strip() for p in cleaned.split(",") if p.strip()]
return ", ".join(parts[:3]) if parts else trans.split(",")[0].strip()
async def mine_book_questions(