-
Notifications
You must be signed in to change notification settings - Fork 0
/
meaningtest.py
executable file
·70 lines (62 loc) · 2.53 KB
/
meaningtest.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
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Unit tests for meaning.py"""
import meaning
import unittest
class KnownValues(unittest.TestCase):
knownParserValues = (
("*German: [[wichtig]]",
[('de', 'wichtig', '', 1, False, '')]
),
("*[[Esperanto]]: [[grava]]",
[('eo', 'grava', '', 1, False, '')]
),
("*{{fr}}: [[importante]] {{f}}",
[('fr', 'importante', 'f', 1, False, '')]
),
("*Dutch: [[voorbeelden]] ''n, pl'', [[instructies]] {{f}}, {{p}}",
[('nl', 'voorbeelden', 'n', 2, False, ''),
('nl', 'instructies', 'f', 2, False, '')]
),
("*Russian: [[шесток]] ''m'' (shestok)",
[('ru', 'шесток', 'm', 1, False, 'shestok')]
),
("*Kazakh: сәлем, салам, сәлеметсіздер(respectable)",
[('ka', 'сәлем', '', 1, False, ''),
('ka', 'салам', '', 1, False, ''),
('ka', 'сәлеметсіздер', '', 1, False, 'respectable')]
),
("*Chinese(Mandarin):[[你好]](ni3 hao3), [[您好]](''formal'' nin2 hao3)",
[('zh', '你好', '', 1, False, 'ni3 hao3'),
('zh', '您好', '', 1, False, "''formal'' nin2 hao3")]
),
("*German: [[Lamm]] ''n'' [[:de:Lamm|(de)]]",
[('de', 'Lamm', 'n', 1, False, '')]
),
("*Italian: [[pronto#Italian|pronto]]",
[('it', 'pronto', '', 1, False, '')]
),
)
def testParser(self):
'''self.term, self.gender, self.number, self.diminutive and remark
parsed correctly from Wiki format
'''
for wikiline, results in self.knownParserValues:
ameaning = meaning.Meaning('en', 'dummy')
ameaning.parseTranslations(wikiline)
i = 0
for termlang, thisterm, termgender, termnumber, termisadiminutive, \
remark in results:
resultterm = ameaning.translations[
termlang]['alltrans'][i]['trans']
self.assertEqual(resultterm.getTerm(), thisterm)
self.assertEqual(resultterm.getGender(), termgender)
self.assertEqual(resultterm.getNumber(), termnumber)
# self.assertEqual(resultterm.getIsDiminutive(),
# termisadiminutive)
self.assertEqual(
ameaning.translations[termlang]['alltrans'][i]['remark'],
remark)
i += 1
if __name__ == "__main__":
unittest.main()