-
Notifications
You must be signed in to change notification settings - Fork 0
/
myUnitTest.py
60 lines (53 loc) · 2.34 KB
/
myUnitTest.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
48
49
50
51
52
53
54
55
56
57
58
59
60
import main
import unittest
class MyUnitTest(unittest.TestCase):
pairs = [
[
'I want to buy the car, becaeuse it is cheap. The car is also luxurius.',
'I want to buy the car, because it is cheap. The car is also luxurious.'
],
[
'how far is it from the churc to the station?',
'how far is it from the church to the station?'
],
[
'in 1986 a severe nuclear disaster occurred in the city of Chernobyl. It is considered the worst nuclear '
'disaster in historie.' +
' it is belived that the disaster was cauded by human error and reacctor\'s design flas.',
'in 1986 a severe nuclear disaster occurred in the city of Chernobyl. It is considered the worst nuclear '
'disaster in history.' +
' it is believed that the disaster was caused by human error and reactor\'s design flaws.'
],
[
'Swimning in ghe Caraibbean sea must be very relaxying.',
'Swimming in the Caribbean sea must be very relaxing.',
],
[
'This hamburger costs 350$.',
'This hamburger costs 350$.'
],
[
'Don\'t be latr.',
'Don\'t be late.'
],
[
'We were two student from the Columbus Univerisity. As mecanics ennginers we design engines, power plants' +
' and other machines.',
'We were two student from the Columbus University. As mechanics engineers we design engines, power plants' +
' and other machines.'
]
]
def test_equals(self):
for pair in self.pairs:
test_txt = pair[0]
ref_txt = pair[1]
output_txt = main.correct(test_txt) # il testo corretto e' uncased per via di BERT uncased in uso
self.assertEqual(output_txt, ref_txt, output_txt + ' != ' + ref_txt)
def test_not_equals(self):
text = 'Pontedera is near Pisa' # il dizionario non riconosce la citta di Pontedera
self.assertNotEqual(main.correct(text), text.lower())
text2 = 'The new Huauei has a 20 Mpx camera desined by Leica' # Huawei e Leica non predicibili da BERT
self.assertNotEqual(main.correct(text2), text2.lower())
if __name__ == '__main__':
test = MyUnitTest()
test.main(failfast=True)