forked from myay/TREAM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresult_summarizer_ntctcrt.py
139 lines (85 loc) · 3.89 KB
/
result_summarizer_ntctcrt.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
import os
def main():
#src_path = "./results/raw/nt/split/"
#des_path = "./results/clean/nt/res_n_split.txt"
#src_path = "./results/raw/nt/fval/"
#des_path = "./results/clean/nt/res_n_fval.txt"
#src_path = "./results/raw/nt/fidx/"
#des_path = "./results/clean/nt/res_n_fidx.txt"
#src_path = "./results/raw/nt/chidx/"
#des_path = "./results/clean/nt/res_n_chidx.txt"
#src_path = "./results/raw/ct/split/"
#des_path = "./results/clean/ct/res_ct_split.txt"
#src_path = "./results/raw/ct/fval/"
#des_path = "./results/clean/ct/res_ct_fval.txt"
#src_path = "./results/raw/ct/fidx/"
#des_path = "./results/clean/ct/res_ct_fidx.txt"
#src_path = "./results/raw/ct/chidx/"
#des_path = "./results/clean/ct/res_ct_chidx.txt"
#src_path = "./results/raw/crt/split/"
#des_path = "./results/clean/crt/res_crt_split.txt"
#src_path = "./results/raw/crt/fval/"
#des_path = "./results/clean/crt/res_crt_fval.txt"
#src_path = "./results/raw/crt/fidx/"
#des_path = "./results/clean/crt/res_crt_fidx.txt"
#src_path = "./results/raw/nt/chidx/"
#des_path = "./results/clean/nt/res_n_chidx.txt"
#DT
#src_path = "./results/raw/crt/split/"
#des_path = "./results/clean/crt/res_crt_split_DT.txt"
#src_path = "./results/raw/crt/fval/"
#des_path = "./results/clean/crt/res_crt_fval_DT.txt"
#src_path = "./results/raw/crt/fidx/"
#des_path = "./results/clean/crt/res_crt_fidx_DT.txt"
#src_path = "./results/raw/nt/split/"
#des_path = "./results/clean/crt/res_nt_split_DT.txt"
#src_path = "./results/raw/nt/fval/"
#des_path = "./results/clean/crt/res_nt_fval_DT.txt"
#src_path = "./results/raw/nt/fidx/"
#des_path = "./results/clean/crt/res_nt_fidx_DT.txt"
#src_path = "./results/raw/nt/chidx/"
#des_path = "./results/clean/crt/res_nt_chidx_DT.txt"
#RF
#src_path = "./results/raw/crt/split/"
#des_path = "./results/clean/crt/res_crt_split_RF.txt"
#src_path = "./results/raw/crt/fval/"
#des_path = "./results/clean/crt/res_crt_fval_RF.txt"
#src_path = "./results/raw/crt/fidx/"
#des_path = "./results/clean/crt/res_crt_fidx_RF.txt"
#src_path = "./results/raw/nt/split/"
#des_path = "./results/clean/crt/res_nt_split_RF.txt"
#src_path = "./results/raw/nt/fval/"
#des_path = "./results/clean/crt/res_nt_fval_RF.txt"
#src_path = "./results/raw/nt/fidx/"
#des_path = "./results/clean/crt/res_nt_fidx_RF.txt"
src_path = "./results/raw/nt/chidx/"
des_path = "./results/clean/crt/res_nt_chidx_RF.txt"
out = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
BERs = ["0.00001,", "0.0001,", "0.0010,", "0.0100,", "0.1000,", "0.2000,", "0.4000,", "0.6000,", "0.8000,", "1.0000,"]
counter = 0
for filename in os.listdir(src_path):
if(filename.find("pkl") == -1 and filename.find("output") == -1 and filename.find("result") == -1
#and (filename.find("_T5") == -1 and filename.find("_T10") == -1)
and (filename.find("_T5") != -1 or filename.find("_T10") != -1)
):
counter = counter + 1
#print(filename)
with open(src_path + filename, 'r') as f:
#with open(des_path + filename, 'w+') as w:
for idx, line in enumerate(f.readlines()):
#print(line)
if(idx != 0):
#print(line)
out[idx-1] += float(line.split(",")[1])
#else:
#out = line.split()
#out = line.split(" ")[1] + line.split(" ")[3]
#w.write(out + "\n")
for idx, sum in enumerate(out):
out[idx] = sum / counter
print(counter)
with open(des_path, 'w+') as w:
for idx, sum in enumerate(out):
w.write(BERs[idx] + "{:.4f}".format(sum) + "\n")
if __name__ == '__main__':
main()