s421818-mlworkshops/createWERandSRRFiles.py
2020-04-03 14:24:43 +02:00

14 lines
375 B
Python

import re
wer = open("wer.txt","w")
with open("helper.txt", "r") as f:
for line in f:
if re.match(r'^id:.*', line):
wer.write(line + " = ")
elif re.match(r'^Scores:.*', line):
helper = line.replace("Scores: (#C #S #D #I) ", "").split()
sum = helper[0] + helper[1] + helper[2] + helper[3]
wer.write(str((int(helper[0])/int(sum)) * 100) + "%\n")
wer.close()