bano1 commited on
Commit
5bb6c29
·
verified ·
1 Parent(s): 911d6f0

Create bibtex.py

Browse files
Files changed (1) hide show
  1. src/bibtex.py +16 -0
src/bibtex.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ def export_bibtex(papers):
2
+ db = {"entries": []}
3
+ for i, p in enumerate(papers):
4
+ title = p.get("title") or f"paper_{i}"
5
+ authors = " and ".join(p.get("authors", ["Unknown"]))
6
+ entry = {
7
+ "ENTRYTYPE": "article",
8
+ "ID": re.sub(r"\s+", "_", title)[:80],
9
+ "title": title,
10
+ "author": authors,
11
+ "year": p.get("year", "2025"),
12
+ "abstract": p.get("abstract", "")
13
+ }
14
+ db["entries"].append(entry)
15
+ return bibtexparser.dumps(db)
16
+