forked from GrammaticalFramework/gf-wordnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathParseExtendBul.gf
362 lines (310 loc) · 14.2 KB
/
ParseExtendBul.gf
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
concrete ParseExtendBul of ParseExtend =
ExtendBul - [iFem_Pron, youPolFem_Pron, weFem_Pron, youPlFem_Pron, theyFem_Pron, GenNP, DetNPMasc, DetNPFem, FocusAP,
CompVP, InOrderToVP, PurposeVP, ComplGenVV, ReflRNP, ProDrop, UncontractedNeg, AdvIsNPAP, ExistCN, NominalizeVPSlashNP], NumeralBul - [num], PunctuationX ** open Predef, Prelude, ResBul, GrammarBul, ParadigmsBul in {
lin gen_Quant = DefArt ;
UttAP ap = {s = ap.s ! ASg Neut Indef ! P3} ;
UttAPMasc ap = {s = ap.s ! ASg Masc Indef ! P3} ;
UttAPFem ap = {s = ap.s ! ASg Fem Indef ! P3} ;
UttVPS p vps = {s = vps.s ! personAgr p.gn p.p} ;
PhrUttMark pconj utt voc mark = {s = pconj.s ++ utt.s ++ voc.s ++ SOFT_BIND ++ mark.s} ;
AdvRNP np prep rnp = {s = \\role => np.s ! role ++ prep.s ++ rnp.s ! RObj prep.c; gn = np.gn; p = np.p} ;
AdvRVP vp prep rnp = insertObj (\\a => prep.s ++ rnp.s ! RObj prep.c) Pos vp ;
AdvRAP ap prep rnp = {
s = \\aform,p => ap.s ! aform ! p ++ prep.s ++ rnp.s ! RObj prep.c ;
isPre = False
} ;
PossPronRNP pron num cn rnp = DetCN (DetQuant (PossPron pron) num) (PossNP cn (lin NP {s = rnp.s; gn = rnp.gn; p=NounP3 Pos})) ;
lin FocusComp comp np =
mkClause (comp.s ! personAgr np.gn np.p) np.gn (NounP3 comp.p)
(insertObj (\\_ => np.s ! RSubj) (personPol np.p) (predV verbBe)) ;
lincat [Comp] = {s : Agr => Ints 4 => Str} ;
lin BaseComp x y =
{s = \\agr=>table {4 => y.s!agr; _ => x.s!agr}} ;
ConsComp x xs =
{s = \\agr=>table {4 => xs.s!agr!4; t => x.s!agr++linCoord bindComma!t++xs.s!agr!t}} ;
ConjComp conj ss = {
s = \\agr => linCoord [] ! conj.sep ++ ss.s!agr!conj.sep ++ conj.s ++ ss.s!agr!4 ;
p = Pos
} ;
lincat CNN = {s : Species => Role => Ints 4 => Str ; n1,n : NNumber ; g1 : AGender; nonEmpty : Bool} ;
lin BaseCNN num1 cn1 num2 cn2 =
let mknf : NNumber -> Species -> Role -> AGender -> NForm =
\nn,spec,role,g ->
case <nn,spec> of {
<NNum Sg,Def> => case role of {
RSubj => NFSgDefNom ;
RVoc => NFVocative ;
_ => NF Sg Def
} ;
<NNum Sg,Indef> => case role of {
RVoc => NFVocative ;
_ => NF Sg Indef
} ;
<NNum Pl,Def> => NF Pl Def ;
<NNum Pl,Indef> => NF Pl Indef;
<NCountable,Def> => NF Pl spec ;
<NCountable,Indef> => case g of {
AMasc Human => NF Pl Indef;
_ => NFPlCount
}
} ;
in { s = \\spec,role => table {4 => num2.s ! dgenderSpecies cn2.g spec role ++ cn2.s ! mknf num2.nn spec role cn2.g ;
_ => num1.s ! dgenderSpecies cn1.g spec role ++ cn1.s ! mknf num1.nn spec role cn1.g
} ;
n1 = num1.nn ;
n = num1.nn ;
g1 = cn1.g ;
nonEmpty = num1.nonEmpty
} ;
DetCNN quant conj cnn =
{ s = \\role =>
let spec = case cnn.nonEmpty of {True=>Indef; _=>quant.spec} ;
s = quant.s ! True ! aform (gennum cnn.g1 (numnnum cnn.n)) (case role of {RVoc=>Indef; _=>Def}) role ++
linCoord [] ! conj.sep ++ cnn.s ! spec ! role ! conj.sep ++ conj.s ++ cnn.s ! spec ! role ! 4
in case role of {
RObj c => linCase c quant.p ++ s;
_ => s
} ;
gn = gennum cnn.g1 (numnnum cnn.n);
p = NounP3 quant.p
} ;
ReflPossCNN conj cnn = {
s = \\role => reflPron ! aform (gennum cnn.g1 (numnnum cnn.n1)) Def (RObj Acc) ++
cnn.s ! Def ! role ! conj.sep ++ conj.s ++ cnn.s ! Def ! role ! 4 ;
gn = gennum cnn.g1 (numnnum cnn.n)
} ;
PossCNN_RNP quant conj cnn rnp =
{ s = \\role =>
let spec = case cnn.nonEmpty of {True=>Indef; _=>quant.spec} ;
s = quant.s ! True ! aform (gennum cnn.g1 (numnnum cnn.n)) (case role of {RVoc=>Indef; _=>Def}) role ++
cnn.s ! spec ! role ! conj.sep ++ conj.s ++ cnn.s ! spec ! role ! 4 ++
"на" ++ rnp.s ! (RObj CPrep)
in case role of {
RObj c => linCase c quant.p ++ s;
_ => s
} ;
gn = gennum cnn.g1 (numnnum cnn.n)
} ;
lin NumMore num = {s = \\cf => "още" ++ num.s ! cf ; nn = NNum Pl ; nonEmpty = True} ;
NumLess num = {s = \\cf => num.s ! cf ++ "по-малко" ; nn = NNum Pl ; nonEmpty = True} ;
lin UseACard card =
{s = table { CFMasc spec _ => card.s ! spec;
CFMascDefNom _ => card.s ! Def;
CFFem spec => card.s ! spec;
CFNeut spec => card.s ! spec
};
nn = card.nn
};
UseAdAACard ada card =
{s = table { CFMasc spec _ => ada.s ++ card.s ! spec;
CFMascDefNom _ => ada.s ++ card.s ! Def;
CFFem spec => ada.s ++ card.s ! spec;
CFNeut spec => ada.s ++ card.s ! spec
};
nn = card.nn
};
lin RelNP = GrammarBul.RelNP ;
ExtRelNP np rs = {
s = \\role => case role of {
RObj c => linCase c (personPol np.p) ++ np.s ! RObj CPrep ;
role => np.s ! role
} ++ bindComma ++ rs.s ! personAgr np.gn np.p ;
gn = np.gn ;
p = NounP3 (personPol np.p)
} ;
lin BareN2 n2 = n2 ;
lin ComparAdv pol cadv adv comp = {
s = pol.s ++ case pol.p of {Pos => []; Neg => "не"} ++ cadv.s ++ adv.s ++ cadv.p ++ comp.s ! agrP3 (GSg Neut)
} ;
CAdvAP pol cadv ap comp = {
s = \\a,p => pol.s ++ case pol.p of {Pos => []; Neg => "не"} ++ cadv.s ++ ap.s ! a ! p ++ cadv.p ++ comp.s ! agrP3 (GSg Neut) ;
isPre = False
} ;
AdnCAdv pol cadv = {s = pol.s ++ case pol.p of {Pos => []; Neg => "не"} ++ cadv.s ++ cadv.p} ;
EnoughAP a ant pol vp = {
s = \\aform,p => let gn = case aform of {
ASg g _ => GSg g ;
ASgMascDefNom => GSg Masc ;
APl _ => GPl
}
in "достатъчно" ++ a.s ! aform ! p ++ ant.s ++ pol.s ++ daComplex ant.a (orPol pol.p vp.p) vp ! Perf ! {gn=gn; p=p} ;
isPre = False
} ;
EnoughAdv adv = {
s = "достатъчно" ++ adv.s
} ;
ExtAdvAP ap adv = {
s = \\aform,p => ap.s ! aform ! p ++ bindComma ++ adv.s ;
isPre = False
} ;
lin TimeNP np = {s = np.s ! RObj CPrep} ;
lin AdvAdv adv1 adv2 = {s=adv1.s ++ adv2.s} ;
lin UseDAP dap = {
s = \\role => let s = dap.s ! False ! ANeut ! role
in case role of {
RObj c => linCase c dap.p ++ s;
_ => s
} ;
gn = gennum ANeut (numnnum dap.nn);
p = NounP3 dap.p
} ;
UseDAPMasc dap = {
s = \\role => let s = dap.s ! False ! (AMasc Human) ! role
in case role of {
RObj c => linCase c dap.p ++ s;
_ => s
} ;
gn = gennum (AMasc Human) (numnnum dap.nn);
p = NounP3 dap.p
} ;
UseDAPFem dap = {
s = \\role => let s = dap.s ! False ! AFem ! role
in case role of {
RObj c => linCase c dap.p ++ s;
_ => s
} ;
gn = gennum AFem (numnnum dap.nn);
p = NounP3 dap.p
} ;
lin AdvImp adv imp = {
s = \\pol,gennum => adv.s ++ imp.s ! pol ! gennum
} ;
lin whatSgFem_IP = mkIP "каква" "каква" (GSg Fem) ;
whatSgNeut_IP = mkIP "какво" "какво" (GSg Neut) ;
lin that_RP = IdRP ;
lin EmbedVP ant pol p vp = {s = ant.s ++ pol.s ++ daComplex ant.a (orPol pol.p vp.p) vp ! Perf ! personAgr p.gn p.p} ;
ComplVV vv ant pol vp =
insertObj (\\agr => ant.s ++ pol.s ++
case vv.typ of {
VVInf asp => daComplex ant.a pol.p vp ! asp ! agr;
VVGerund => gerund vp ! Imperf ! agr
}) vp.p
(predV vv) ;
SlashVV vv ant pol slash = {
s = vv.s ;
ad = {isEmpty=True; s=[]};
clitics = [] ;
compl1 = \\agr => ant.s ++ pol.s ++ daComplex ant.a pol.p {s=slash.s; ad=slash.ad; clitics=slash.clitics; compl=slash.compl1; vtype=slash.vtype; p = Pos; isSimple = slash.isSimple} ! Perf ! agr ;
compl2 = slash.compl2 ;
vtype = vv.vtype ;
p = slash.p ;
c2 = slash.c2 ;
isSimple = False ;
subjCtrl = slash.subjCtrl
} ;
SlashV2V vv ant pol vp =
insertSlashObj2 (\\agr => ant.s ++ pol.s ++ vv.c3.s ++ daComplex ant.a (orPol pol.p vp.p) vp ! Perf ! agr) Pos (slashV vv vv.c2 vv.subjCtrl) ;
SlashV2VNP vv np ant pol slash = {
s = vv.s ;
ad = {isEmpty=True; s=[]};
clitics = [] ;
compl1 = \\agr => ant.s ++ pol.s ++ vv.c2.s ++ np.s ! RObj vv.c2.c ++
daComplex ant.a (orPol pol.p (personPol np.p)) {s=slash.s; ad=slash.ad; clitics=slash.clitics; compl=slash.compl1; vtype=slash.vtype; p=Pos; isSimple = slash.isSimple} ! Perf ! personAgr np.gn np.p ;
compl2 = slash.compl2 ;
vtype = vv.vtype ;
p = Pos ;
c2 = slash.c2 ;
isSimple = False ;
subjCtrl = slash.subjCtrl
} ;
InOrderToVP ant pol p vp =
{s = "за" ++ ant.s ++ pol.s ++ daComplex ant.a pol.p vp ! Perf ! personAgr p.gn p.p};
CompVP ant pol p vp = {s = \\agr => ant.s ++ pol.s ++ daComplex ant.a pol.p vp ! Perf ! personAgr p.gn p.p; p = Pos} ;
UttVP ant pol p vp = {s = ant.s ++ pol.s ++ daComplex ant.a pol.p vp ! Perf ! personAgr p.gn p.p} ;
ReflA2 a rnp = {
s = \\aform,_ => a.s ! aform ++ a.c2.s ++ rnp.s ! RObj a.c2.c ;
isPre = False
} ;
ReflVPSlash slash rnp = {
s = slash.s ;
ad = slash.ad ;
clitics = slash.clitics ;
compl = \\a => slash.compl1 ! a ++ slash.c2.s ++ rnp.s ! RObj slash.c2.c ++ slash.compl2 ! agrP3 rnp.gn ;
vtype = slash.vtype ;
p = slash.p ;
isSimple = False
} ;
lin RecipVPSlash slash = {
s = slash.s ;
ad = slash.ad ;
clitics = slash.clitics ;
compl = \\a => slash.compl1 ! a ++ "един"++linPrep slash.c2++"друг" ++ slash.compl2 ! a ;
vtype = case slash.c2.c of {
Acc | Dat => VMedial slash.c2.c ;
_ => slash.vtype
} ;
p = slash.p ;
isSimple = False
} ;
RecipVPSlashCN slash cn = {
s = slash.s ;
ad = slash.ad ;
clitics = slash.clitics ;
compl = \\a => slash.compl1 ! a ++ linPrep slash.c2 ++ "един на друг" ++ cn.s ! NF Pl Def ++ slash.compl2 ! a ;
vtype = slash.vtype ;
p = slash.p ;
isSimple = False
} ;
lincat Sub1000000000 = {s : CardOrd => NumF => Str; n : Number} ;
lin pot3as4 n = n ;
pot4 n = {
s = \\o,f => case o of {
NCard cf => let cf : CardForm =
case cf of {
CFMasc spec _ => CFMasc spec NonHuman ;
CFMascDefNom _ => CFMascDefNom NonHuman ;
CFFem spec => CFMasc spec NonHuman ;
CFNeut spec => CFMasc spec NonHuman
}
in n.s ! NCard cf ! f ++ case n.n of {Sg => "милион"; Pl => "милиона"} ;
NOrd aform => let cf : CardForm =
case aform of {
ASg Masc spec => CFMasc spec NonHuman ;
ASgMascDefNom => CFMascDefNom NonHuman ;
ASg Fem spec => CFFem spec ;
ASg Neut spec => CFNeut spec ;
APl spec => CFNeut spec
}
in n.s ! NCard cf ! f ++ (mkA079 "милионен").s ! aform
} ;
n = Pl
} ;
pot4plus n1 n2 = {
s = \\o,f => (pot4 n1).s ! o ! f ++ "и" ++ n2.s ! o ! f;
n = Pl
} ;
pot21 = {
s = \\o,_ => mkCardOrd100 "сто" "стоте" "стотен" ! o ;
i = False ;
n = Pl
} ;
pot31 = {
s = \\o,_ => mkCardOrd100 "хиляда" "хилядата" "хиляден" ! o ;
n = Pl
} ;
pot41 = {
s = \\o,_ => case o of {
NCard (CFMasc Indef _) => "милион" ;
NCard (CFMasc Def _) => "единия милион" ;
NCard (CFMascDefNom _) => "единият милион" ;
NCard (CFFem Indef) => "милион" ;
NCard (CFFem Def) => "единия милион" ;
NCard (CFNeut Indef) => "милион" ;
NCard (CFNeut Def) => "единия милион" ;
NOrd aform => (mkA079 "милионен").s ! aform
};
n = Pl
} ;
num x = {s = \\c => x.s ! c ! Formal; n=x.n} ;
lincat ListImp = {s : Polarity => GenNum => Ints 4 => Str} ;
lin BaseImp x y =
{s = \\p,gn=>table {4 => y.s!p!gn; _ => x.s!p!gn}} ;
ConsImp x xs =
{s = \\p,gn=>table {4 => xs.s!p!gn!4; t => x.s!p!gn++linCoord bindComma!t++xs.s!p!gn!t}} ;
ConjImp conj ss = {
s = \\p,gn => linCoord [] ! conj.sep ++ ss.s!p!gn!conj.sep ++ conj.s ++ ss.s!p!gn!4
} ;
{-lin ProgrVPSlash vp = vp ** {
s = \\_ => vp.s ! Imperf
} ;-}
}