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=}')