File size: 863 Bytes
707614a
9dda31e
 
707614a
 
9dda31e
 
707614a
142a9b8
707614a
 
 
 
 
 
 
 
 
 
 
 
9dda31e
707614a
 
9dda31e
707614a
 
 
9dda31e
707614a
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import csv
import json

from tqdm import tqdm

from categories.accuracy import *

try:
    with open("../data/translations.json", "r") as f:
        translations = json.loads(f.read())
except Exception as e:
    print(e)
    translations = None

accuracy_scores = []
print("Calculating accuracy scores...")
for t in tqdm(translations):
    acc_s = accuracy(t["german"], t["english"])
    accuracy_scores.append(acc_s["score"])

# Create a CSV file
with open("accuracy_scores.csv", "w", newline="") as csvfile:
    writer = csv.writer(csvfile)
    # Write the header
    writer.writerow(["German", "English", "Accuracy Score"])
    # Write the data
    print("\nWriting to CSV...")
    for i, t in tqdm(enumerate(translations)):
        writer.writerow([t["german"], t["english"], accuracy_scores[i]])

print(f"CSV file created with {len(translations)} entries.")