-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathplot.py
More file actions
85 lines (74 loc) · 1.87 KB
/
plot.py
File metadata and controls
85 lines (74 loc) · 1.87 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
import json
from collections import Counter
import pickle
with open("data/pp_authors.txt", "rb") as fp: # Unpickling
pp_authors = pickle.load(fp)
unis = json.load(open("data/alias_map.json"))
affi_count = Counter()
new = []
for pp in pp_authors:
list_aff = []
for author in pp:
aff_full = author[author.find("(") + 1 : author.find("')")].lower()
for aff_nml in unis:
if aff_full in unis[aff_nml] and aff_nml not in list_aff:
list_aff.append(aff_nml)
for aff in list_aff:
affi_count[aff] += 1
academic_prefix = [
"university",
"univerisity",
"institute",
"uc ",
"mit",
"college",
"telecom paris",
"chinese academy of sciences",
"school",
"lawrence livermore national laboratory",
"kaist",
"kaust",
"ist austria",
"cnrs",
"universit\u00e9",
"irit",
"inria",
"college",
"mila",
"eth zurich",
"oxford",
"cornell",
"harvard",
"csiro",
"tu darmstadt",
"kth",
"virginia tech",
"\u00e9cole polytechnique f\u00e9d\u00e9rale de lausanne",
"ens",
"academy",
"unist",
"national",
"yale",
"universite",
"universidad",
"univ.",
"lmu munich",
"cuny",
"tu dresden",
"technion",
"postech",
"telecom sudparis",
]
def is_academic(affi):
for prefix in academic_prefix:
if prefix in affi:
return True
return False
academic_affi_count = Counter({k: v for k, v in dict(affi_count).items() if is_academic(k)})
industry_affi_count = Counter({k: v for k, v in dict(affi_count).items() if not is_academic(k)})
affi_count = sorted(affi_count.items(), key=lambda x: x[1], reverse=True)
# Serializing json
json_object = json.dumps(affi_count, indent=4, sort_keys=True)
# Writing to sample.json
with open("out.json", "w") as outfile:
outfile.write(json_object)