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
+4
-3
@@ -15,6 +15,7 @@ import sqlite3
|
||||
import random
|
||||
from typing import Dict, Any, List, Optional
|
||||
from datetime import datetime
|
||||
from app.dictionary import clean_russian_translation
|
||||
|
||||
CEFR_LEVELS = ["A1", "A2", "B1", "B2"]
|
||||
|
||||
@@ -2190,7 +2191,7 @@ def process_cefr_answer(
|
||||
"SELECT term, translation, phonetic, pos FROM offline_dictionary WHERE term = ? COLLATE NOCASE",
|
||||
(selected_clean,),
|
||||
).fetchone()
|
||||
sel_trans = sel_row["translation"] if sel_row else selected_clean
|
||||
sel_trans = clean_russian_translation(sel_row["translation"]) if sel_row else selected_clean
|
||||
sel_phon = sel_row["phonetic"] if sel_row else ""
|
||||
sel_pos = sel_row["pos"] if sel_row else ""
|
||||
sel_ctx = resolve_context_sentence_for_term(conn, selected_clean)
|
||||
@@ -2244,7 +2245,7 @@ def process_cefr_answer(
|
||||
"SELECT term, translation, phonetic, pos FROM offline_dictionary WHERE term = ? COLLATE NOCASE",
|
||||
(opt_clean,),
|
||||
).fetchone()
|
||||
opt_trans = opt_row["translation"] if opt_row else opt_clean
|
||||
opt_trans = clean_russian_translation(opt_row["translation"]) if opt_row else opt_clean
|
||||
opt_phon = opt_row["phonetic"] if opt_row else ""
|
||||
opt_pos = opt_row["pos"] if opt_row else ""
|
||||
|
||||
@@ -2413,7 +2414,7 @@ def ingest_cefr_word(
|
||||
"SELECT term, translation, phonetic, pos FROM offline_dictionary WHERE term = ? COLLATE NOCASE",
|
||||
(clean_term,),
|
||||
).fetchone()
|
||||
trans = row["translation"] if row else clean_term
|
||||
trans = clean_russian_translation(row["translation"]) if row else clean_term
|
||||
phon = row["phonetic"] if row else ""
|
||||
pos = row["pos"] if row else ""
|
||||
|
||||
|
||||
Reference in new issue
Block a user