fix(llm): RAG citation pages, scrub placeholders, disease-aware document choice
CI / ruff · pytest (pull_request) Successful in 1m2s

- converter marks a paragraph glued across a page break with ⟦стр. N⟧; the chunker
  strips the marker and extends the chunk's page range (wrong-page citations 24 -> 3,
  the rest are scale-form table rows split by a page)
- [NAME]/[PHONE] placeholders from privacy.scrub() no longer count as unknown words
  (a scrubbed question used to fall below the coverage gate)
- a question naming one disease boosts its guideline in retrieval and passage choice
  ("ТМС при депрессии" was answered from the PTSD guideline); "антидепрессант" is not a cue

Refs #62

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-04 04:31:59 +03:00
co-authored by Claude Opus 5.5
parent 6c212d560c
commit fe29ebd629
8 changed files with 206 additions and 91 deletions
+5 -3
View File
@@ -9,7 +9,8 @@
- таблицы -> markdown; у таблицы-продолжения на новой странице повторяется шапка,
строка, разорванная границей страницы, склеивается;
- колонтитулы (повторяющиеся строки вверху/внизу страниц) вырезаются;
- маркеры страниц `--- стр. N ---` для ссылок на источник;
- маркеры страниц `--- стр. N ---` для ссылок на источник; абзац, перетёкший на новую
страницу, склеивается, а место перехода помечается `⟦стр. N⟧`;
- текст с картинок (блок-схемы и т.п.) берётся из figures/<имя pdf>.p<N>.txt
(ручная транскрипция) и вставляется в конец своей страницы;
- если есть manual/<имя pdf>.txt, берётся он (документы, которые автоматом
@@ -211,9 +212,10 @@ def convert(pdf_path: Path) -> str:
if not text:
continue
if first_on_page and prev and prev[0] == "text" and text[0].islower():
# абзац перетёк на новую страницу: дописываем его хвост к началу
# абзац перетёк на новую страницу: дописываем его хвост к началу, а место
# перехода помечаем ⟦стр. N⟧ — чанкер по метке ставит верную страницу в цитату
head, _, rest = text.partition("\n")
prev[1] = prev[1] + " " + head
prev[1] = prev[1] + f" ⟦стр. {num}⟧ " + head
if rest:
blocks.append(["text", rest])
else: