-
Notifications
You must be signed in to change notification settings - Fork 0
/
eng-pargram.lfg
328 lines (249 loc) · 10.6 KB
/
eng-pargram.lfg
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
PARGRAM ENGLISH CONFIG (1.0)
ROOTCAT S.
REPARSECAT FRAGMENTS.
FILES eng-pargram-lex.lfg
common.templates.lfg
common.features.lfg. "the common files are part of the
pargram project"
LEXENTRIES (PARGRAM ENGLISH).
RULES (PARGRAM ENGLISH).
MORPHOLOGY (PARGRAM ENGLISH).
"templates and features from the common files (STANDARD COMMON) have lower
priority than those defined in this grammar"
TEMPLATES (STANDARD COMMON) (PARGRAM ENGLISH).
FEATURES (STANDARD COMMON) (PARGRAM ENGLISH).
GOVERNABLERELATIONS SUBJ OBJ OBJ-TH COMP XCOMP OBL.
SEMANTICFUNCTIONS ADJUNCT MOD TOPIC STANDARD.
NONDISTRIBUTIVES NUM PERS COORD-FORM.
EPSILON e.
OPTIMALITYORDER NOGOOD *Fragment "disprefer fragments and mark with *"
+OblAg. "prefer by obliques in passives"
GENOPTIMALITYORDER GenBadPunct NOGOOD "do not generate these"
+GenGoodPunct. "prefer these"
"This grammar is to be used with the information for those starting up
pargram grammars (or others interested in this type of grammar). It
illustrates a number of the facilities provided by xle which the more
theoretically trained grammar writers may not be familiar with. There
are comments throughout this file and the accompanying lexicon, but
see the documentation file for more details.
Please send any comments or suggestions to Tracy Holloway King
Tracy.King@microsoft.com"
----
PARGRAM ENGLISH FEATURES (1.0)
"This feature declaration modifies the shared pargram one
(common.features.lfg)."
"note that this feature declaration allows many
of the features in the common declaration to go through even though
they are not ever used."
&CASE: -> $ { nom acc }. "use only nom and acc"
&TENSE: -> $ { pres past }. " use only pres and past"
!ANIM: -> $ {}. "delete ANIM"
COORD-FORM: -> $ { and or }. "coordinating conjunction"
CHECK: -> << [ _AUX ].
_AUX: -> $ { + }. "used to partly control auxes with participles"
FIRST.
REST.
TOKEN.
o::. "have to declare projections"
----
"loads up the FST tokenizer and morphology"
PARGRAM ENGLISH MORPHOLOGY (1.0)
TOKENIZE:
P!basic-parse-tok.fst G!default-gen-tokenizer.fst
ANALYZE:
eng-pargram-morph.fst
----
PARGRAM ENGLISH RULES (1.0)
"top level category"
S --> "COM{EX RULE S: the girl pushes the boys.}"
e: @(DEFAULT (^ TNS-ASP TENSE) pres)
"provide pres as a default value to TENSE"
@(DEFAULT (^ STMT-TYPE) decl)
"provide decl as default value to STMT-TYPE";
("topicalized NP; COM{EX RULES S: bananas, I devour.}"
NP: (^ XCOMP* {OBJ|OBJ-TH})=!
(^ TOPIC)=!;
COMMA "obligatory comma")
NP: @SUBJ "obligatory subject noun phrase"
(! CASE)=nom;
{ VP: @(PASSIVE -) "passives go through Vaux"
|VPaux}
(PUNCT: @(OT-MARK GenGoodPunct) "prefer in generation").
VP --> V
(NP: @OBJ "direct object"
(! CASE)=acc)
(NP: @OBJ-TH "second object"
(! CASE)=acc)
(PP: @OBL) "subcategorized oblique, including passive agents"
"COM{EX RULES S: a boy is pushed by a girl.}"
PP*: @ADJUNCT "PP adjuncts"
"COM{EX RULES S: they sleep with the telescope.}".
VPaux --> AUX
VP.
NP --> (D) "optional determiner"
N*: @MOD; "noun noun modifiers; COM{EX RULES NP: a banana cake}"
N "head noun"
PP*: @ADJUNCT.
PP --> "prepositional phrases; COM{EX RULES PP: in the cake}"
P
NP: @OBJ
(! CASE)=acc.
METARULEMACRO(_CAT _BASECAT _RHS) = "applies to all rules in the grammar"
{ "just use the rule as stated"
"don't do anything to it; ALWAYS include this option"
_RHS
|"if it is an NP or an N, pass it to the NP
coordination rule"
"COM{EX RULE NP: the girl and the boy}"
e: _CAT $c { NP N };
@(NPCOORD _CAT)
|"if it is any other category, pass it to
the same category coordination rule"
"COM{EX RULE S: the girl sleeps and walks.}"
"COM{EX RULE PP: with the girl and in the park}"
e: _CAT ~$ { NP N };
@(SCCOORD _CAT)
|"allow bracketing around any category"
"COM{EX RULE S: [the girl] sleeps.}"
"COM{EX RULE S: boys baked [the bananas in the cake].}"
LB: @(OT-MARK GenBadPunct); "preceding quote mark"
"disprefer in generation"
_CAT: @PUSHUP; "this pushes the quotes to the top
to avoid vacuous ambiguity for things like:
COM{EX RULES NP: [cakes])"
RB "following quote mark"}.
"Coordination rules"
NPCOORD(_CAT) = "coordination of nominals"
"COM{EX RULE NP: girls and boys}"
"This differs from SCCOORD in that the conjunction provides NUM pl to
the resulting coordinated f-structure and the person features are
resolved for the noun phrase."
_CAT: @IN-SET "first nominal"
@NP-CONJUNCT; "calls person resolution template"
CONJnp: @PUSHUP; "conjunction"
"PUSHUP avoids vacuous ambiguity in constructions like:
COM{EX RULES NP: girls and boys}"
_CAT: @IN-SET "second nominal"
@NP-CONJUNCT.
SCCOORD(_CAT) = "coordination of non-nominals"
"COM{EX RULES PP: with girls and with boys}"
"COM{EX RULES S: girls sleep and boys sleep.}"
"no features other than a COORD-FORM are provided to the coordinated
f-structure."
_CAT: @IN-SET; "first constituent"
(COMMA: @(OT-MARK GenBadPunct)) "optional comma;
disprefered in generation"
"COM{EX RULES S: girls sleep, and boys sleep.}"
CONJ: @PUSHUP; "conjunction"
"PUSHUP avoids vacuous ambiguity in constructions like:
COM{EX RULES S: boys walk and sleep.}"
_CAT: @IN-SET "second constituent".
"Fragment rule for robust parsing"
"This rule will only be tried if no complete parse is found."
"COM{EX RULES the the girl slept.}"
"COM{EX RULES sleeps ! the girl}"
FRAGMENTS -->
{ NP: (^ FIRST)=!
@(OT-MARK Fragment) "disprefer Fragments"
"This ensures that the smallest number of Fragments
will be built"
|PP: (^ FIRST)=!
@(OT-MARK Fragment)
|VP: (^ FIRST)=!
(! SUBJ PRED)='pro' "have to provide subject for completeness"
@(OT-MARK Fragment)
|S: (^ FIRST)=!
@(OT-MARK Fragment)
|TOKEN: (^ FIRST)=! "use token if cannot match to anything"
@(OT-MARK Fragment)@(OT-MARK Fragment) "doubly penalize tokens"}
("optionally include another fragment"
FRAGMENTS: (^ REST)=!).
"Sublexical rules"
"These rules build up the surface N and V forms from the information
in the morphology. The main trick to writing sublexical rules is that
the category listed in the lexicon must have _BASE put after it. This
information will allow XLE to properly display the tree.
Here all of the nodes are ^=!. It is possible, but rarely necessary,
to have more complicated annotations on the sublexical rules."
V --> V_BASE "stem form"
V_SFX_BASE+ "as many tags as the morphology provides".
N --> N_BASE "stem form"
N_SFX_BASE+ "as many tags as the morphology provides".
P --> P_BASE "stem form"
P_SFX_BASE "+Prep tag".
----
PARGRAM ENGLISH TEMPLATES (1.0)
NOUN(_P) = "nouns and pronouns"
"COM{EX TEMPLATES NP: the girls}"
"COM(EX TEMPLATES NP: us}"
@(PRED _P)
"provide default 3rd person since pronouns and
nouns only get tags for 1st and 2nd person"
@(DEFAULT (^ PERS) 3).
PREP(_P) = "semantic preposition; COM{EX TEMPLATES PP: with them}"
(^ PRED)='_P<(^ OBJ)>'.
DET(_P _T) = "determiner"
(^ SPEC DET PRED)='_P'
(^ SPEC DET DET-TYPE)=_T.
V3SG = "third singular verb form; COM{EX TEMPLATES S: he sleeps.}"
(^ SUBJ NUM)=c sg
(^ SUBJ PERS)=c 3.
NONV3SG = "non third singular verb form; COM{EX TEMPLATES S: boys sleep.}"
{ (^ SUBJ NUM)=c pl
|(^ SUBJ NUM)=c sg
(^ SUBJ PERS)~=3}.
V1SG = "1st person singular subject; for auxiliaries"
"COM{EX TEMPLATES S: I am sleeping.}"
(^ SUBJ PERS)=c 1
(^ SUBJ NUM)=c sg.
VPL = " plural subject "
(^ SUBJ NUM)=c pl.
V2SG = "second person subject"
(^ SUBJ PERS)=c 2
(^ SUBJ NUM)=c sg.
V-SUBJ(_P) = "intransitive verb"
"COM{EX TEMPLATES S: they sleep.}"
@(SUBJ_core _P).
V-SUBJ-OBJ(_P) = "transitive verb; calls passive"
"COM{EX TEMPLATES S: the girl devours a banana.}"
"COM{EX TEMPLATES S: a banana is devoured.}"
@(PASS @(SUBJ-OBJ_core _P)).
V-SUBJ-OBJ-OBJTH(_P) = "double object verbs; calls passive"
"COM{EX TEMPLATES S: we baked the girls a cake.}"
"COM{EX TEMPLATES S: the girls were baked a cake.}"
@(PASS @(SUBJ-OBJ-OBJTH_core _P)).
PASS(_SCHEMATA) = "passive lexical rule"
"COM{EX TEMPLATES S: the girl devours a banana.}"
"COM{EX TEMPLATES S: a banana is devoured.}"
{ "active version"
_SCHEMATA
(^ PASSIVE)=-
|"passive version"
_SCHEMATA
(^ PASSIVE)=c +
{ (^ SUBJ) --> NULL "wipe out the subject"
|(^ SUBJ) --> (^ OBL) "make into an oblique by phrase"
@(OT-MARK OblAg)} "COM{EX TEMPLATES S: a banana is devoured by the girls.}"
(^ OBJ) --> (^ SUBJ) "make the object the subject"}.
NP-CONJUNCT = "provides person resolution features for nominal
coordination"
{ "if either conjunct is 1st person; the whole NP is"
"COM{EX TEMPLATES NP: the boys and me}"
(! PERS)=c 1
(^ PERS)=1
|"if a conjunct is 2nd person and the NP is not
already 1st person, make it 2nd person"
(! PERS)=c 2
{ (^ PERS)=c 1 "one conjunct was 1st person"
"COM{EX TEMPLATES NP: you and I}"
|(^ PERS)=2 } "else assign 2nd person"
"COM{EX TEMPLATES NP: you and the boys}"
|"otherwise, the NP is 3rd person"
"COM{EX TEMPLATES NP: the boys and her}"
(^ PERS)=3}.
DEFAULT(_FEAT _VAL) = "provides a default value for a feature"
{ _FEAT "feature exists but with a different value"
_FEAT ~= _VAL
|_FEAT = _VAL "assign the default value"
"it will unify if it already exists"}.
----