fix(pr1): remove has_any_author gate from affiliation/email fallback

This commit is contained in:
LLLin000 2026-07-04 22:17:43 +08:00
parent 57bb73556b
commit a138100398
2 changed files with 22 additions and 2 deletions

View file

@ -1223,9 +1223,9 @@ def _collect_frontmatter_fallback_fields(
fallback_title = norm
elif role == "authors" and not has_any_author:
fallback_authors.append(norm)
elif role == "affiliation" and not has_any_author:
elif role == "affiliation":
fallback_affiliations.append(norm)
elif role == "email" and not has_any_author:
elif role in {"email", "correspondence"}:
fallback_emails.append(norm)
elif role == "doi" and not has_doi:
# Only accept clean DOI lines

View file

@ -979,6 +979,26 @@ def test_frontmatter_no_duplication_when_metadata_present() -> None:
assert "John Smith" not in md
def test_render_frontmatter_affiliation_fallback_even_when_authors_metadata_present() -> None:
from paperforge.worker.ocr_render import render_fulltext_markdown
structured = [
{"page": 1, "role": "authors", "text": "John Smith", "block_id": "p1_a1"},
{"page": 1, "role": "affiliation", "text": "University of Science", "block_id": "p1_af1"},
]
md = render_fulltext_markdown(
structured_blocks=structured,
resolved_metadata={"authors_display": "John Smith", "authors": {"value": ["John Smith"]}},
figure_inventory={"matched_figures": [], "unmatched_assets": [], "unresolved_clusters": []},
table_inventory={"tables": [], "unmatched_assets": []},
page_count=1,
document_structure=None,
reader_payload={},
)
assert "**Affiliation:** University of Science" in md
assert "John Smith" in md
def test_frontmatter_title_fallback_when_metadata_empty() -> None:
"""Title from structured blocks appears when metadata title is empty."""
from paperforge.worker.ocr_render import render_fulltext_markdown