File size: 767 Bytes
1c4c9b7 |
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 re
import jiwer
p = open('label.txt',encoding="utf-8")
label = p.readline().split('=')[1]
label = eval(label)
label_ch = []
label_rm = []
for i in range(len(label)):
q = re.search('[^A-z]+\s+', str(label[i])).span()
label_ch.append(label[i][:q[1]])
label_rm.append(label[i][q[1]:])
p = open('pred.txt','r',encoding="utf-8")
pred = p.readline().split('=')[1]
pred = eval(pred)
pred_ch = []
pred_rm = []
for i in range(len(pred)):
q = re.search('[^A-z]+\s+', str(pred[i])).span()
pred_ch.append(pred[i][:q[1]])
pred_rm.append(pred[i][q[1]:])
for i in range(len(label_rm)):
if len(label_rm[i]) == 0:
print(i)
label_rm[i] = 'a'
wer_ch = jiwer.wer(label_ch, pred_ch)
print(f'{wer_ch=}')
wer_rm = jiwer.wer(label_rm, pred_rm)
print(f'{wer_rm=}')
|