forked from hamanhbui/neurips2021_analysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvert_aff.py
38 lines (30 loc) · 884 Bytes
/
convert_aff.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
import pickle
import json
with open("pp_authors.txt", "rb") as fp: # Unpickling
pp_authors = pickle.load(fp)
unis = json.load(open("convert.json"))
new = []
for pp in pp_authors:
for author in pp:
aff_full = author[author.find("(") + 1 : author.find("')")].lower()
is_in = False
if aff_full in unis.keys():
aff_name = unis[aff_full]
is_in = True
for x in unis:
if unis[x] == aff_full:
is_in = True
if is_in == False:
print(aff_full)
if aff_full not in new:
new.append(aff_full)
new.sort()
print(len(new))
obj = {}
for aff in new:
obj[aff] = "to replace"
# Serializing json
json_object = json.dumps(obj, indent=4, sort_keys=True)
# Writing to sample.json
with open("to_convert.json", "w") as outfile:
outfile.write(json_object)