1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# Copyright (c) 2004 Bjorn Tillenius
7
# This file is part of Grammatista.
9
# Grammatista is free software; you can redistribute it and/or modify
10
# it under the terms of the GNU General Public License as published by
11
# the Free Software Foundation; either version 2 of the License, or
12
# (at your option) any later version.
14
# Grammatista is distributed in the hope that it will be useful,
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
# GNU General Public License for more details.
19
# You should have received a copy of the GNU General Public License
20
# along with Grammatista; if not, write to the Free Software
21
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
##############################################################################
24
"""Functional test for grammatista
26
It creates a new database, and inserts the definition for
27
Lithuanian. Then it test some things.
39
"""Sets up everything before the tests are run."""
40
# First add 'utilities' and 'lang' to sys path
42
for libdir in ('utilities', 'lang'):
43
path = os.path.join(cwd, libdir)
44
sys.path.insert(0, path)
49
# Then create the database
52
# And finally define Lithuanian
53
lithuanian.main(args=('-t',))
55
def main(args=sys.argv[1:], stdout=sys.stdout, stderr=sys.stderr):
57
print "Running tests...",
58
gram = grammatista.Grammatista()
59
lithuanian = gram.getLanguage(u'Lietuvių')
60
assert lithuanian.label == u'Lietuvių'
62
noun = lithuanian.getWordCategory(u'Noun')
63
assert noun.label == 'Noun'
65
nom_sing = noun.getInflectionForm(u'Nominative', u'Singular')
66
gen_sing = noun.getInflectionForm(u'Genitive', u'Singular')
67
dat_sing = noun.getInflectionForm(u'Dative', u'Singular')
68
acc_sing = noun.getInflectionForm(u'Accusative', u'Singular')
69
inst_sing = noun.getInflectionForm(u'Instrumental', u'Singular')
70
loc_sing = noun.getInflectionForm(u'Locative', u'Singular')
71
voc_sing = noun.getInflectionForm(u'Vocative', u'Singular')
73
nom_plur = noun.getInflectionForm('Nominative', 'Plural')
74
gen_plur = noun.getInflectionForm('Genitive', 'Plural')
75
dat_plur = noun.getInflectionForm('Dative', 'Plural')
76
acc_plur = noun.getInflectionForm('Accusative', 'Plural')
77
inst_plur = noun.getInflectionForm('Instrumental', 'Plural')
78
loc_plur = noun.getInflectionForm('Locative', 'Plural')
79
voc_plur = noun.getInflectionForm('Vocative', 'Plural')
81
namas = noun.getWord(u'namas')
82
assert namas[nom_sing] == u'namas'
83
assert namas[gen_sing] == u'namo'
84
assert namas[dat_sing] == u'namui'
85
assert namas[acc_sing] == u'namą'
86
assert namas[inst_sing] == u'namu'
87
assert namas[loc_sing] == u'name'
88
assert namas[voc_sing] == u'name'
90
assert namas[nom_plur] == u'namai'
91
assert namas[gen_plur] == u'namų'
92
assert namas[dat_plur] == u'namams'
93
assert namas[acc_plur] == u'namus'
94
assert namas[inst_plur] == u'namais'
95
assert namas[loc_plur] == u'namuose'
96
assert namas[voc_plur] == u'namai'
98
namas = noun.getWord('kelias')
99
assert namas[nom_sing] == u'kelias'
100
assert namas[gen_sing] == u'kelio'
101
assert namas[dat_sing] == u'keliui'
102
assert namas[acc_sing] == u'kelią'
103
assert namas[inst_sing] == u'keliu'
104
assert namas[loc_sing] == u'kelyje'
105
assert namas[voc_sing] == u'keli'
107
assert namas[nom_plur] == u'keliai'
108
assert namas[gen_plur] == u'kelių'
109
assert namas[dat_plur] == u'keliams'
110
assert namas[acc_plur] == u'kelius'
111
assert namas[inst_plur] == u'keliais'
112
assert namas[loc_plur] == u'keliuose'
113
assert namas[voc_plur] == u'keliai'
115
namas = noun.getWord('brolis')
116
assert namas[nom_sing] == u'brolis'
117
assert namas[gen_sing] == u'brolio'
118
assert namas[dat_sing] == u'broliui'
119
assert namas[acc_sing] == u'brolį'
120
assert namas[inst_sing] == u'broliu'
121
assert namas[loc_sing] == u'brolyje'
122
assert namas[voc_sing] == u'broli'
124
assert namas[nom_plur] == u'broliai'
125
assert namas[gen_plur] == u'brolių'
126
assert namas[dat_plur] == u'broliams'
127
assert namas[acc_plur] == u'brolius'
128
assert namas[inst_plur] == u'broliais'
129
assert namas[loc_plur] == u'broliuose'
130
assert namas[voc_plur] == u'broliai'
132
namas = noun.getWord('kambarys')
133
assert namas[nom_sing] == u'kambarys'
134
assert namas[gen_sing] == u'kambario'
135
assert namas[dat_sing] == u'kambariui'
136
assert namas[acc_sing] == u'kambarį'
137
assert namas[inst_sing] == u'kambariu'
138
assert namas[loc_sing] == u'kambaryje'
139
assert namas[voc_sing] == u'kambary'
141
assert namas[nom_plur] == u'kambariai'
142
assert namas[gen_plur] == u'kambarių'
143
assert namas[dat_plur] == u'kambariams'
144
assert namas[acc_plur] == u'kambarius'
145
assert namas[inst_plur] == u'kambariais'
146
assert namas[loc_plur] == u'kambariuose'
147
assert namas[voc_plur] == u'kambariai'
153
if __name__ == "__main__":