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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
|
--1 A Simple German Resource Morphology
--
-- Aarne Ranta 2002
--
-- This resource morphology contains definitions needed in the resource
-- syntax. It moreover contains the most usual inflectional patterns.
--
-- We use the parameter types and word classes defined in $types.Deu.gf$.
resource Morpho = Types ** open (Predef=Predef), Prelude in {
--2 Nouns
--
-- For conciseness and abstraction, we define a method for
-- generating a case-dependent table from a list of four forms.
oper
caselist : (_,_,_,_ : Str) -> Case => Str = \n,a,d,g -> table {
Nom => n ; Acc => a ; Dat => d ; Gen => g} ;
-- The *worst-case macro* for common nouns needs six forms: all plural forms
-- are always the same except for the dative.
mkNoun : (_,_,_,_,_,_ : Str) -> Gender -> CommNoun =
\mann, mannen, manne, mannes, männer, männern, g -> {s = table {
Sg => caselist mann mannen manne mannes ;
Pl => caselist männer männer männern männer
} ; g = g} ;
-- But we never need all the six forms at the same time. Often
-- we need just two, three, or four forms.
mkNoun4 : (_,_,_,_ : Str) -> Gender -> CommNoun = \kuh,kuhes,kühe,kühen ->
mkNoun kuh kuh kuh kuhes kühe kühen ;
mkNoun3 : (_,_,_ : Str) -> Gender -> CommNoun = \kuh,kühe,kühen ->
mkNoun kuh kuh kuh kuh kühe kühen ;
mkNoun2n : (_,_ : Str) -> Gender -> CommNoun = \zahl, zahlen ->
mkNoun3 zahl zahlen zahlen ;
mkNoun2es : (_,_ : Str) -> Gender -> CommNoun = \wort, wörter ->
mkNoun wort wort wort (wort + "es") wörter (wörter + "n") ;
mkNoun2s : (_,_ : Str) -> Gender -> CommNoun = \vater, väter ->
mkNoun vater vater vater (vater + "s") väter (väter + "n") ;
mkNoun2ses : (_,_ : Str) -> Gender -> CommNoun = \wort,wörter ->
mkNoun wort wort wort (wort + variants {"es" ; "s"}) wörter (wörter + "n") ;
-- Here are the school grammar declensions with their commonest variations.
-- Unfortunately we cannot define *Umlaut* in GF, but have to give two forms.
--
-- First declension, with plural "en"/"n", including weak masculins:
declN1 : Str -> CommNoun = \zahl ->
mkNoun2n zahl (zahl + "en") Fem ;
declN1e : Str -> CommNoun = \stufe ->
mkNoun2n stufe (stufe + "n") Fem ;
declN1M : Str -> CommNoun = \junge -> let {jungen = junge + "n"} in
mkNoun junge jungen jungen jungen jungen jungen Masc ;
declN1eM : Str -> CommNoun = \soldat -> let {soldaten = soldat + "en"} in
mkNoun soldat soldaten soldaten soldaten soldaten soldaten Masc ;
-- Second declension, with plural "e":
declN2 : Str -> CommNoun = \punkt ->
mkNoun2es punkt (punkt+"e") Masc ;
declN2i : Str -> CommNoun = \onkel ->
mkNoun2s onkel onkel Masc ;
declN2u : (_,_ : Str) -> CommNoun = \raum,räume ->
mkNoun2es raum räume Masc ;
declN2uF : (_,_ : Str) -> CommNoun = \kuh,kühe ->
mkNoun3 kuh kühe (kühe + "n") Fem ;
-- Third declension, with plural "er":
declN3 : Str -> CommNoun = \punkt ->
mkNoun2es punkt (punkt+"er") Neut ;
declN3u : (_,_ : Str) -> CommNoun = \buch,bücher ->
mkNoun2ses buch bücher Neut ;
declN3uS : (_,_ : Str) -> CommNoun = \haus,häuser ->
mkNoun2es haus häuser Neut ;
-- Plural with "s":
declNs : Str -> CommNoun = \restaurant ->
mkNoun3 restaurant (restaurant+"s") (restaurant+"s") Neut ;
--2 Pronouns
--
-- Here we define personal and relative pronouns.
-- All personal pronouns, except "ihr", conform to the simple
-- pattern $mkPronPers$.
ProPN = {s : NPForm => Str ; n : Number ; p : Person} ;
mkPronPers : (_,_,_,_,_ : Str) -> Number -> Person -> ProPN =
\ich,mich,mir,meines,mein,n,p -> {
s = table {
NPCase c => caselist ich mich mir meines ! c ;
NPPoss gn c => mein + pronEnding ! gn ! c
} ;
n = n ;
p = p
} ;
pronEnding : GenNum => Case => Str = table {
GSg Masc => caselist "" "en" "em" "es" ;
GSg Fem => caselist "e" "e" "er" "er" ;
GSg Neut => caselist "" "" "em" "es" ;
GPl => caselist "e" "e" "en" "er"
} ;
pronIch = mkPronPers "ich" "mich" "mir" "meines" "mein" Sg P1 ;
pronDu = mkPronPers "du" "dich" "dir" "deines" "dein" Sg P2 ;
pronEr = mkPronPers "er" "ihn" "ihm" "seines" "sein" Sg P3 ;
pronSie = mkPronPers "sie" "sie" "ihr" "ihres" "ihr" Sg P3 ;
pronEs = mkPronPers "es" "es" "ihm" "seines" "sein" Sg P3 ;
pronWir = mkPronPers "wir" "uns" "uns" "unser" "unser" Pl P1 ;
pronSiePl = mkPronPers "sie" "sie" "ihnen" "ihrer" "ihr" Pl P3 ;
pronSSie = mkPronPers "Sie" "Sie" "Ihnen" "Ihrer" "Ihr" Pl P3 ; ---
-- We still have wrong agreement with the complement of the polite "Sie":
-- it is in plural, like the verb, although it should be in singular.
-- The peculiarity with "ihr" is the presence of "e" in forms without an ending.
pronIhr =
{s = table {
NPPoss (GSg Masc) Nom => "euer" ;
NPPoss (GSg Neut) Nom => "euer" ;
NPPoss (GSg Neut) Acc => "euer" ;
pf => (mkPronPers "ihr" "euch" "euch" "euer" "eur" Pl P2).s ! pf
} ;
n = Pl ;
p = P2
} ;
-- Relative pronouns are like the definite article, except in the genitive and
-- the plural dative. The function $artDef$ will be defined right below.
RelPron : Type = {s : GenNum => Case => Str} ;
relPron : RelPron = {s = \\gn,c =>
case <gn,c> of {
<GSg Fem,Gen> => "deren" ;
<GSg g,Gen> => "dessen" ;
<GPl,Dat> => "denen" ;
<GPl,Gen> => "deren" ;
_ => artDef ! gn ! c
}
} ;
--2 Articles
--
-- Here are all forms the indefinite and definite article.
-- The indefinite article is like a large class of pronouns.
-- The definite article is more peculiar; we don't try to
-- subsume it to any general rule.
artIndef : Gender => Case => Str = \\g,c => "ein" + pronEnding ! GSg g ! c ;
artDef : GenNum => Case => Str = table {
GSg Masc => caselist "der" "den" "dem" "des" ;
GSg Fem => caselist "die" "die" "der" "der" ;
GSg Neut => caselist "das" "das" "dem" "des" ;
GPl => caselist "die" "die" "den" "der"
} ;
--2 Adjectives
--
-- As explained in $types.Deu.gf$, it
-- would be superfluous to use the cross product of gender and number,
-- since there is no gender distinction in the plural. But it is handy to have
-- a function that constructs gender-number complexes.
gNumber : Gender -> Number -> GenNum = \g,n ->
case n of {
Sg => GSg g ;
Pl => GPl
} ;
-- It's also handy to have a function that finds out the number from such a complex.
numGenNum : GenNum -> Number = \gn ->
case gn of {
GSg _ => Sg ;
GPl => Pl
} ;
-- This function costructs parameters in the complex type of adjective forms.
aMod : Adjf -> Gender -> Number -> Case -> AForm = \a,g,n,c ->
AMod a (gNumber g n) c ;
-- The worst-case macro for adjectives (positive degree) only needs
-- two forms.
mkAdjective : (_,_ : Str) -> Adjective = \böse,bös -> {s = table {
APred => böse ;
AMod Strong (GSg Masc) c =>
caselist (bös+"er") (bös+"en") (bös+"em") (bös+"es") ! c ;
AMod Strong (GSg Fem) c =>
caselist (bös+"e") (bös+"e") (bös+"er") (bös+"er") ! c ;
AMod Strong (GSg Neut) c =>
caselist (bös+"es") (bös+"es") (bös+"em") (bös+"es") ! c ;
AMod Strong GPl c =>
caselist (bös+"e") (bös+"e") (bös+"en") (bös+"er") ! c ;
AMod Weak (GSg g) c => case <g,c> of {
<_,Nom> => bös+"e" ;
<Masc,Acc> => bös+"en" ;
<_,Acc> => bös+"e" ;
_ => bös+"en" } ;
AMod Weak GPl c => bös+"en"
}} ;
-- Here are some classes of adjectives:
adjReg : Str -> Adjective = \gut -> mkAdjective gut gut ;
adjE : Str -> Adjective = \bös -> mkAdjective (bös+"e") bös ;
adjEr : Str -> Adjective = \teu -> mkAdjective (teu+"er") (teu+"r") ;
adjInvar : Str -> Adjective = \prima -> {s = table {_ => prima}} ;
-- The first three classes can be recognized from the end of the word, depending
-- on if it is "e", "er", or something else.
adjGen : Str -> Adjective = \gut -> let {
er = Predef.dp 2 gut ;
teu = Predef.tk 2 gut ;
e = Predef.dp 1 gut ;
bös = Predef.tk 1 gut
} in
ifTok Adjective er "er" (adjEr teu) (
ifTok Adjective e "e" (adjE bös) (
(adjReg gut))) ;
-- The comparison of adjectives needs three adjectives in the worst case.
mkAdjComp : (_,_,_ : Adjective) -> AdjComp = \gut,besser,best ->
{s = table {Pos => gut.s ; Comp => besser.s ; Sup => best.s}} ;
-- It can be done by just three strings, if each of the comparison
-- forms taken separately is a regular adjective.
adjCompReg3 : (_,_,_ : Str) -> AdjComp = \gut,besser,best ->
mkAdjComp (adjReg gut) (adjReg besser) (adjReg best) ;
-- If also the comparison forms are regular, one string is enough.
adjCompReg : Str -> AdjComp = \billig ->
adjCompReg3 billig (billig+"er") (billig+"st") ;
--2 Verbs
--
-- We limit ourselves to verbs in present tense infinitive, indicative,
-- and imperative, and past participle. Other forms will be introduced later.
--
-- The worst-case macro needs three forms: the infinitive, the third person
-- singular indicative, and the second person singular imperative.
-- We take care of the special cases "ten", "sen", "ln", "rn".
--
-- A famous law about Germanic languages says that plural first and third person
-- are similar.
mkVerbum : (_,_,_,_ : Str) -> Verbum = \geben, gib, gb, gegeben ->
let {
en = Predef.dp 2 geben ;
geb = ifTok Tok (Predef.tk 1 en) "e" (Predef.tk 2 geben)(Predef.tk 1 geben) ;
gebt = ifTok Tok (Predef.dp 1 geb) "t" (geb + "et") (geb + "t") ;
gibst = ifTok Tok (Predef.dp 1 gib) "s" (gib + "t") (gib + "st") ;
gegebener = (adjReg gegeben).s
} in table {
VInf => geben ;
VInd Sg P1 => geb + "e" ;
VInd Sg P2 => gibst ;
VInd Sg P3 => gib + "t" ;
VInd Pl P2 => gebt ;
VInd Pl _ => geben ; -- the famous law
VImp Sg => gb ;
VImp Pl => gebt ;
VPart a => gegebener ! a
} ;
-- Regular verbs:
regVerb : Str -> Verbum = \legen ->
let {lege = ifTok Tok (Predef.dp 3 legen) "ten" (Predef.tk 1 legen) (
ifTok Tok (Predef.dp 2 legen) "en" (Predef.tk 2 legen) (
Predef.tk 1 legen))} in
mkVerbum legen lege lege ("ge" + (lege + "t")) ;
-- Verbs ending with "t"; now recognized in $mkVerbum$.
verbWarten : Str -> Verbum = regVerb ;
-- Verbs with Umlaut in the second and third person singular and imperative:
verbSehen : Str -> Str -> Str -> Verbum = \sehen, sieht, gesehen ->
let {sieh = Predef.tk 1 sieht} in mkVerbum sehen sieh sieh gesehen ;
-- Verbs with Umlaut in the second and third person singular but not imperative:
verbLaufen : Str -> Str -> Str -> Verbum = \laufen, läuft, gelaufen ->
let {läuf = Predef.tk 1 läuft ; laufe = Predef.tk 1 laufen}
in mkVerbum laufen läuf laufe gelaufen ;
-- The verb "be":
verbumSein : Verbum = let {
gewesen = (adjReg "gewesen").s
} in
table {
VInf => "sein" ;
VInd Sg P1 => "bin" ;
VInd Sg P2 => "bist" ;
VInd Sg P3 => "ist" ;
VInd Pl P2 => "seid" ;
VInd Pl _ => "sind" ;
VImp Sg => "sei" ;
VImp Pl => "seiet" ;
VPart a => gewesen ! a
} ;
-- The verb "have":
verbumHaben : Verbum = let {
haben = (regVerb "haben")
} in
table {
VInd Sg P2 => "hast" ;
VInd Sg P3 => "hat" ;
v => haben ! v
} ;
-- The verb "become", used as the passive auxiliary:
verbumWerden : Verbum = let {
werden = regVerb "werden" ;
geworden = (adjReg "geworden").s
} in
table {
VInd Sg P2 => "wirst" ;
VInd Sg P3 => "wird" ;
VPart a => geworden ! a ;
v => werden ! v
} ;
-- A *full verb* ($Verb$) consists of the inflection forms ($Verbum$) and
-- a *particle* (e.g. "aus-sehen"). Simple verbs are the ones that have no
-- such particle.
mkVerb : Verbum -> Particle -> Verb = \v,p -> {s = v ; s2 = p} ;
mkVerbSimple : Verbum -> Verb = \v -> mkVerb v [] ;
verbSein = mkVerbSimple verbumSein ;
verbHaben = mkVerbSimple verbumHaben ;
verbWerden = mkVerbSimple verbumWerden ;
{-
-- tests for optimizer
verbumSein2 : Verbum =
table {
VInf => "sein" ;
VInd Sg P1 => "bin" ;
VInd Sg P2 => "bist" ;
VInd Sg P3 => "ist" ;
VInd Pl P2 => "seid" ;
VInd Pl _ => "sind" ;
VImp Sg => "sei" ;
VImp Pl => "seiet" ;
VPart a => (adjReg "gewesen").s ! a
} ;
verbumHaben2 : Verbum =
table {
VInd Sg P2 => "hast" ;
VInd Sg P3 => "hat" ;
v => regVerb "haben" ! v
} ;
-}
} ;
|