39 lines
951 B
Python
39 lines
951 B
Python
import pandas as pd
|
|
from jiwer import wer
|
|
|
|
df_data = pd.read_csv('./Infra/wikiniews_results.tsv', sep='\t', index_col=False, header=None,
|
|
skip_blank_lines=False, keep_default_na=False, names=[1,2,3,4,5])
|
|
|
|
correct_answers = 0
|
|
|
|
for index, row in df_data.iterrows():
|
|
|
|
wer_result = wer(row[2], row[3])
|
|
|
|
df_data.loc[index, 5] = wer_result
|
|
|
|
if wer_result == 0.0:
|
|
|
|
correct_answers += 1
|
|
|
|
|
|
wer_mean = df_data[5].mean()
|
|
print(wer_mean)
|
|
|
|
srr = (correct_answers*1)/len(df_data)
|
|
print(srr)
|
|
|
|
df_data.to_csv('./wikiniews_results_with_wer.tsv',sep='\t', header=None)
|
|
|
|
with open("wer_mean.txt", "w") as text_file:
|
|
text_file.write(str(df_data[5].mean()))
|
|
|
|
with open("srr.txt", "w") as text_file:
|
|
text_file.write(str(srr))
|
|
|
|
with open("historical_wer_mean.txt", "a") as text_file:
|
|
text_file.write(str(df_data[5].mean()) + '\n')
|
|
|
|
with open("historical_srr.txt", "a") as text_file:
|
|
text_file.write(str(srr) + '\n')
|