fix(dictionary): strip Latin romanization debris from Russian translations and sanitize dictionary cache
This commit is contained in:
1 parent
e371cdd4e5
commit
52db766b23
7 files changed
+109
-27
No files matched your search
@@ -26,17 +26,10 @@ def clean_dict_translation(raw: str) -> str:
|
||||
"""Extracts first 1-2 clean Cyrillic meanings, stripping phonetic / Latin noise."""
|
||||
if not raw:
|
||||
return ""
|
||||
clean = re.sub(r'/[^/]*$', '', raw)
|
||||
parts = re.split(r'[,;]\s*', clean)
|
||||
cyrillic_parts = []
|
||||
for p in parts:
|
||||
p_clean = re.sub(r"[a-zA-Záéíóúýšžčñ']+", '', p).strip()
|
||||
p_clean = re.sub(r'\s+', ' ', p_clean).strip(' /\\,;-()[]')
|
||||
if p_clean and re.search(r'[\u0400-\u04FF]', p_clean) and p_clean not in cyrillic_parts:
|
||||
cyrillic_parts.append(p_clean)
|
||||
if len(cyrillic_parts) >= 2:
|
||||
break
|
||||
return ", ".join(cyrillic_parts) if cyrillic_parts else raw[:50].strip()
|
||||
from app.dictionary import clean_russian_translation
|
||||
cleaned = clean_russian_translation(raw)
|
||||
parts = [p.strip() for p in cleaned.split(",") if p.strip()]
|
||||
return ", ".join(parts[:2]) if parts else raw[:50].strip()
|
||||
|
||||
|
||||
def get_dictionary_hint(term: str) -> str:
|
||||
|
||||
Reference in new issue
Block a user