mirror of
https://github.com/lllin000/PaperForge.git
synced 2026-07-22 06:50:53 +00:00
When PaddleOCR fails to detect a standalone 'Figure N' / 'FIGURE N' heading (rendered in a bold/small-caps font that the OCR engine doesn't read), the caption body is captured as figure_caption_candidate but lacks the figure number prefix. The new _recover_figure_heading_prefix() function checks the PDF text layer (via existing page_pdf_lines_by_page infrastructure — no extra PDF open) and prepends the heading. Key logic: - Scans PDF text lines on the same page for 'Figure N' headings - Confirms by checking if the NEXT PDF line (by y-order) shares ≥15 chars of common prefix with the OCR caption candidate text - Only runs when _extract_figure_number() returns None (no figure number in existing caption text) - Integrated into build_figure_inventory() before _is_formal_legend() check, so recovered captions enter the legend matching pool Fixes 'FIGURE 1' loss in 5S7UI34M and 'FIGURE 5' loss in HQAQBSBP. 372 figure tests pass. |
||
|---|---|---|
| .. | ||
| page4.png | ||