-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplates.py
More file actions
339 lines (310 loc) · 19 KB
/
templates.py
File metadata and controls
339 lines (310 loc) · 19 KB
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
class CoordinationTemplates:
def __init__(self):
self.rules = {
"simple_2NPs_coord_aff":
(["PropN1", "AND", "PropN2", "MV", "DOT"],
{"match": ([0, 2], [3])}),
"simple_2NPs_coord_neg":
(["PropN1", "AND", "PropN2", "NEG_MOD", "MV", "DOT"],
{"match": ([0, 2], [3])}),
"simple_2NPs_coord_interr":
(["INTERR_MOD", "PropN1_lower", "AND", "PropN2", "MV", "QUEST_MARK"],
{"match": ([1, 3], [0])}),
"simple_3NPs_coord_aff":
(["PropN1", "COMMA", "PropN2", "AND", "PropN3", "MV", "DOT"],
{"match": ([0, 2, 4], [5])}),
"simple_3NPs_coord_neg":
(["PropN1", "COMMA", "PropN2", "AND", "PropN3", "NEG_MOD", "MV", "DOT"],
{"match": ([0, 2, 4], [5])}),
"simple_3NPs_coord_interr":
(["INTERR_MOD", "PropN1_lower", "COMMA", "PropN2", "AND", "PropN3", "MV", "QUEST_MARK"],
{"match": ([1, 3, 5], [0])}),
"first_expanded_2NPs_coord_aff":
(["ExpNP", "AND", "PropN1_lower", "MV", "DOT"],
{"match": ([0, 2], [3])}),
"first_expanded_2NPs_coord_neg":
(["ExpNP", "AND", "PropN1_lower", "NEG_MOD", "MV", "DOT"],
{"match": ([0, 2], [3])}),
"first_expanded_2NPs_coord_interr":
(["INTERR_MOD", "ExpNP_lower", "AND", "PropN1_lower", "MV", "QUEST_MARK"],
{"match": ([1, 3], [0])}),
"second_expanded_2NPs_coord_aff":
(["PropN1", "AND", "ExpNP_lower", "MV", "DOT"],
{"match": ([0, 2], [3])}),
"second_expanded_2NPs_coord_neg":
(["PropN1", "AND", "ExpNP_lower", "NEG_MOD", "MV", "DOT"],
{"match": ([0, 2], [3])}),
"second_expanded_2NPs_coord_interr":
(["INTERR_MOD", "PropN1_lower", "AND", "ExpNP_lower", "MV", "QUEST_MARK"],
{"match": ([1, 3], [0])}),
"both_expanded_2NPs_coord_aff":
(["ExpNP", "AND", "ExpNP2", "MV", "DOT"],
{"match": ([0, 2], [3])}),
"both_expanded_2NPs_coord_neg":
(["ExpNP", "AND", "ExpNP2", "NEG_MOD", "MV", "DOT"],
{"match": ([0, 2], [3])}),
"both_expanded_2NPs_coord_interr":
(["INTERR_MOD", "ExpNP_lower", "AND", "ExpNP2", "MV", "QUEST_MARK"],
{"match": ([1, 3], [0])}),
"first_expanded_3NPs_coord_aff":
(["ExpNP", "COMMA", "PropN1_lower", "AND", "PropN3", "MV", "DOT"],
{"match": ([0, 2, 4], [5])}),
"first_expanded_3NPs_coord_neg":
(["ExpNP", "COMMA", "PropN1_lower", "AND", "PropN3", "NEG_MOD", "MV", "DOT"],
{"match": ([0, 2, 4], [5])}),
"first_expanded_3NPs_coord_interr":
(["INTERR_MOD", "ExpNP_lower", "COMMA", "PropN1_lower", "AND", "PropN3", "MV", "QUEST_MARK"],
{"match": ([1, 3, 5], [0])}),
"last_expanded_3NPs_coord_aff":
(["PropN1", "COMMA", "PropN3", "AND", "ExpNP_lower", "MV", "DOT"],
{"match": ([0, 2, 4], [5])}),
"last_expanded_3NPs_coord_neg":
(["PropN1", "COMMA", "PropN3", "AND", "ExpNP_lower", "NEG_MOD", "MV", "DOT"],
{"match": ([0, 2, 4], [5])}),
"last_expanded_3NPs_coord_interr":
(["INTERR_MOD", "PropN1_lower", "COMMA", "PropN3", "AND", "ExpNP_lower", "MV", "QUEST_MARK"],
{"match": ([1, 3, 5], [0])}),
"both_expanded_3NPs_coord_aff":
(["ExpNP", "COMMA", "ExpNP2", "AND", "PropN3", "MV", "DOT"],
{"match": ([0, 2, 4], [5])}),
"both_expanded_3NPs_coord_neg":
(["ExpNP", "COMMA", "ExpNP2", "AND", "PropN3", "NEG_MOD", "MV", "DOT"],
{"match": ([0, 2, 4], [5])}),
"both_expanded_3NPs_coord_interr":
(["INTERR_MOD", "ExpNP_lower", "COMMA", "ExpNP2", "AND", "PropN3", "MV", "QUEST_MARK"],
{"match": ([1, 3, 5], [0])}),
}
class TenseAgreementTemplates:
def __init__(self):
self.rules = {
# Present tense agreement AFFIRMATIVE with the main verb BE.
# e.g. Sam is angry , and Fred is too . <eos>
"tense_agr_presBe_sg_sg_aff":
(["NP1_sg", "presBe_sg", "BE_action", "COMMA", "AND", "NP2_sg", "presBe_sg", "TOO", "DOT"],
{"match": ([5], [6])}),
"tense_agr_presBe_sg_pl_aff":
(["NP1_sg", "presBe_sg", "BE_action", "COMMA", "AND", "NP2_pl", "presBe_pl", "TOO", "DOT"],
{"match": ([5], [6])}),
"tense_agr_presBe_pl_sg_aff":
(["NP1_pl", "presBe_pl", "BE_action", "COMMA", "AND", "NP2_sg", "presBe_sg", "TOO", "DOT"],
{"match": ([5], [6])}),
"tense_agr_presBe_pl_pl_aff":
(["NP1_pl", "presBe_pl", "BE_action", "COMMA", "AND", "NP2_pl", "presBe_pl", "TOO", "DOT"],
{"match": ([5], [6])}),
# Present tense agreement NEGATIVE with the main verb BE.
# e.g. Sam is not angry , but Fred is . <eos>
"tense_agr_presBe_sg_sg_1neg":
(["NP1_sg", "presBe_sg", "NOT", "BE_action", "COMMA", "BUT", "NP2_sg", "presBe_sg", "DOT"],
{"match": ([6], [7])}),
"tense_agr_presBe_sg_pl_1neg":
(["NP1_sg", "presBe_sg", "NOT", "BE_action", "COMMA", "BUT", "NP2_pl", "presBe_pl", "DOT"],
{"match": ([6], [7])}),
"tense_agr_presBe_pl_sg_1neg":
(["NP1_pl", "presBe_pl", "NOT", "BE_action", "COMMA", "BUT", "NP2_sg", "presBe_sg", "DOT"],
{"match": ([6], [7])}),
"tense_agr_presBe_pl_pl_1neg":
(["NP1_pl", "presBe_pl", "NOT", "BE_action", "COMMA", "BUT", "NP2_pl", "presBe_pl", "DOT"],
{"match": ([6], [7])}),
# Present tense agreement NEGATIVE with the main verb BE.
# e.g. Sam is angry , but Fred is not . <eos>
"tense_agr_presBe_sg_sg_2neg":
(["NP1_sg", "presBe_sg", "BE_action", "COMMA", "BUT", "NP2_sg", "presBe_sg", "NOT", "DOT"],
{"match": ([5], [6])}),
"tense_agr_presBe_sg_pl_2neg":
(["NP1_sg", "presBe_sg", "BE_action", "COMMA", "BUT", "NP2_pl", "presBe_pl", "NOT", "DOT"],
{"match": ([5], [6])}),
"tense_agr_presBe_pl_sg_2neg":
(["NP1_pl", "presBe_pl", "BE_action", "COMMA", "BUT", "NP2_sg", "presBe_sg", "NOT", "DOT"],
{"match": ([5], [6])}),
"tense_agr_presBe_pl_pl_2neg":
(["NP1_pl", "presBe_pl", "BE_action", "COMMA", "BUT", "NP2_pl", "presBe_pl", "NOT", "DOT"],
{"match": ([5], [6])}),
# Past tense agreement AFFIRMATIVE.
# e.g. Sam laughed , and Fred did too . <eos>
"tense_agr_past_sg_sg_aff":
(["NP1_sg", "PAST_action", "COMMA", "AND", "NP2_sg", "DID_past_sg", "TOO", "DOT"],
{"match": ([4], [5])}),
"tense_agr_past_sg_pl_aff":
(["NP1_sg", "PAST_action", "COMMA", "AND", "NP2_pl", "DID_past_pl", "TOO", "DOT"],
{"match": ([4], [5])}),
"tense_agr_past_pl_sg_aff":
(["NP1_pl", "PAST_action", "COMMA", "AND", "NP2_sg", "DID_past_sg", "TOO", "DOT"],
{"match": ([4], [5])}),
"tense_agr_past_pl_pl_aff":
(["NP1_pl", "PAST_action", "COMMA", "AND", "NP2_pl", "DID_past_pl", "TOO", "DOT"],
{"match": ([4], [5])}),
# Past tense agreement NEGATIVE.
# e.g. Sam did not laugh , but Fred did . <eos>
"tense_agr_past_sg_sg_neg":
(["NP1_sg", "DID_past_sg", "NOT", "INFINITIVE_action", "COMMA", "BUT", "NP2_sg", "DID_past_sg", "DOT"],
{"match": ([6], [7])}),
"tense_agr_past_sg_pl_neg":
(["NP1_sg", "DID_past_sg", "NOT", "INFINITIVE_action", "COMMA", "BUT", "NP2_pl", "DID_past_pl", "DOT"],
{"match": ([6], [7])}),
"tense_agr_past_pl_sg_neg":
(["NP1_pl", "DID_past_pl", "NOT", "INFINITIVE_action", "COMMA", "BUT", "NP2_sg", "DID_past_sg", "DOT"],
{"match": ([6], [7])}),
"tense_agr_past_pl_pl_neg":
(["NP1_pl", "DID_past_pl", "NOT", "INFINITIVE_action", "COMMA", "BUT", "NP2_pl", "DID_past_pl", "DOT"],
{"match": ([6], [7])}),
# Future tense agreement AFFIRMATIVE.
# e.g. Sam will laugh , and Fred will too . <eos>
"tense_agr_future_sg_sg_aff":
(["NP1_sg", "WILL_future_sg", "INFINITIVE_action", "COMMA", "AND", "NP2_sg", "WILL_future_sg", "TOO", "DOT"],
{"match": ([5], [6])}),
"tense_agr_future_sg_pl_aff":
(["NP1_sg", "WILL_future_sg", "INFINITIVE_action", "COMMA", "AND", "NP2_pl", "WILL_future_pl", "TOO", "DOT"],
{"match": ([5], [6])}),
"tense_agr_future_pl_sg_aff":
(["NP1_pl", "WILL_future_pl", "INFINITIVE_action", "COMMA", "AND", "NP2_sg", "WILL_future_sg", "TOO", "DOT"],
{"match": ([5], [6])}),
"tense_agr_future_pl_pl_aff":
(["NP1_pl", "WILL_future_pl", "INFINITIVE_action", "COMMA", "AND", "NP2_pl", "WILL_future_pl", "TOO", "DOT"],
{"match": ([5], [6])}),
# Future tense agreement NEGATIVE.
# e.g. Sam will not laugh , but Fred will . <eos>
"tense_agr_future_sg_sg_neg":
(["NP1_sg", "WILL_future_sg", "NOT", "INFINITIVE_action", "COMMA", "BUT", "NP2_sg", "WILL_future_sg", "DOT"],
{"match": ([6], [7])}),
"tense_agr_future_sg_pl_neg":
(["NP1_sg", "WILL_future_sg", "NOT", "INFINITIVE_action", "COMMA", "BUT", "NP2_pl", "WILL_future_pl", "DOT"],
{"match": ([6], [7])}),
"tense_agr_future_pl_sg_neg":
(["NP1_pl", "WILL_future_pl", "NOT", "INFINITIVE_action", "COMMA", "BUT", "NP2_sg", "WILL_future_sg", "DOT"],
{"match": ([6], [7])}),
"tense_agr_future_pl_pl_neg":
(["NP1_pl", "WILL_future_pl", "NOT", "INFINITIVE_action", "COMMA", "BUT", "NP2_pl", "WILL_future_pl", "DOT"],
{"match": ([6], [7])}),
# Present tense agreement AFFIRMATIVE with the main verb BE and INVERSION.
# e.g. Sam is angry , and so is Fred . <eos>
"tense_agr_with_inv_presBe_sg_sg_aff":
(["NP1_sg", "presBe_sg", "BE_action", "COMMA", "AND_aff", "presBe_sg", "NP2_sg", "DOT"],
{"match": ([6], [5])}),
"tense_agr_with_inv_presBe_sg_pl_aff":
(["NP1_sg", "presBe_sg", "BE_action", "COMMA", "AND_aff", "presBe_pl", "NP2_pl", "DOT"],
{"match": ([6], [5])}),
"tense_agr_with_inv_presBe_pl_sg_aff":
(["NP1_pl", "presBe_pl", "BE_action", "COMMA", "AND_aff", "presBe_sg", "NP2_sg", "DOT"],
{"match": ([6], [5])}),
"tense_agr_with_inv_presBe_pl_pl_aff":
(["NP1_pl", "presBe_pl", "BE_action", "COMMA", "AND_aff", "presBe_pl", "NP2_pl", "DOT"],
{"match": ([6], [5])}),
# Present tense agreement NEGATIVE with the main verb BE and INVERSION.
# e.g. Sam is not angry , and neither is Fred . <eos>
"tense_agr_with_inv_presBe_sg_sg_neg":
(["NP1_sg", "presBe_sg", "NOT", "BE_action", "COMMA", "AND_neg", "presBe_sg", "NP2_sg", "DOT"],
{"match": ([7], [6])}),
"tense_agr_with_inv_presBe_sg_pl_neg":
(["NP1_sg", "presBe_sg", "NOT", "BE_action", "COMMA", "AND_neg", "presBe_pl", "NP2_pl", "DOT"],
{"match": ([7], [6])}),
"tense_agr_with_inv_presBe_pl_sg_neg":
(["NP1_pl", "presBe_pl", "NOT", "BE_action", "COMMA", "AND_neg", "presBe_sg", "NP2_sg", "DOT"],
{"match": ([7], [6])}),
"tense_agr_with_inv_presBe_pl_pl_neg":
(["NP1_pl", "presBe_pl", "NOT", "BE_action", "COMMA", "AND_neg", "presBe_pl", "NP2_pl", "DOT"],
{"match": ([7], [6])}),
# Past tense agreement AFFIRMATIVE with INVERSION.
# e.g. Sam laughed , and so did Fred . <eos>
"tense_agr_with_inv_past_sg_sg_aff":
(["NP1_sg", "PAST_action", "COMMA", "AND_aff", "DID_past_sg", "NP2_sg", "DOT"],
{"match": ([5], [4])}),
"tense_agr_with_inv_past_sg_pl_aff":
(["NP1_sg", "PAST_action", "COMMA", "AND_aff", "DID_past_pl", "NP2_pl", "DOT"],
{"match": ([5], [4])}),
"tense_agr_with_inv_past_pl_sg_aff":
(["NP1_pl", "PAST_action", "COMMA", "AND_aff", "DID_past_sg", "NP2_sg", "DOT"],
{"match": ([5], [4])}),
"tense_agr_with_inv_past_pl_pl_aff":
(["NP1_pl", "PAST_action", "COMMA", "AND_aff", "DID_past_pl", "NP2_pl", "DOT"],
{"match": ([5], [4])}),
# Past tense agreement NEGATIVE with INVERSION.
# e.g. Sam did not laugh , and neither did Fred . <eos>
"tense_agr_with_inv_past_sg_sg_neg":
(["NP1_sg", "DID_past_sg", "NOT", "INFINITIVE_action", "COMMA", "AND_neg", "DID_past_sg", "NP2_sg", "DOT"],
{"match": ([7], [6])}),
"tense_agr_with_inv_past_sg_pl_neg":
(["NP1_sg", "DID_past_sg", "NOT", "INFINITIVE_action", "COMMA", "AND_neg", "DID_past_pl", "NP2_pl", "DOT"],
{"match": ([7], [6])}),
"tense_agr_with_inv_past_pl_sg_neg":
(["NP1_pl", "DID_past_pl", "NOT", "INFINITIVE_action", "COMMA", "AND_neg", "DID_past_sg", "NP2_sg", "DOT"],
{"match": ([7], [6])}),
"tense_agr_with_inv_past_pl_pl_neg":
(["NP1_pl", "DID_past_pl", "NOT", "INFINITIVE_action", "COMMA", "AND_neg", "DID_past_pl", "NP2_pl", "DOT"],
{"match": ([7], [6])}),
# Future tense agreement AFFIRMATIVE with INVERSION.
# e.g. Sam will laugh , and so will Fred . <eos>
"tense_agr_with_inv_future_sg_sg_aff":
(["NP1_sg", "WILL_future_sg", "INFINITIVE_action", "COMMA", "AND_aff", "WILL_future_sg", "NP2_sg", "DOT"],
{"match": ([6], [5])}),
"tense_agr_with_inv_future_sg_pl_aff":
(["NP1_sg", "WILL_future_sg", "INFINITIVE_action", "COMMA", "AND_aff", "WILL_future_pl", "NP2_pl", "DOT"],
{"match": ([6], [5])}),
"tense_agr_with_inv_future_pl_sg_aff":
(["NP1_pl", "WILL_future_pl", "INFINITIVE_action", "COMMA", "AND_aff", "WILL_future_sg", "NP2_sg", "DOT"],
{"match": ([6], [5])}),
"tense_agr_with_inv_future_pl_pl_aff":
(["NP1_pl", "WILL_future_pl", "INFINITIVE_action", "COMMA", "AND_aff", "WILL_future_pl", "NP2_pl", "DOT"],
{"match": ([6], [5])}),
# Future tense agreement NEGATIVE with INVERSION.
# e.g. Sam did not laugh , and neither did Fred . <eos>
"tense_agr_with_inv_future_sg_sg_neg":
(["NP1_sg", "WILL_future_sg", "NOT", "INFINITIVE_action", "COMMA", "AND_neg", "WILL_future_sg", "NP2_sg", "DOT"],
{"match": ([7], [6])}),
"tense_agr_with_inv_future_sg_pl_neg":
(["NP1_sg", "WILL_future_sg", "NOT", "INFINITIVE_action", "COMMA", "AND_neg", "WILL_future_pl", "NP2_pl", "DOT"],
{"match": ([7], [6])}),
"tense_agr_with_inv_future_pl_sg_neg":
(["NP1_pl", "WILL_future_pl", "NOT", "INFINITIVE_action", "COMMA", "AND_neg", "WILL_future_sg", "NP2_sg", "DOT"],
{"match": ([7], [6])}),
"tense_agr_with_inv_future_pl_pl_neg":
(["NP1_pl", "WILL_future_pl", "NOT", "INFINITIVE_action", "COMMA", "AND_neg", "WILL_future_pl", "NP2_pl", "DOT"],
{"match": ([7], [6])}),
# Present tense agreement AFFIRMATIVE with the main verb BE.
# e.g. Sam is angry , is n't he ? <eos>
"tense_agr_tags_presBe_sg_aff":
(["NP1_sg", "presBe_sg", "BE_action", "COMMA", "presBe_sg", "NT", "HE", "QUEST_MARK"],
{"match": ([0], [4])}),
"tense_agr_tags_presBe_pl_aff":
(["NP1_pl", "presBe_pl", "BE_action", "COMMA", "presBe_pl", "NT", "THEY", "QUEST_MARK"],
{"match": ([0], [4])}),
# Present tense agreement NEGATIVE with the main verb BE.
# e.g. Sam is n't angry , is he ? <eos>
"tense_agr_tags_presBe_sg_neg":
(["NP1_sg", "presBe_sg", "NT", "BE_action", "COMMA", "presBe_sg", "HE", "QUEST_MARK"],
{"match": ([0], [5])}),
"tense_agr_tags_presBe_pl_neg":
(["NP1_pl", "presBe_pl", "NT", "BE_action", "COMMA", "presBe_pl", "THEY", "QUEST_MARK"],
{"match": ([0], [5])}),
# Past tense agreement AFFIRMATIVE.
# e.g. Sam laughed , did n't he ? <eos>
"tense_agr_tags_past_sg_aff":
(["NP1_sg", "PAST_action", "COMMA", "DID_past_sg", "NT", "HE", "QUEST_MARK"],
{"match": ([0], [3])}),
"tense_agr_tags_past_pl_aff":
(["NP1_pl", "PAST_action", "COMMA", "DID_past_pl", "NT", "THEY", "QUEST_MARK"],
{"match": ([0], [3])}),
# Past tense agreement NEGATIVE.
# e.g. Sam did n't laugh , did he ? <eos>
"tense_agr_tags_past_sg_neg":
(["NP1_sg", "DID_past_sg", "NT", "INFINITIVE_action", "COMMA", "DID_past_sg", "HE", "QUEST_MARK"],
{"match": ([0], [5])}),
"tense_agr_tags_past_pl_neg":
(["NP1_pl", "DID_past_pl", "NT", "INFINITIVE_action", "COMMA", "DID_past_pl", "THEY", "QUEST_MARK"],
{"match": ([0], [5])}),
# Future tense agreement AFFIRMATIVE.
# e.g. Sam will laugh , will n't he ? <eos>
"tense_agr_tags_future_sg_aff":
(["NP1_sg", "WILL_future_sg", "INFINITIVE_action", "COMMA", "WILL_future_sg", "NT", "HE", "QUEST_MARK"],
{"match": ([0], [4])}),
"tense_agr_tags_future_pl_aff":
(["NP1_pl", "WILL_future_pl", "INFINITIVE_action", "COMMA", "WILL_future_pl", "NT", "THEY", "QUEST_MARK"],
{"match": ([0], [4])}),
# Future tense agreement NEGATIVE.
# e.g. Sam will n't laugh , will he ? <eos>
"tense_agr_tags_future_sg_neg":
(["NP1_sg", "WILL_future_sg", "NT", "INFINITIVE_action", "COMMA", "WILL_future_sg", "HE", "QUEST_MARK"],
{"match": ([0], [5])}),
"tense_agr_tags_future_pl_neg":
(["NP1_pl", "WILL_future_pl", "NT", "INFINITIVE_action", "COMMA", "WILL_future_pl", "THEY", "QUEST_MARK"],
{"match": ([0], [5])}),
}