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
"""'Interaction' test for grammatista
26
It creates a new database, and inserts the definition for
27
Lithuanian. Then you get to do some exercises.
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
from grammatista import Grammatista
58
from grammatista.exercise import IExercise
61
lithuanian = gram.getLanguage(u'Lietuvių')
62
noun = lithuanian.getWordCategory('Noun')
63
while True and noun.exerciseDefinitions:
64
for definition in noun.exerciseDefinitions:
65
exercise = IExercise(definition)
66
print '("%s" (%s): ' % (
68
",".join([object.label
69
for object in exercise.inflectionForm.objects])),
70
answer = sys.stdin.readline().strip()
71
if exercise.checkAnswer(answer):
72
print "Correct answer."
74
print "Wrong answer, correct was: '%s'" % (
75
exercise.correctAnswer,)
80
if __name__ == "__main__":