comments: implement extract-ocr — 2,393 comments have image-only attachments invisible to all text exhibits #663

Closed
opened 2026-08-19 18:12:31 +00:00 by kert · 2 comments
Owner

stack comments extract-ocr has been a phase-2 stub since #253. As of 2026-08-19, 2,393 comments across the ten PFS dockets have ocr_needed attachments (image-only PDFs and JPG/PNG scans) whose text is invisible to every downstream consumer — the RAG index, the palliative sweep (#660), and any docket exhibit. The count will grow as #662's backfill pulls the remaining ~160k comment details.

The GPU fleet (P45, #653-#655: rack 3060 + laptop 5070 Ti + rig 4090) is live and the distributed-GPU OCR notes are already in the spec (76c7288 phase-2 marker). Implement the OCR pass (tesseract or a vision model on the fleet), update each comment's combined.md in place (attachment status ocr_needed → ok), and re-attach the "Comment text" bib note.

`stack comments extract-ocr` has been a phase-2 stub since #253. As of 2026-08-19, **2,393 comments across the ten PFS dockets have `ocr_needed` attachments** (image-only PDFs and JPG/PNG scans) whose text is invisible to every downstream consumer — the RAG index, the palliative sweep (#660), and any docket exhibit. The count will grow as #662's backfill pulls the remaining ~160k comment details. The GPU fleet (P45, #653-#655: rack 3060 + laptop 5070 Ti + rig 4090) is live and the distributed-GPU OCR notes are already in the spec (76c7288 phase-2 marker). Implement the OCR pass (tesseract or a vision model on the fleet), update each comment's `combined.md` in place (attachment status `ocr_needed` → `ok`), and re-attach the "Comment text" bib note.
kert added the bib label 2026-08-19 18:12:31 +00:00
Author
Owner

Implemented (2026-08-20): stack comments extract-ocr [--docket] [--limit] — RapidOCR (onnxruntime, pip-only, no system packages: uv run --with rapidocr-onnxruntime), PDFs rasterized per page through PyMuPDF at 200 dpi (no poppler), images OCR'd directly. Hooked into extract_attachment(ocr_engine=...) so a re-extract with the engine rewrites combined.md + sibling transcripts and clears the ocr_needed flag only when OCR clears the threshold. TDD'd (tests/rex/comments/test_extract_ocr.py); smoke: 3 scanned letters → 5-10k chars each. Full run over the 2,738-dir backlog launched (niced, .state/comments/ocr.log), chained with an idempotent palliative re-sweep so #660's exhibit picks up newly readable text. Leaving open until the run completes; note the bib 'Comment text' notes are not yet refreshed for OCR'd dirs (attach is skip-if-exists) — follow-up if Zotero-side transcripts matter.

Implemented (2026-08-20): `stack comments extract-ocr [--docket] [--limit]` — RapidOCR (onnxruntime, pip-only, no system packages: `uv run --with rapidocr-onnxruntime`), PDFs rasterized per page through PyMuPDF at 200 dpi (no poppler), images OCR'd directly. Hooked into `extract_attachment(ocr_engine=...)` so a re-extract with the engine rewrites combined.md + sibling transcripts and clears the `ocr_needed` flag only when OCR clears the threshold. TDD'd (tests/rex/comments/test_extract_ocr.py); smoke: 3 scanned letters → 5-10k chars each. Full run over the 2,738-dir backlog launched (niced, `.state/comments/ocr.log`), chained with an idempotent palliative re-sweep so #660's exhibit picks up newly readable text. Leaving open until the run completes; note the bib 'Comment text' notes are not yet refreshed for OCR'd dirs (attach is skip-if-exists) — follow-up if Zotero-side transcripts matter.
Author
Owner

Run complete (2026-08-20 18:38 ET): all 2,738 queued comment dirs re-extracted with OCR, 0 errors (~6.5 hrs CPU, niced). The chained palliative re-sweep found +1 new hit (topic:palliative 417 → 418) — the scanned-attachment population was largely not palliative-relevant, a useful negative result now disclosed by the live notebook exhibit. Remaining known gap: bib 'Comment text' notes are not refreshed for OCR'd dirs (attach is skip-if-exists) — cosmetic for Zotero browsing, not for any exhibit, so closing.

Run complete (2026-08-20 18:38 ET): **all 2,738 queued comment dirs re-extracted with OCR, 0 errors** (~6.5 hrs CPU, niced). The chained palliative re-sweep found **+1 new hit** (topic:palliative 417 → 418) — the scanned-attachment population was largely not palliative-relevant, a useful negative result now disclosed by the live notebook exhibit. Remaining known gap: bib 'Comment text' notes are not refreshed for OCR'd dirs (attach is skip-if-exists) — cosmetic for Zotero browsing, not for any exhibit, so closing.
kert closed this issue 2026-08-21 13:45:22 +00:00
Sign in to join this conversation.