-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerate_report.py
64 lines (54 loc) · 1.62 KB
/
generate_report.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
from cgi import test
import os
def make_report(path_origdata,csv,task):
#test_grammer_swap0.1_eval_matrix
# report_which = path_origdata.replace('15t','t')
# report_which = path_origdata.replace('15d','d')
if task=='test':
report_which = path_origdata.split('/')[-1].split('test')[0]
else:
report_which = path_origdata.split('/')[-1].split('dev')[0]
# print(report_which)
# print(report_which.replace('compounds','').replace('context',''))
model= path_origdata.split('/')[-1].replace('swap','').replace('_eval_matrix.txt','')
model = model.split('_')[-1]
print("t",model)
#report_which.replace('compounds','').replace('context','')
dev1 = open(path_origdata,'r')
dev = dev1.readlines()
for i in range(len(dev)):
dev[i] = dev[i].replace('\n','').split(' ')
print()
print()
print()
print("yesh")
print(dev7])
print(dev[10][2])
# exit()
accuracy = dev[7][13]
f1 = dev[8][4]
recall = dev[8][3]
prec = dev[8][2]
writer.writerow([model,accuracy,recall,prec,f1])
# print([model,context,batch,accuracy,f1,recall,prec])
import csv
pth = 'results english/'
files = os.listdir(pth)
files.sort()
task = 'dev'
f = open('results_task2'+task+'.csv', 'w')
writer = csv.writer(f)
writer.writerow(['model','accuracy','recall','prec','f1'])
# task = 'dev
# print(files)
#exit()
# if 'dev' in 'indicbertcontext15015dev_report.txt':
# print("dell")
# exit()
for file in files:
print(file)
if task in file:
# if '150' in file:
# print('150')
make_report(pth+file,writer,task)
f.close()