From 35ca06dd6b882719e2a5e05565d8e9e9f83ce55b Mon Sep 17 00:00:00 2001 From: Viktor Antropov Date: Mon, 2 Nov 2026 17:33:09 +0300 Subject: [PATCH] Word list export includes LT top replacement - helps separate typos from abbreviations --- app.py | 9 ++++++++- static/index.html | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index 2546289..6837df7 100644 --- a/app.py +++ b/app.py @@ -422,11 +422,18 @@ def run_job(job_id: str, data: bytes, filename: str, use_llm: bool): for it in items: counts[it["kind"]] = counts.get(it["kind"], 0) + 1 frag_counts = Counter() + frag_first_repl: dict = {} for it in items: frag = (it.get("fragment") or "").strip().lower() if frag: frag_counts[frag] += 1 - fragments_top = [{"fragment": k, "count": v} for k, v in frag_counts.most_common(100)] + if frag not in frag_first_repl: + repls = it.get("replacements") or [] + frag_first_repl[frag] = repls[0] if repls else "" + fragments_top = [ + {"fragment": k, "count": v, "top_replacement": frag_first_repl.get(k, "")} + for k, v in frag_counts.most_common(100) + ] page_acc = 0 page_map = [] for p in paras: diff --git a/static/index.html b/static/index.html index 373607e..d78950a 100644 --- a/static/index.html +++ b/static/index.html @@ -182,9 +182,9 @@ function render(r) { document.querySelectorAll(".repl").forEach(b => b.onclick = () => { navigator.clipboard.writeText(b.dataset.t); b.title = "скопировано"; }); const dl = $("dlw"); if (dl) dl.onclick = () => { window.location = "/api/report/" + jobId + "/docx"; }; const dl2 = $("dlw2"); if (dl2) dl2.onclick = () => { - const top = (lastReport.fragments_top || []).map(x => x.count + " " + x.fragment).join("\r\n"); + const top = (lastReport.fragments_top || []).map(x => x.count + " " + x.fragment + (x.top_replacement ? " -> " + x.top_replacement.replace(/\s+/g, " ") : "")).join("\r\n"); const a = document.createElement("a"); - a.href = URL.createObjectURL(new Blob(["сколько фрагмент\r\n" + top], {type: "text/plain;charset=utf-8"})); + a.href = URL.createObjectURL(new Blob(["сколько фрагмент -> подсказка\r\n" + top], {type: "text/plain;charset=utf-8"})); a.download = "spisok_slov.txt"; a.click(); };