s421818-mlworkshops/createWERandSRRFiles.py

24 lines
606 B
Python
Raw Normal View History

2020-04-03 14:21:13 +02:00
import re
wer = open("wer.txt","w")
2020-04-03 14:48:28 +02:00
lastId = "id: (sp1_4)"
globalPercent = 0
counter = 0
2020-04-03 14:21:13 +02:00
with open("helper.txt", "r") as f:
for line in f:
2020-04-03 14:48:28 +02:00
if re.match(r'^id.*', line):
lastId = line.replace("\n", "")
elif re.match(r'^Scores.*', line):
helper = line.replace("Scores (#C #S #D #I) ", "").split()
sum = int(helper[0]) + int(helper[1]) + int(helper[2]) + int(helper[3])
sum = (int(helper[0])/int(sum)) * 100
globalPercent += sum
counter += 1
wer.write(lastId + " = " + str(sum) + "%\n")
wer.write("AVG: " + str(int((globalPercent) / (int(counter) * 100))*100) + "%")
2020-04-03 14:21:13 +02:00
wer.close()