forked from emeryberger/CSrankings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfind-missing-authors.py
62 lines (45 loc) · 1.81 KB
/
find-missing-authors.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
from csrankings import *
def parseDBLP():
authors = {}
i = 0
with open('dblp.xml', mode='r') as f:
# with gzip.open('dblp.xml.gz') as f:
oldnode = None
foundArticle = False
authorName = ""
for (event, node) in ElementTree.iterparse(f, events=['start', 'end']):
if (oldnode is not None):
oldnode.clear()
oldnode = node
if (node.tag == 'inproceedings' or node.tag == 'article'):
for child in node:
if (child.tag == 'booktitle' or child.tag == 'journal'):
foundArticle = True
break
if (not foundArticle):
# Nope.
continue
# Now, count up how many faculty from our list are on this paper.
for child in node:
if (child.tag == 'author'):
authorName = child.text
if (not authorName is None):
authorName.strip()
if (not authors.has_key(authorName)):
authors[authorName] = 1
return authors
# a = sorted(authors.iteritems(), key=operator.itemgetter(1))
# for k in a:
# print k[0]
def csv2dict_str_str(fname):
with open(fname, mode='r') as infile:
reader = csv.reader(infile)
#for rows in reader:
# print rows[0], "-->", rows[1]
d = {unicode(rows[0].strip(),'utf-8'): unicode(rows[1].strip(),'utf-8') for rows in reader}
return d
facultydict = csv2dict_str_str('faculty-affiliations.csv')
authors = parseDBLP()
for name in facultydict:
if (not name in authors):
print name.encode('utf-8')