2019-05-17 10:33:58 +02:00
|
|
|
import re
|
|
|
|
import csv
|
|
|
|
|
|
|
|
allWer = []
|
|
|
|
corrects = 0
|
|
|
|
|
|
|
|
with open("out.txt", "r", encoding='utf-8') as results:
|
|
|
|
for line in results:
|
|
|
|
if line.startswith('Scores'):
|
|
|
|
correct = int(re.findall('\\d+', line)[0])
|
|
|
|
substitutions = int(re.findall('\\d+', line)[1])
|
|
|
|
deletions = int(re.findall('\\d+', line)[2])
|
|
|
|
insertions = int(re.findall('\\d+', line)[3])
|
|
|
|
|
|
|
|
wer = (substitutions + deletions + insertions) / (substitutions + deletions + correct)
|
|
|
|
allWer.append(wer)
|
|
|
|
|
|
|
|
if substitutions == 0 and deletions == 0 and insertions == 0:
|
|
|
|
corrects += 1
|
|
|
|
|
|
|
|
werAvg = sum(allWer) / len(allWer)
|
|
|
|
srr = corrects / len(allWer)
|
2019-05-17 11:00:38 +02:00
|
|
|
|
|
|
|
with open("WerSrrOut.txt", "w") as file:
|
|
|
|
file.write("WER average: " + str(werAvg) + '\n' + "Sentence recognition rate: " + str(srr))
|
|
|
|
file.close()
|