2020-04-03 14:05:40 +02:00
|
|
|
import sys
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
word_error_rate = 0
|
|
|
|
number_of_sentence = 0
|
|
|
|
correct_sentences = 0
|
|
|
|
|
|
|
|
with open(sys.argv[1], 'r') as sclite_result, \
|
2020-04-03 16:43:09 +02:00
|
|
|
open('new_wer.txt', 'w') as wer, \
|
|
|
|
open('srr.txt', 'a+') as srr:
|
2020-04-03 14:05:40 +02:00
|
|
|
|
|
|
|
for line in sclite_result:
|
|
|
|
complited = False
|
|
|
|
if line[:7] == 'Scores:':
|
|
|
|
number_of_sentence += 1
|
|
|
|
c, s, d, i = line.strip().split()[-4:]
|
|
|
|
word_error_rate = sum(map(int, [s, d, i])) / sum(map(int, [s, d, c]))
|
|
|
|
complited = True
|
|
|
|
|
|
|
|
if complited:
|
2020-04-03 16:30:37 +02:00
|
|
|
wer.write(f'{word_error_rate:.6f}\n')
|
2020-04-03 14:05:40 +02:00
|
|
|
if word_error_rate == 0:
|
|
|
|
correct_sentences += 1
|
|
|
|
|
|
|
|
sentence_recognition_rate = correct_sentences / number_of_sentence
|
2020-04-03 16:30:37 +02:00
|
|
|
srr.write(f'{sentence_recognition_rate:.6f}\n')
|