forked from mattsinc/dblp-python
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdsn-ranking.py
More file actions
233 lines (192 loc) · 7.26 KB
/
dsn-ranking.py
File metadata and controls
233 lines (192 loc) · 7.26 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
import re
import os
import dblp
import json
import time
import datetime
## Constants
OUTPUT_DIR = './output-new' # Output directory
MIN_PAGES = 3 # Min pages for a paper
MATCH = ['DSN', 'FTCS'] # Venues considered
# DOI considered (to filter out workshops)
MATCH_DOI = [
'10\.1109/DSN([0-9]+)\.{}\.([0-9]+)',
'10\.1109/ICDSN\.{}\.([0-9]+)',
'10\.1109/DSN\.{}\.([0-9]+)',
'10\.1109\/FTCS\.{}\.([0-9]+)']
# RECENT = 2014 # Year for recent papers --- change: no hard coding required, figured out from DBLP
RECENT_YEARS = 5 # Number years span used to consider a publication as 'recent'
## Global Variables
authorList = {}
def get_recent_pubs(pubs):
"""
Get the number of recent publications (using the `RECENT` constant as reference.
Args:
pubs: List of publications for the author.
Returns:
The number of publications that qualify as recent.
"""
cc = 0
for key in pubs:
# in case the year has a suffix (e.g., LeeL17a)
try:
yyy = int(key[len(key) - 2:])
except:
yyy = int(key[len(key) - 3:len(key) - 1])
yyy = yyy + 1900 if yyy > 50 else yyy + 2000
if yyy >= RECENT:
cc += 1
return cc
def update_authors(pid, name, key):
"""
Update the author list (`authorList`)
Args:
pid: Identifier of the author.
name: Name of the author
key: Key of the publication
Returns:
None
"""
if pid in authorList:
author = authorList[pid]
author["pubs"].add(key)
authorList[pid] = author
else:
author = {
'name': name,
'pubs': {key}
}
authorList[pid] = author
def filter_papers(pub, venue):
"""
Filter out papers from the count (e.g., Industrial Track, Workshop papers, etc)
Returns:
True if the paper should be considered. False otherwise.
"""
year = int(venue[len(venue)-4:])
pags = 0
# Check number of pages. Discard keynotes or abstract
if 'pages' in pub:
if '-' not in pub['pages']:
pags = 1
else:
try:
pages = pub['pages'].split('-')
pags = int(pages[1]) - int(pages[0]) + 1
except:
# For some papers, pages does not include the finish page of the publication.
pags = 99
if pags < MIN_PAGES:
return False
# Filter out workshops, industry track, supplemental volume, etc
if pub["venue"] in MATCH:
# Papers from main conference can be distinguished by the doi. For example, a paper from a workshop has a doi
# with DSN-W.YYYY, while the papers from the main conference has a doi with DSN.YYYY.
# For some papers the doi is not available (e.g., https://dblp.uni-trier.de/rec/xml/conf/ftcs/HuangK93.xml)
for doi in MATCH_DOI:
try:
regex = r"%s" % doi.format(year)
match = re.search(regex, pub["doi"])
# print ("%s %s" % (regex, pub["doi"]))
if match != None:
# if doi.format(year) in pub["doi"]:
return True
except:
# if the paper does not have a doi
return True
return False
def get_authors(venue):
"""
Save the author list (in `authorList`) who had accepted papers in the conference.
Args:
venue: venue to search. The venue follows this format /conf/XXX/YYYY, where XXX is the abbrev of the conf and
YYYY correspond to the year of the conf.
Returns:
The number of publications (main conference) for the venue
"""
papers=0
results = dblp.search_pub(venue)
hits = json.loads(results)["result"]["hits"]
for i in hits["hit"]:
info = i["info"]
if filter_papers(info, venue):
papers+=1
# print(info)
if 'authors' in info:
if isinstance(info["authors"]["author"], list):
for author in info["authors"]["author"]:
update_authors(author["@pid"], author["text"], info["key"])
else:
author = info["authors"]["author"]
update_authors(author["@pid"], author["text"], info["key"])
return papers
def usage():
if not os.path.isdir(OUTPUT_DIR):
if OUTPUT_DIR[0:2] == './':
dir = OUTPUT_DIR[2:]
else:
dir = OUTPUT_DIR
os.makedirs(dir)
return True
def main():
"""
Main Function
Returns:
"""
if not usage():
exit(1)
# Getting the year used to determine 'recent' publications
cyear = datetime.datetime.now().year
cyear = int(cyear) + 1
global RECENT
RECENT = cyear - RECENT_YEARS
print ('Last: {} | Recent papers since: {}'.format(cyear-1, RECENT))
outFile = open(OUTPUT_DIR + '/dsnHOF-' + time.strftime("%Y%m%d-%H%M%S"), mode='a', encoding='utf-8')
# FTCS (1988-1999)
print ('Processing FTCS (1988, 1999)')
for year in range(1988,2000):
print(" * Processing year {}: {}".format(year, get_authors("conf/ftcs/{}".format(year))))
# DSN (2000-now)
print ('Processing DSN (2000, %d)' % (cyear-1))
for year in range(2000,cyear):
print(" * Processing year {}: {}".format(year, get_authors("conf/dsn/{}".format(year))))
for pid in authorList:
author = authorList[pid]
author['total'] = len (author["pubs"])
author['recent'] = get_recent_pubs(author["pubs"])
authorList[pid] = author
outFile.write("{}\t{}\t{}\t{}\n".format(author["name"], author["total"], author["recent"], author["pubs"]))
outFile.flush()
# Sort by total publications
rank=1
last_total=0
i=1
data = []
for key, value in sorted(authorList.items(), key=lambda x : x[1]['total'], reverse=True):
if i > 100 and last_total != value['total']:
break
if last_total != value['total']: rank = i
print ('{}\t{}\t{}\t{}\t{}\t{}'.format(i, rank, value['name'], value['total'], value['recent'], dblp.get_affiliation(key, value['name'])))
data.append({
"anchor": "ranking",
"num": i,
"rank": rank,
"author": value['name'],
'total': value['total'],
'recent': value['recent'],
'affiliation': dblp.get_affiliation(key, value['name'])
})
i+=1
last_total = value['total']
with open('./ranking.json', mode='w', encoding='utf-8') as jsonFile:
json.dump(data, jsonFile, indent=4)
def test():
# xx = dblp.get_affiliation("i/RavishankarKIyer", "Ravishankar K. Iyer")
# xx = dblp.get_affiliation("k/PhilipKoopman", "Philip J. Koopman Jr.")
# xx = dblp.get_affiliation("50/842","Daniel P. Siewiorek")
# xx = dblp.get_affiliation("l/MichaelRLyu", "Michael R. Lyu")
xx = dblp.get_affiliation("k/JoostPieterKatoen", "Joost-Pieter Katoen")
print(xx)
if __name__ == '__main__':
main()
# test()