fix: body_zone filter must skip recovery-rescued captions

The body_zone early-exit filter unconditionally skipped all figure_caption_candidate
blocks in body_zone. After PDF prefix recovery, recovered captions now have a
'Figure N' prefix but were still blocked by the zone filter. Added
_extract_figure_number() guard so body_zone captions with a recovered number
pass through to legend matching.

Result for 5S7UI34M: 4->9 matched figures, 33->1 unmatched assets (p1 logo).
This commit is contained in:
LLLin000 2026-07-03 01:24:56 +08:00
parent 4de22c90c2
commit 59708cd961

View file

@ -3049,7 +3049,8 @@ def build_figure_inventory(structured_blocks: list[dict], page_width: float = 12
and _looks_like_figure_description_opening(text)
)
if role == "figure_caption_candidate" and (
str(block.get("zone") or "") == "body_zone"
(str(block.get("zone") or "") == "body_zone"
and _extract_figure_number(block.get("text", "")) is None) # skips recovery-rescued captions
or (
str(block.get("zone") or "") != "display_zone"
and str(block.get("style_family") or "") != "legend_like"