hanhaonan02 Claude Fable 5.1 commited on
Commit
96e4fd5
·
1 Parent(s): 4b73edf

Take the author line from the first page, not PDF metadata

Browse files

Without an authors line the model invented author names on a Space-generated poster.
Lines between the title block and the abstract are used; e-mails and stray combining marks removed.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

Files changed (1) hide show
  1. pdf_pipeline.py +15 -1
pdf_pipeline.py CHANGED
@@ -1,6 +1,7 @@
1
  """Paper-only prompt construction. No poster GT or external generation API."""
2
  import json
3
  import re
 
4
  from pathlib import Path
5
  from PIL import Image
6
  import fitz
@@ -84,7 +85,20 @@ def prepare(pdf, job, instruction, canvas, accent, columns, custom_spec=''):
84
  meta_title=clean_text(doc.metadata.get('title',''))
85
  if meta_title and len(meta_title)>8 and (len(title)<8 or len(title.split())>3 and sum(len(w) for w in title.split())/len(title.split())<2.5):
86
  title=meta_title[:400]
87
- authors=clean_text(doc.metadata.get('author',''))[:500]
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  asset_lines=[];assets=[]
89
  for a in chosen:
90
  cap=clean_text(a.get('caption',''))
 
1
  """Paper-only prompt construction. No poster GT or external generation API."""
2
  import json
3
  import re
4
+ import unicodedata
5
  from pathlib import Path
6
  from PIL import Image
7
  import fitz
 
85
  meta_title=clean_text(doc.metadata.get('title',''))
86
  if meta_title and len(meta_title)>8 and (len(title)<8 or len(title.split())>3 and sum(len(w) for w in title.split())/len(title.split())<2.5):
87
  title=meta_title[:400]
88
+ # authors: the first-page lines between the title block and the abstract (PDF metadata is usually empty,
89
+ # and without an authors line the model may invent names)
90
+ title_lines=[l for l in lines if max(s['size'] for s in l)>=largest*.85 and l[0]['bbox'][1]<doc[0].rect.height*.45]
91
+ title_bottom=max((s['bbox'][3] for l in title_lines for s in l),default=0)
92
+ author_lines=[]
93
+ for l in sorted((l for l in lines if l[0]['bbox'][1]>=title_bottom-1 and l not in title_lines),key=lambda l:(round(l[0]['bbox'][1]),l[0]['bbox'][0])):
94
+ txt=clean_text(join_line(l))
95
+ if re.match(r'^\s*(abstract|a\s*b\s*s\s*t\s*r\s*a\s*c\s*t)\b',txt,re.I) or l[0]['bbox'][1]>doc[0].rect.height*.5: break
96
+ if re.search(r'published as a conference|under review|preprint|anonymous author|proceedings of|copyright|workshop',txt,re.I): continue
97
+ author_lines.append(txt)
98
+ authors=' '.join(author_lines)
99
+ authors=re.sub(r'\{[^}]*\}?|\S+@\S+','',authors) # e-mail lists
100
+ authors=re.sub(r'\s+([\u0300-\u036f])',r'\1',authors) # 'Balunovi ́c' -> 'Balunović'
101
+ authors=clean_text(unicodedata.normalize('NFC',authors))[:500] or clean_text(doc.metadata.get('author',''))[:500]
102
  asset_lines=[];assets=[]
103
  for a in chosen:
104
  cap=clean_text(a.get('caption',''))