Spaces:
Sleeping
Sleeping
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 filesWithout 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>
123456777 unmodified lines85868787888990919293949596979899100101102103104"""Paper-only prompt construction. No poster GT or external generation API."""import jsonimport reimport unicodedatafrom pathlib import Pathfrom PIL import Imageimport fitz77 unmodified lines meta_title=clean_text(doc.metadata.get('title','')) 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): title=meta_title[:400] authors=clean_text(doc.metadata.get('author',''))[:500] # authors: the first-page lines between the title block and the abstract (PDF metadata is usually empty, # and without an authors line the model may invent names) 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] title_bottom=max((s['bbox'][3] for l in title_lines for s in l),default=0) author_lines=[] 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])): txt=clean_text(join_line(l)) 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 if re.search(r'published as a conference|under review|preprint|anonymous author|proceedings of|copyright|workshop',txt,re.I): continue author_lines.append(txt) authors=' '.join(author_lines) authors=re.sub(r'\{[^}]*\}?|\S+@\S+','',authors) # e-mail lists authors=re.sub(r'\s+([\u0300-\u036f])',r'\1',authors) # 'Balunovi ́c' -> 'Balunović' authors=clean_text(unicodedata.normalize('NFC',authors))[:500] or clean_text(doc.metadata.get('author',''))[:500] asset_lines=[];assets=[] for a in chosen: cap=clean_text(a.get('caption',''))pdf_pipeline.py+15-1