-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
ml_test.py
47 lines (37 loc) · 1.51 KB
/
ml_test.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import unittest
import os
from whisper_normalizer.indic_normalizer import MalayalamNormalizer
normalizer = MalayalamNormalizer()
CURR_DIR = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
import unittest
class TestNormalizer(unittest.TestCase):
def setUp(self):
# Read input and output data from ml_norm.tsv
self.test_data = []
with open(os.path.join(CURR_DIR, "ml_norm.tsv")) as file:
for line in file:
input_data, expected_output = line.strip().split('\t')
self.test_data.append((input_data, expected_output))
def test_normalizer(self):
passes = 0
failures = 0
failure_list = []
for input_data, expected_output in self.test_data:
# Apply your normalizer to the input data
result = normalizer(input_data)
# Compare the result with the expected output
if result == expected_output:
passes += 1
else:
failures += 1
failure_list.append((input_data, expected_output, result))
# Print the list of failures and the number of passes
print("Passes:", passes)
print("Failures:", failures)
for failure in failure_list:
print("Input:", failure[0])
print("Expected Output:", failure[1])
print("Actual Output:", failure[2])
print() # Add a newline for clarity
if __name__ == '__main__':
unittest.main()