fix: suppress Journal Pre-proof running header on ALL pages, not just page 1

Running headers at y<6% page height with pre-proof text are now
frontmatter_noise regardless of page number or raw_label, preventing
PaddleOCR mislabeling header as paragraph_title from inserting
page-furniture text into the body heading hierarchy
This commit is contained in:
Research Assistant 2026-06-08 19:38:31 +08:00
parent abe7c6744a
commit 1ca2f7e509
2 changed files with 17 additions and 14 deletions

View file

@ -399,16 +399,19 @@ def assign_block_role(
page_w = float(block.get("page_width") or page_width or 1200)
block_width = (bbox[2] - bbox[0]) if len(bbox) >= 4 else 0
preproof_likely = (
page_num == 1
and y_top > page_h * 0.08
and raw_label == "paragraph_title"
)
# Running header on any page — pre-proof text at extreme top is page furniture
if y_top < page_h * 0.06:
return RoleAssignment(
role="frontmatter_noise",
confidence=0.98,
evidence=[
"journal pre-proof running header suppressed: "
f"p{page_num} y={y_top:.0f}/{page_h:.0f}"
],
)
is_running_header = y_top < page_h * 0.06
is_footer = y_top > page_h * 0.94
if preproof_likely and not is_running_header and not is_footer:
# Page 1 cover-page pre-proof is also page furniture
if page_num == 1 and raw_label == "paragraph_title" and y_top > page_h * 0.08:
return RoleAssignment(
role="frontmatter_noise",
confidence=0.98,

View file

@ -683,16 +683,16 @@ def test_preproof_marker_variants():
assert result.role == "frontmatter_noise"
def test_preproof_running_header_not_suppressed():
"""Pre-proof text at extreme top (like a running header) should NOT be suppressed."""
def test_preproof_running_header_is_suppressed():
"""Pre-proof text at extreme top (running header) on any page is suppressed."""
from paperforge.worker.ocr_roles import assign_block_role
result = assign_block_role({
"raw_label": "paragraph_title",
"text": "Journal Pre-proof",
"page": 1, "page_width": 1224, "page_height": 1584,
"block_bbox": [190, 30, 475, 55],
"page": 4, "page_width": 1224, "page_height": 1584,
"block_bbox": [190, 1, 475, 20],
}, page_blocks=[])
assert result.role != "frontmatter_noise"
assert result.role == "frontmatter_noise"
def test_preproof_page2_not_suppressed():