-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfilter_pure_mavlab.py
152 lines (114 loc) · 4.71 KB
/
filter_pure_mavlab.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
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
import bibtexparser
import json
from collections import OrderedDict
chairs = {
'MAVLAB': ['valles', 'coppola', 'scheper', 'mcguire', 'olejnik', 'dijk', 'wagter', 'croon', 'remes', 'popovic', 'popović',
'ruijsink', 'karasek', 'armanini', 'caetano', 'tijmons', 'smeur', 'horst', 'tienen', 'hecke',
'oliveira', 'lentink', 'percin', 'tay', 'noyon', 'dupeyroux', 'hamaza', 'ferede', 'bahnam',
'mancinelli', 'stroobants', 'hagenaars',
'ho', 'li',
# 'wang', 'ma', 'xu', 'yu', 'wu', 'ye', 'zheng',
'altena', 'bredenbeck',
'ramirez', 'farinha', 'ponti', 'blaha', 'nowak' ]}
# Full authors name removal
remove = ['V. Ho', 'A. Sharma', 'Max Li', 'Yifei Li']
# , 'Merkus', 'Costa', 'Engelen', 'Xue Wu', 'S Wu', 'S-F Wu', 'SF Wu', 'M Wang', 'Xuerui Wang',
# 'Guangming Zeng', 'Sherry Wang', 'Yanyang Wang', 'Xiaotian Wang', 'Xue Wu', 'T Chen',
# 'GT Zheng']
def get_chair(name):
for chair, staff in chairs.items():
if name in staff:
return chair
return None
papers = dict()
totals = OrderedDict()
mavlabpapers = {}
parser = bibtexparser.bparser.BibTexParser(common_strings=True)
with open('./pure/cs.bib', encoding="utf8") as bibtex_file:
bibtex_str = bibtex_file.read()
bib_database = bibtexparser.loads(bibtex_str, parser=parser)
mavlab_database = bibtexparser.bibdatabase.BibDatabase()
rest = bibtexparser.bibdatabase.BibDatabase()
print('================================================================')
for b in bib_database.entries:
#print(b)
if not ('year' in b) or not ('author' in b) or not ('ENTRYTYPE' in b) or not ('title' in b):
print('ERROR!', b)
print('------------------------------------------------------------------------')
continue
# Paper
year = b['year']
title = b['title']
doctype = b['ENTRYTYPE']
authors = b['author']
if year not in totals:
papers[year] = []
totals[year] = {key:{} for key in chairs.keys()}
totals[year].update({staff:{} for chair in chairs.values() for staff in chair})
curyear = totals[year]
curyear_papers = papers[year]
paperstring = b['ID'] + ': ' + doctype
curyear_papers.append(paperstring)
papers[year] = curyear_papers
mavlabpaper = 0
for person in authors.split(' and '):
if ',' in person:
# last name left of comma: right part
name = person.split(',')[0].split(' ')[-1].strip().strip('{').strip('}').strip().lower()
else:
# last name
name = person.split(' ')[-1].strip().strip('{').strip('}').strip().lower()
chairname = get_chair(name)
if chairname == 'MAVLAB':
if mavlabpaper > -1: # if not forbidden
mavlabpaper = 1
if person in remove:
print(person)
# Store forbidden
mavlabpaper = -1
#print(person, name, chairname)
if chairname:
sum_pers = curyear[name]
if doctype not in sum_pers:
sum_pers[doctype] = []
sum_pers[doctype].append(paperstring)
#print('-----',b['year'],b['ENTRYTYPE'],mavlabpaper)
if mavlabpaper == 1:
key = (year, doctype)
if not key in mavlabpapers:
mavlabpapers[key] = 0
mavlabpapers[key] += 1
mavlab_database.entries.append(b)
else:
rest.entries.append(b)
print(mavlabpapers)
# dump back
writer = bibtexparser.bwriter.BibTexWriter()
writer.indent = '\t' # indent entries with 4 spaces instead of one
writer.order_entries_by = 'year'
writer.align_values = True
with open('pure.bib', 'w', encoding='utf8') as bibfile:
bibfile.write('# AUTOGENERATED\n# Import from: https://research.tudelft.nl/en/organisations/control-simulation/publications/\n\n\n')
bibfile.write(writer.write(mavlab_database).replace('&',r'\&'))
with open('pure/cs_nomav.bib', 'w', encoding='utf8') as bibfile:
bibfile.write(writer.write(rest))
def print_summary():
# Excel file with papers per year
with open('mavlab_summary.csv', 'w') as fout:
paper_types = ['article','inproceedings', 'phdthesis', 'conference', 'book', 'misc']
fout.write('year')
for t in paper_types:
fout.write(';' + t)
fout.write('\n')
for y in range(2003,2026):
fout.write(str(y) + ';')
for t in paper_types:
key = (str(y),t)
#print(key)
if key in mavlabpapers:
fout.write(str(mavlabpapers[key]) + ';')
else:
fout.write('0;')
fout.write('\n' )
print_summary()
print('Done')