mirror of
https://github.com/lllin000/PaperForge.git
synced 2026-07-22 06:50:53 +00:00
fix: preserve panel labels and figure_inner_text in post-reference backmatter zone
This commit is contained in:
parent
06f3c3e948
commit
af11f6d985
2 changed files with 24 additions and 0 deletions
|
|
@ -4682,6 +4682,12 @@ def normalize_document_structure(
|
|||
new_role="media_asset",
|
||||
reason="image/media block in post_reference_backmatter_zone promoted to media_asset",
|
||||
)
|
||||
# ponytail: panel_label + figure_inner_text guard; if other specialized roles
|
||||
# appear in backmatter zone, extend this list
|
||||
if block.get("marker_signature", {}).get("type") == "panel_label":
|
||||
continue
|
||||
if block.get("role") == "figure_inner_text":
|
||||
continue
|
||||
elif role not in _BACKMATTER_NON_BODY_ROLES:
|
||||
old_role = block.get("role")
|
||||
if old_role != "backmatter_body":
|
||||
|
|
|
|||
|
|
@ -143,3 +143,21 @@ def test_keep_formal_caption_seed_for_numbered_display_legend() -> None:
|
|||
}
|
||||
|
||||
assert _should_keep_formal_caption_seed(block) is True
|
||||
|
||||
|
||||
def test_panel_label_in_post_ref_zone_not_converted_to_backmatter() -> None:
|
||||
"""Panel labels like (a) in post_reference_backmatter_zone stay figure_inner_text.
|
||||
|
||||
Regression: guard in normalize_document_structure prevents backmatter
|
||||
normalization from overwriting figure_inner_text role.
|
||||
"""
|
||||
from paperforge.worker.ocr_roles import assign_block_role
|
||||
|
||||
block = {
|
||||
"block_label": "text",
|
||||
"block_content": "(a)",
|
||||
"block_bbox": [90, 90, 120, 120],
|
||||
"page": 10,
|
||||
}
|
||||
role = assign_block_role(block, page_blocks=[], page_width=1200, page_height=1600)
|
||||
assert role.role == "figure_inner_text"
|
||||
|
|
|
|||
Loading…
Reference in a new issue