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
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
|
--# -path=.:../scandinavian:../common:../abstract:../../prelude
--1 Danish Lexical Paradigms
--
-- Aarne Ranta 2005 - 2006
--
-- This is an API for the user of the resource grammar
-- for adding lexical items. It gives functions for forming
-- expressions of open categories: nouns, adjectives, verbs.
--
-- Closed categories (determiners, pronouns, conjunctions) are
-- accessed through the resource syntax API, $Structural.gf$.
--
-- The main difference with $MorphoDan.gf$ is that the types
-- referred to are compiled resource grammar types. We have moreover
-- had the design principle of always having existing forms, rather
-- than stems, as string arguments of the paradigms.
--
-- The structure of functions for each word class $C$ is the following:
-- first we give a handful of patterns that aim to cover all
-- regular cases. Then we give a worst-case function $mkC$, which serves as an
-- escape to construct the most irregular words of type $C$.
-- However, this function should only seldom be needed: we have a
-- separate module [``IrregDan`` ../../danish/IrregDan.gf],
-- which haves a list of irregular verbs.
resource ParadigmsDan =
open
(Predef=Predef),
Prelude,
CommonScand,
ResDan,
MorphoDan,
CatDan in {
--2 Parameters
--
-- To abstract over gender names, we define the following identifiers.
oper
Gender : Type ;
utrum : Gender ;
neutrum : Gender ;
-- To abstract over number names, we define the following.
Number : Type ;
singular : Number ;
plural : Number ;
-- To abstract over case names, we define the following.
Case : Type ;
nominative : Case ;
genitive : Case ;
-- Prepositions used in many-argument functions are just strings.
mkPrep : Str -> Prep ;
noPrep : Prep ; -- empty string
--2 Nouns
mkN : overload {
-- The regular function takes the singular indefinite form
-- and computes the other forms and the gender by a heuristic.
-- The heuristic is that all nouns are $utrum$ with the
-- plural ending "er" or "r".
mkN : (bil : Str) -> N ;
-- Giving gender manually makes the heuristic more reliable.
mkN : (hus : Str) -> Gender -> N ;
-- This function takes the singular indefinite and definite forms; the
-- gender is computed from the definite form.
mkN : (bil,bilen : Str) -> N ;
-- This function takes the singular indefinite and definite and the plural
-- indefinite
mkN : (bil,bilen,biler : Str) -> N ;
-- Worst case: give all four forms. The gender is computed from the
-- last letter of the second form (if "n", then $utrum$, otherwise $neutrum$).
mkN : (dreng,drengen,drenge,drengene : Str) -> N ;
} ;
--3 Compound nouns
--
-- All the functions above work quite as well to form compound nouns,
-- such as "fodbold".
--3 Relational nouns
--
-- Relational nouns ("datter til x") need a preposition.
mkN2 : N -> Prep -> N2 ;
-- The most common preposition is "af", and the following is a
-- shortcut for regular relational nouns with "af".
regN2 : Str -> Gender -> N2 ;
-- Use the function $mkPrep$ or see the section on prepositions below to
-- form other prepositions.
--
-- Three-place relational nouns ("forbindelse fra x til y")
-- need two prepositions.
mkN3 : N -> Prep -> Prep -> N3 ;
--3 Relational common noun phrases
--
-- In some cases, you may want to make a complex $CN$ into a
-- relational noun (e.g. "tidligere kone til"). However, $N2$ and
-- $N3$ are purely lexical categories. But you can use the $AdvCN$
-- and $PrepNP$ constructions to build phrases like this.
--
--3 Proper names and noun phrases
--
-- Proper names, with a regular genitive, are formed as follows
mkPN : overload {
mkPN : Str -> PN ; -- utrum
mkPN : Str -> Gender -> PN ;
mkPN : N -> PN ;
} ;
--2 Adjectives
-- The regular pattern works for many adjectives, e.g. those ending
-- with "ig". Two, five, or at worst five forms are sometimes needed.
mkA : overload {
mkA : (fin : Str) -> A ;
mkA : (fin,fint : Str) -> A ;
mkA : (galen,galet,galne : Str) -> A ;
mkA : (stor,stort,store,storre,storst : Str) -> A ;
-- If comparison is formed by "mer", "mest", as in general for
-- long adjective, the following pattern is used:
mkA : A -> A ; -- -/mer/mest norsk
} ;
--3 Two-place adjectives
--
-- Two-place adjectives need a preposition for their second argument.
mkA2 : A -> Prep -> A2 ;
--2 Adverbs
-- Adverbs are not inflected. Most lexical ones have position
-- after the verb. Some can be close to the verb like the negation
-- "ikke" (e.g. "altid").
mkAdv : Str -> Adv ;
mkAdV : Str -> AdV ;
-- Adverbs modifying adjectives and sentences can also be formed.
mkAdA : Str -> AdA ;
--2 Verbs
--
mkV : overload {
-- The 'regular verb' function is the first conjugation.
mkV : (snakke : Str) -> V ;
-- The almost regular verb function needs the infinitive and the preteritum.
mkV : (leve,levde : Str) -> V ;
-- There is an extensive list of irregular verbs in the module $IrregDan$.
-- In practice, it is enough to give three forms, as in school books.
mkV : (drikke, drakk, drukket : Str) -> V ;
-- The worst case needs six forms.
mkV : (spise,spiser,spises,spiste,spist,spis : Str) -> V ;
--3 Verbs with a particle.
--
-- The particle, such as in "lukke op", is given as a string.
mkV : V -> Str -> V ;
} ;
--3 Verbs with 'være' as auxiliary
--
-- By default, the auxiliary is "have". This function changes it to "være".
vaereV : V -> V ;
--3 Deponent verbs
--
-- Some words are used in passive forms only, e.g. "undres", some as
-- reflexive e.g. "forestille sig".
depV : V -> V ;
reflV : V -> V ;
--3 Two-place verbs
--
-- Two-place verbs need a preposition, except the special case with direct object.
-- (transitive verbs). Notice that, if a particle is needed, it comes from the $V$.
mkV2 : overload {
mkV2 : Str -> V2 ;
mkV2 : V -> V2 ;
mkV2 : V -> Prep -> V2 ;
} ;
--3 Three-place verbs
--
-- Three-place (ditransitive) verbs need two prepositions, of which
-- the first one or both can be absent.
mkV3 : V -> Prep -> Prep -> V3 ; -- snakke, med, om
dirV3 : V -> Prep -> V3 ; -- give,_,til
dirdirV3 : V -> V3 ; -- give,_,_
--3 Other complement patterns
--
-- Verbs and adjectives can take complements such as sentences,
-- questions, verb phrases, and adjectives.
mkV0 : V -> V0 ;
mkVS : V -> VS ;
mkV2S : V -> Prep -> V2S ;
mkVV : V -> VV ;
mkV2V : V -> Prep -> Prep -> V2V ;
mkVA : V -> VA ;
mkV2A : V -> Prep -> V2A ;
mkVQ : V -> VQ ;
mkV2Q : V -> Prep -> V2Q ;
mkAS : A -> AS ;
mkA2S : A -> Prep -> A2S ;
mkAV : A -> AV ;
mkA2V : A -> Prep -> A2V ;
-- Notice: categories $AS, A2S, AV, A2V$ are just $A$,
-- and the second argument is given as an adverb..
-- $V0$ is just $V$.
V0 : Type ;
AS, A2S, AV, A2V : Type ;
--.
--2 Definitions of the paradigms
--
-- The definitions should not bother the user of the API. So they are
-- hidden from the document.
Gender = MorphoDan.Gender ;
Number = MorphoDan.Number ;
Case = MorphoDan.Case ;
utrum = Utr ;
neutrum = Neutr ;
singular = Sg ;
plural = Pl ;
nominative = Nom ;
genitive = Gen ;
Preposition : Type = Str ; -- obsolete
mkPreposition : Str -> Prep ; -- obsolete
mkPreposition = mkPrep ;
mkPrep p = {s = p ; lock_Prep = <>} ;
noPrep = mkPrep [] ;
mk4N x y z u = mkSubstantive x y z u ** {g = extNGen y ; lock_N = <>} ;
regN x = regGenN x Utr ;
regGenN x g = case last x of {
"e" => case g of {
Utr => mk4N x (x + "n") (x + "r") (x + "rne") ;
Neutr => mk4N x (x + "t") (x + "r") (init x + "ene")
} ;
_ => case g of {
Utr => mk4N x (x + "en") (x + "er") (x + "erne") ;
Neutr => mk4N x (x + "et") (x + "") (x + "ene")
}
} ;
mk2N x y = case last y of {
"n" => mk3N x y (init y + "r") ;
_ => mk3N x y x
} ;
mk3N x y z = let u = ifTok Str x z "ene" "ne" in mk4N x y z (z + u) ;
mkN2 = \n,p -> n ** {lock_N2 = <> ; c2 = mkComplement p.s} ;
regN2 n g = mkN2 (regGenN n g) (mkPreposition "av") ;
mkN3 = \n,p,q -> n ** {lock_N3 = <> ; c2 = mkComplement p.s ; c3 = mkComplement q.s} ;
mk2PN n g = {s = \\c => mkCase c n ; g = g} ** {lock_PN = <>} ;
regPN n = mk2PN n utrum ;
nounPN n = {s = n.s ! singular ! Indef ; g = n.g ; lock_PN = <>} ;
-- To form a noun phrase that can also be plural and have an irregular
-- genitive, you can use the worst-case function.
makeNP : Str -> Str -> Number -> Gender -> NP ;
makeNP x y n g =
{s = table {NPPoss _ => x ; _ => y} ; a = agrP3 g n ;
lock_NP = <>} ;
mk3A = mk3ADeg ;
mk2A a b = mk3A a b (a + "e") ;
regA a = (regADeg a) ** {lock_A = <>} ;
mkA2 a p = a ** {c2 = mkComplement p.s ; lock_A2 = <>} ;
mkADeg a b c d e = mkAdject a b c d e ** {isComp = False ; lock_A = <>} ;
regADeg a = case Predef.dp 2 a of {
"sk" => aRask a ;
_ => case last a of {
"t" => aAbstrakt a ;
_ => aRod a
}} ** {isComp = False ; lock_A = <>} ;
irregADeg a b c = mkAdject a (a + "t") (a + "e") b c **
{isComp = False ; lock_A = <>} ;
mk3ADeg a b c = mkAdject a b c (c + "re") (c + "st") **
{isComp = False ; lock_A = <>} ;
mk2ADeg a b = mkAdject a b (a + "e") (a + "ere") (a + "est") **
{isComp = False ; lock_A = <>} ;
compoundA adj = {s = adj.s ; isComp = True ; lock_A = <>} ;
mkAdv x = ss x ** {lock_Adv = <>} ;
mkAdV x = ss x ** {lock_AdV = <>} ;
mkAdA x = ss x ** {lock_AdA = <>} ;
mk6V a b c d e f = mkVerb6 a b c d e f **
{part = [] ; vtype = VAct ; lock_V = <> ; isVaere = False} ;
regV a = case last a of {
"e" => vHusk (init a) ;
_ => vBo a
} ** {part = [] ; vtype = VAct ; isVaere = False ; lock_V = <>} ;
mk2V a b = regVerb a b **
{part = [] ; vtype = VAct ; isVaere = False ; lock_V = <>} ;
irregV =
\drikke,drakk,drukket ->
let
drikk = case last drikke of {
"e" => init drikke ;
_ => drikke
} ;
drikker = case last (init drikke) of {
"r" => init drikke ;
_ => drikke + "r"
}
in
mk6V drikke drikker (drikke + "s") drakk drukket (mkImper drikk) ;
vaereV v = {
s = v.s ;
part = [] ;
vtype = v.vtype ;
isVaere = True ;
lock_V = <>
} ;
partV v p = {
s = v.s ;
part = p ;
vtype = v.vtype ;
isVaere = v.isVaere ;
lock_V = <>
} ;
depV v = {
s = v.s ; part = v.part ; vtype = VPass ; isVaere = False ; lock_V = <>
} ;
reflV v = {
s = v.s ; part = v.part ; vtype = VRefl ; isVaere = False ; lock_V = <>
} ;
mk2V2 v p = v ** {c2 = mkComplement p.s ; lock_V2 = <>} ;
dirV2 v = mk2V2 v (mkPrep []) ;
mkV3 v p q = v ** {c2 = mkComplement p.s ; c3 = mkComplement q.s ; lock_V3 = <>} ;
dirV3 v p = mkV3 v noPrep p ;
dirdirV3 v = dirV3 v noPrep ;
mkV0 v = v ** {lock_V0 = <>} ;
mkVS v = v ** {lock_VS = <>} ;
mkV2S v p = mk2V2 v p ** {lock_V2S = <>} ;
mkVV v = v ** {c2 = mkComplement "at" ; lock_VV = <>} ;
mkV2V v p t = mk2V2 v p ** {c3 = mkComplement "at" ; lock_V2V = <>} ;
mkVA v = v ** {lock_VA = <>} ;
mkV2A v p = mk2V2 v p ** {lock_V2A = <>} ;
mkVQ v = v ** {lock_VQ = <>} ;
mkV2Q v p = mk2V2 v p ** {lock_V2Q = <>} ;
mkAS v = v ** {lock_A = <>} ;
mkA2S v p = mkA2 v p ** {lock_A = <>} ;
mkAV v = v ** {lock_A = <>} ;
mkA2V v p = mkA2 v p ** {lock_A = <>} ;
V0 : Type = V ;
AS, A2S, AV : Type = A ;
A2V : Type = A2 ;
---------------
mkN = overload {
mkN : Str -> N = regN ;
mkN : Str -> Gender -> N = regGenN ;
mkN : (bil,bilen : Str) -> N = mk2N ;
mkN : (bil,bilen,biler : Str) -> N = mk3N ;
mkN : (dreng,drengen,drenge,drengene : Str) -> N = mk4N ;
} ;
regN : Str -> N ;
regGenN : Str -> Gender -> N ;
mk2N : (bil,bilen : Str) -> N ;
mk3N : (bil,bilen,biler : Str) -> N ;
mk4N : (dreng,drengen,drenge,drengene : Str) -> N ;
mkPN = overload {
mkPN : Str -> PN = regPN ; -- masculine
mkPN : Str -> Gender -> PN = mk2PN ;
mkPN : N -> PN = nounPN ;
} ;
regPN : Str -> PN ; -- utrum
mk2PN : Str -> Gender -> PN ;
nounPN : N -> PN ;
mkA = overload {
mkA : (fin : Str) -> A = regADeg ;
mkA : (fin,fint : Str) -> A = mk2ADeg ;
mkA : (galen,galet,galne : Str) -> A = mk3ADeg ;
mkA : (stor,stort,store,storre,storst : Str) -> A = mkADeg ;
mkA : A -> A = compoundA ; -- -/mer/mest norsk
} ;
mk3A : (galen,galet,galne : Str) -> A ;
regA : Str -> A ;
mk2A : (stor,stort : Str) -> A ;
mkADeg : (stor,stort,store,storre,storst : Str) -> A ;
regADeg : Str -> A ;
irregADeg : (tung,tyngre,tyngst : Str) -> A ;
mk3ADeg : (galen,galet,galne : Str) -> A ;
mk2ADeg : (bred,bredt : Str) -> A ;
compoundA : A -> A ; -- -/mer/mest norsk
mkV = overload {
mkV : (snakke : Str) -> V = regV ;
mkV : (leve,levde : Str) -> V = mk2V ;
mkV : (drikke, drakk, drukket : Str) -> V = irregV ;
mkV : (spise,spiser,spises,spiste,spist,spis : Str) -> V = mk6V ;
mkV : V -> Str -> V = partV ;
} ;
regV : (snakke : Str) -> V ;
mk2V : (leve,levde : Str) -> V ;
irregV : (drikke, drakk, drukket : Str) -> V ;
mk6V : (spise,spiser,spises,spiste,spist,spis : Str) -> V ;
partV : V -> Str -> V ;
mkV2 = overload {
mkV2 : Str -> V2 = \s -> dirV2 (regV s) ;
mkV2 : V -> V2 = dirV2 ;
mkV2 : V -> Prep -> V2 = mk2V2 ;
} ;
mk2V2 : V -> Prep -> V2 ;
dirV2 : V -> V2 ;
} ;
|