-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathresearcher.py
More file actions
83 lines (70 loc) · 2.77 KB
/
researcher.py
File metadata and controls
83 lines (70 loc) · 2.77 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
"""
每⼀个会议都有各⾃的⽀持者,现在请你将每个会议各⾃的研
究者寻找出来,并且根据时间信息,看看哪些⼈依然活跃,哪些
⼈不再活跃。
"""
import os
import json
import codecs
from utils import load_data, confs
def find_researcher_of_conf(data):
researchers = {} # map the papers according to the conference
for item in data:
conf = item['conf']
if conf not in researchers:
researchers[conf] = []
researchers[conf].append(item)
file_path = './data/researchers/'
if not os.path.exists(file_path):
os.makedirs(file_path)
for conf in confs:
conf_researchers = {} # map the authors according to the year
for item in researchers[conf]:
year = item['year']
if year not in conf_researchers:
conf_researchers[year] = set()
conf_researchers[year] = conf_researchers[year].union(item['author'])
for key in conf_researchers.keys():
conf_researchers[key] = list(conf_researchers[key])
active_list = []
for item in conf_researchers.items():
active_list.append({
'year': int(item[0]),
'authors': item[1]
})
active_list.sort(key=lambda x: x['year'])
active = find_active_researchers(active_list, flag=0xff)
# write researchers of each conference
with codecs.open(file_path + conf + '.json', 'w', encoding='utf8') as f:
f.write(json.dumps(active_list))
# write active researchers of each conference
with codecs.open(file_path + 'active/' + conf, 'w', encoding='utf8') as f:
for r in active:
f.write(r[0] + '\n')
# find the authors who have paper after 2007
def find_active_researchers(active_list, base_year=2007, flag=0):
"""
Rank the authors of the conference and return the result.
"""
researchers = {}
for item in active_list:
for r in item['authors']:
#set the bit to 1 corresponding to that year if a paper has been published in a certain year
if r not in researchers:
researchers[r] = 1 << item['year'] - base_year
else:
researchers[r] = (1 << item['year'] - base_year) | researchers[r]
# sort according to the nearest publication year
active = sorted(researchers.items(), key=lambda x: x[1], reverse=True)
# filter
idx = 0
while idx < len(active):
if active[idx][1] < flag:
break
else:
idx += 1
return active[:idx]
if __name__ == '__main__':
# load data
data = load_data()
find_researcher_of_conf(data)