2 # -*- coding: utf-8 -*-
5 simple conjugation of regular dutch verbs
6 http://www.dutchgrammar.com/en/?n=Verbs.01
9 from optparse
import OptionParser
12 """generic verb methods"""
13 def __init__(self
, werkwoord
):
14 self
.werkwoord
= werkwoord
16 def extract_stam(self
):
17 """extracts the stem of the verb. only takes 3 rules into account."""
18 # een stam eindigt nooit op twee dezelfe medeklinkers
19 if self
.werkwoord
[-3] == self
.werkwoord
[-4]:
20 self
.stam
= self
.werkwoord
[:-3]
22 # de stam van een -iën werkwoord eindigt op `ie'
23 elif self
.werkwoord
[-4:] == "iën":
24 self
.stam
= self
.werkwoord
[:-3] + "e"
26 # een stam eindigt nooit op v of z
27 elif self
.werkwoord
[-3] == "v":
28 self
.stam
= self
.werkwoord
[:-3] + "f"
29 elif self
.werkwoord
[-3] == "z":
30 self
.stam
= self
.werkwoord
[:-3] + "s"
33 self
.stam
= self
.werkwoord
[:-2]
36 """writes out the conjugation to stdout"""
37 # this would take a list of words as an argument.
38 # it would then write out `pronomen - word' list.
39 # the Verbum class would have the pronomen as attributes.
42 class Presens(Verbum
):
43 """takes a verb and conjugates it in the present tense"""
45 """writes out the conjugated verb to stdout"""
46 pronomen_singularis
= ["ik", "jij/je", "u", "hij/zij/ze"]
47 pronomen_pluralis
= ["wij/we", "jullie", "zij/ze"]
49 for pronom
in pronomen_singularis
:
51 print "%s\t%s()" % (pronom
, self
.stam
)
53 print "%s\t%s(%s)" % (pronom
, self
.stam
, "t")
55 for pronom
in pronomen_pluralis
:
56 # bug re rule #1, try `pakken'
57 print "%s\t%s(%s)" % (pronom
, self
.stam
, "en")
59 if __name__
== "__main__":
61 gui
.add_option("-w", "--werkwoord", action
="store", dest
="werkwoord")
62 (options
, args
) = gui
.parse_args()
63 verbum
= Presens(options
.werkwoord
)
65 # simple sanity checks, the word `t' is not a verb :)
69 gui
.error("option -w, the verb needs more letters")
70 if verbum
.werkwoord
[-4:] != "iën":
71 if verbum
.werkwoord
[-2:] != "en":
72 gui
.error("option -w: the ending of the verb must be \"-en\"")
77 # vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4