Skip to content

Commit cff14c7

Browse files
committed
unicode fix, bibtex association fix
1 parent 2df8cdb commit cff14c7

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

Diff for: generate.py

+23-16
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,25 @@
66
DBLP_PID_ENTRYPOINT = "https://dblp.dagstuhl.de/pid/"
77

88
class Publication:
9-
def __init__(self, obj, bibstr):
9+
def __init__(self, obj, bibsByKey):
1010
self.title = obj.find(".//title").text #Title acts as ID
11-
self.bibstr = bibstr
12-
1311
try:
14-
self.authorPIDs = [o.attrib["name"] for o in obj.find(".//author")]
12+
self.year = int(obj.find(".//year").text)
1513
except Exception:
16-
try: #If author is not present, fallback to editors
17-
self.authorPIDs = [o.attrib["name"] for o in obj.find(".//editor")]
18-
except Exception:
19-
self.authorPIDs = []
14+
self.year = 0
15+
16+
self.key = obj[0].attrib["key"] #Key is the first child of the publication, used to fetch BibTeX string
17+
self.bibstr = bibsByKey["DBLP:" + self.key] #BibTeX string for this publication
2018

2119
try:
22-
self.year = int(obj.find(".//year").text)
20+
self.authorPIDs = [o.attrib["name"] for o in obj.find(".//author")]
2321
except Exception:
24-
self.year = 0
22+
self.authorPIDs = []
23+
#We don't want to include editorships in the publication list, having a pub with no authors will be pruned
24+
# try: #If author is not present, fallback to editors
25+
# self.authorPIDs = [o.attrib["name"] for o in obj.find(".//editor")]
26+
# except Exception:
27+
# self.authorPIDs = []
2528

2629
def __eq__(self, other):
2730
return self.title == other.title
@@ -42,7 +45,11 @@ def __init__(self, obj) -> None:
4245
xmlTree = ET.fromstring(rawXML)
4346
xmlPubs = xmlTree.findall(".//r") #This has to work since being in DBLP means having at least one publication
4447
assert len(xmlPubs) == len(bibs), "Number of publications in XML and BIB file do not match"
45-
self.pubs = [Publication(x, b) for x, b in zip(xmlPubs, bibs)]
48+
49+
#The key is after the first { to the first , in the bib entry
50+
bibsByKey = {bib.split("{")[1].split(",")[0]: bib for bib in bibs}
51+
52+
self.pubs = [Publication(x, bibsByKey) for x in xmlPubs]
4653

4754
def pubsByYear(self):
4855
"""Returns a list of publications, partially sorted by year."""
@@ -66,10 +73,10 @@ def __hash__(self):
6673
pubAuthors = {} #Maps a publication title to its RAIR affiliated authors
6774
for m in members:
6875
for p in m.pubs:
69-
if p.title in pubAuthors:
70-
pubAuthors[p.title][1].append(m)
76+
if p.key in pubAuthors:
77+
pubAuthors[p.key][1].append(m)
7178
else:
72-
pubAuthors[p.title] = [p, [m]]
79+
pubAuthors[p.key] = [p, [m]]
7380

7481
#Prunes members from a papers author list if they are not a "current member".
7582
#Being a current member at time of publication is defined as 8 years away from a member's first publication
@@ -87,8 +94,8 @@ def __hash__(self):
8794
for p in m.pubs:
8895
if p.year - firstSelmerPub.year > 8:
8996
break
90-
if p.title in pubAuthors:
91-
pubAuthors[p.title][1].remove(m)
97+
if p.key in pubAuthors:
98+
pubAuthors[p.key][1].remove(m)
9299

93100
#Prunes publications with less than 2 current members as authors
94101
pubAuthors2 = {k: v for k, v in pubAuthors.items() if len(v[1]) > 1}

Diff for: main.tex

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
\rfoot{}
3737
\headsep 1.5em
3838

39+
%Some bib entries have this character, which causes a problem
40+
%If latex build ever fails due to a unicode character, add it here
41+
\DeclareUnicodeCharacter{0308}{}
42+
3943
\begin{document}
4044

4145
\include{publications}

0 commit comments

Comments
 (0)