-
Notifications
You must be signed in to change notification settings - Fork 11
/
ParseExtendPor.gf
143 lines (117 loc) · 3.96 KB
/
ParseExtendPor.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
concrete ParseExtendPor of ParseExtend =
ExtendPor - [iFem_Pron, youPolFem_Pron, weFem_Pron, youPlFem_Pron, theyFem_Pron, GenNP, DetNPMasc, DetNPFem, FocusAP, N2VPSlash, A2VPSlash,
CompVP, InOrderToVP, PurposeVP, ComplGenVV, ReflRNP, UncontractedNeg, AdvIsNPAP, ExistCN, NominalizeVPSlashNP,
PiedPipingQuestSlash, PiedPipingRelSlash], NumeralPor - [num], PunctuationX **
open Prelude, ResPor, MorphoPor, GrammarPor, (E = ExtraPor), Coordination, ExtendPor in {
lin
--^
gen_Quant = {
s = \\b,n,g,c => "" ;
s2 = "" ;
sp = \\n,g,c => artDef False g n c ;
spn = \\c => artDef False Masc Sg c ;
isNeg = False
} ;
UttAP p ap = {s = ap.s ! (genNum2Aform p.a.g p.a.n)} ;
UttVPS p vps= {s = vps.s ! Indic ! p.a ! True} ;
lin
PhrUttMark pconj utt voc mark = {s = pconj.s ++ utt.s ++ voc.s ++ SOFT_BIND ++ mark.s} ;
--^ RNP is not implemented yet in ExtendPor
--lin AdvRNP np prep rnp = rnp ;
lincat
-- True if digit
CNN = {s1 : Bool => Str ; s2 : Str; n1,n : Number; g1 : Gender} ;
lin
BaseCNN num1 cn1 num2 cn2 = {
s1 = \\d => num1.s ! cn1.g ++ cn1.s ! num1.n ;
s2 = num2.s ! cn2.g ++ cn2.s ! num2.n ;
n1 = num1.n ;
g1 = cn1.g ;
n = conjNumber num1.n num2.n ;
} ;
lin
NumLess n = {s = \\g => n.s ! g ++ "menos" ;
n = n.n ; -- shouldn't it be 2 - ?
isNum = n.isNum} ;
NumMore n = {s = \\g => n.s ! g ++ "mais" ;
n = n.n ; isNum = n.isNum } ;
lin
num x = x ;
lin
UseACard ac = {
s = \\_g => ac.s ;
n = Pl
} ;
UseAdAACard ada ac = {
s = \\_g => ada.s ;
n = Sg
} ;
lin
RelNP = GrammarPor.RelNP ;
ExtRelNP np rs = heavyNPpol np.isNeg {
s = \\c => (np.s ! c).ton ++ bindComma ++ rs.s ! Indic ! np.a ;
a = np.a ;
hasClit = False
} ;
lin ExtAdvAP ap adv = ap ** {
s = \\a => ap.s ! a ++ bindComma ++ adv.s
} ;
lin BareN2 n2 = n2 ;
lin
--TODO: test and probably correct use of comp in the following
--TODO: create oper for neg pattern
ComparAdv pol cadv adv comp = let
neg = (negation ! pol.p).p1
in {
s = pol.s ++ neg ++ cadv.s ++ adv.s ++ comp.s ! Ag Masc Sg P3
} ;
CAdvAP pol cadv ap comp = let
neg = (negation ! pol.p).p1
in ap ** {
s = \\af => pol.s ++ neg ++ cadv.s ++ ap.s ! af ++ comp.s ! Ag Masc Sg P3
} ;
AdnCAdv pol cadv = let
neg = (negation ! pol.p).p1
in {
s = pol.s ++ neg ++ cadv.s ++ "que"
} ;
lin
EnoughAP ap ant pol vp = {
s = \\af => let g : Gender = aform2gender af ;
n : Number = aform2number af
in ap.s ! af ++ "o suficiente" ++ ant.s ++ pol.s ++ infVP (Ag g n P3)
} ** ap ;
-- not sure about this, but in the one example seems to work
EnoughAdv adv = adv ;
lin
AdvAdv adv1 adv2 = {s = adv1.s ++ adv2.s} ;
lin
whatSgFem_IP = whatSg_IP ** {a = aagr Fem Sg} ;
whatSgNeut_IP = whatSg_IP ;
--TODO: check
lin that_RP = {
s = relPron ;
a = aagr Masc Sg ;
hasAgr = False
} ;
lin
EmbedVP ant pol p vp = {
s = \\c => prepCase c ++ ant.s ++ pol.s ++ infVP vp pol.p p.a
} ;
ComplVV vv ant pol vp = let
vf : Agr -> Str = \agr -> case ant.a of {
Simul => infVP vp pol.p agr ;
Anter => nominalVP (\_ -> VFin (VPres Indic) agr.n agr.p) vp pol.p agr
}
in
insertComplement (\\a => ant.s ++ pol.s ++ prepCase vv.c2.c ++ vf a) (predV vv) ;
CompVP ant pol p vp = {
s = \\agr => ant.s ++ pol.s ++ "de" ++ infVP vp pol.p p.a ;
cop = serCopula
} ;
UttVP ant pol p vp = {
s = ant.s ++ pol.s ++ infVP vp pol.p p.a
} ;
ReflVPSlash = ExtendPor.ReflRNP ;
lin FocusComp comp np = mkClause (comp.s ! np.a) np.hasClit np.isPol np.a (insertComplement (\\_ => (np.s ! Nom).ton) (predV (selectCopula comp.cop))) ;
} ;