File size: 772 Bytes
aee2b04
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import jiwer
import ast
p = open('pred.txt','r',encoding="utf-8")
l = open('label.txt','r',encoding="utf-8")

pred = p.readline().split('=')[1]
label = l.readline().split('=')[1]
pred = ast.literal_eval(pred) # list like str to list
label = ast.literal_eval(label)
for i in range(len(pred)):
	pred[i] = "".join(dict.fromkeys(pred[i])).replace(' ','')
for i in range(len(label)):
	label[i] = "".join(dict.fromkeys(label[i])).replace(' ','')
print(pred[0])
print(label[0])
wer = jiwer.wer(label, pred)
print(f'{wer=}')
'''
pred = pred.replace(' ', '')
label = label.replace(' ', '')
'''
cer = jiwer.cer(label, pred)
print(f'{cer=}')

q = open('modify_pred.txt','w',encoding="utf-8")
q.write(f'{pred=}')

a = open('modify_label.txt','w',encoding="utf-8")
a.write(f'{label=}')