25 lines
749 B
Python
25 lines
749 B
Python
import sys
|
|
|
|
if __name__ == '__main__':
|
|
werC = 0
|
|
sentenceNumber = 0
|
|
correctSentence = 0
|
|
|
|
with open('wynik2.txt','r') as x, \
|
|
open('wer.txt','w+') as werOut, \
|
|
open('srr.txt','w+') as srrOut:
|
|
for line in x:
|
|
done = False
|
|
if line[:21] == 'Scores: (#C #S #D #I)':
|
|
sentenceNumber += 1
|
|
c, s, d, i = line.strip().split()[-4:]
|
|
werC = sum(map(int, [s, d, i])) / sum(map(int, [s, d, c]))
|
|
done = True
|
|
if done:
|
|
werOut.write(f'{werC:.5f}\n')
|
|
if werC == 0:
|
|
correctSentence +=1
|
|
|
|
srr = ( correctSentence / sentenceNumber ) * 100
|
|
srrOut.write(f'{srr:.5f}\n')
|