Spaces:
Sleeping
Sleeping
File size: 560 Bytes
74b7889 5bb6c29 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | import re
import bibtexparser
def export_bibtex(papers):
db = {"entries": []}
for i, p in enumerate(papers):
title = p.get("title") or f"paper_{i}"
authors = " and ".join(p.get("authors", ["Unknown"]))
entry = {
"ENTRYTYPE": "article",
"ID": re.sub(r"\s+", "_", title)[:80],
"title": title,
"author": authors,
"year": p.get("year", "2025"),
"abstract": p.get("abstract", "")
}
db["entries"].append(entry)
return bibtexparser.dumps(db)
|