s460929-mlworkshops/script.py

31 lines
863 B
Python
Raw Permalink Normal View History

2020-04-04 15:24:01 +02:00
import csv
2020-04-10 17:05:58 +02:00
file = open("scliteresult.txt", "r")
2020-04-04 15:24:01 +02:00
scores = []
for f in file:
if "Scores" in f:
score = (f[22:].rstrip("\n").split(" "))
score = (int(score[1])+int(score[2])+int(score[3]))/(int(score[0])+int(score[1])+int(score[2]))
scores.append(round(score,2))
file.close()
2020-04-10 17:05:58 +02:00
counter = len(scores)
scores_sum = 0
2020-04-04 15:24:01 +02:00
with open('wikiniews_results.tsv','r') as f_in:
2020-04-10 14:50:28 +02:00
with open('newresults.tsv', 'w') as f_out:
2020-04-04 15:24:01 +02:00
writer = csv.writer(f_out, delimiter=' ', lineterminator='\n')
reader = csv.reader(f_in, delimiter='\t')
result = []
for row,score in zip(reader, scores):
# add new column values
row.append('\t'+str(score))
2020-04-10 17:05:58 +02:00
scores_sum +=score
2020-04-04 15:24:01 +02:00
result.append(row)
2020-04-10 17:05:58 +02:00
writer.writerows(result)
2020-04-10 18:51:22 +02:00
file = open("wer_results.txt", "a")
2020-04-10 19:19:23 +02:00
file.write(str(score) + "\n")