forked from rc0/jbofihe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
relative.c
276 lines (202 loc) · 6.49 KB
/
relative.c
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
/***************************************
$Header$
Processing for relative clauses.
***************************************/
/* COPYRIGHT */
#include <assert.h>
#include "nodes.h"
#include "rpc_tab.h"
#include "functions.h"
#include "cmavotab.h"
/*++++++++++++++++++++++++++++++++++++++
TreeNode *x
++++++++++++++++++++++++++++++++++++++*/
static void
process_goi_clause (TreeNode *x)
{
TreeNode *goi, *term, *termc;
XDontGloss *xdg;
goi = find_nth_cmavo_child(x, 1, GOI);
term = find_nth_child(x, 1, TERM);
assert (goi);
assert (term);
termc = child_ref(term, 0);
/* What sort of term? */
switch (termc->data.nonterm.type) {
case TERM_PLAIN_SUMTI:
/* This is the standard 'associated with' meaning */
break;
case TERM_TAGGED_SUMTI:
case TAGGED_TERMSET:
/* In this case we want to elide the gloss for the GOI (in all
cases of GOI?) */
xdg = prop_dont_gloss(goi, YES);
break;
case TERM_PLACED_SUMTI:
/* This is bizarre - what ever would it mean? */
break;
case TERM_FLOATING_TENSE:
/* A meaning for this can just about be envisaged :
e.g. le finpe pe ca cu xamgu would mean
the fish associated with something current is good
but is that what the language definition would say?
*/
break;
case TERMSET:
/* ugh - the branches could differ, plus what would it mean
anyway, there would be multiple terms in each branch. */
break;
case TERM_FLOATING_NEGATE:
/* meaning? */
break;
case TERM_OTHER:
break;
default:
break;
}
}
/*++++++++++++++++++++++++++++++++++++++
Processing to decide whether to gloss NOI as 'such that' or as 'which'.
TreeNode *x
++++++++++++++++++++++++++++++++++++++*/
static void
process_noi_clause (TreeNode *x)
{
}
/*++++++++++++++++++++++++++++++++++++++
TreeNode *x
++++++++++++++++++++++++++++++++++++++*/
static void
process_any_rel_clause (TreeNode *x)
{
TreeNode *rcs, *encl;
TreeNode *antecedent;
/* Find enclosing rule */
rcs = x->parent;
while (rcs->data.nonterm.type != RELATIVE_CLAUSES) {
rcs = rcs->parent;
}
encl = rcs->parent;
/* In several cases, it looks like the relative clause can come
before the antecedent (postcedent? :-) ). This needs to be
confirmed. */
switch (encl->data.nonterm.type) {
case FRAGMENT:
antecedent = NULL;
break;
case SUMTI:
antecedent = child_ref(encl, 0); /* The sumti_1 node */
break;
case SUMTI_5:
antecedent = child_ref(encl, 0); /* The sumti_5a or sumti_5b node */
break;
case LAHE_SUMTI_6:
antecedent = find_nth_child(encl, 1, SUMTI);
break;
case NAHE_BO_SUMTI_6:
antecedent = find_nth_child(encl, 1, SUMTI);
break;
case NAME_SUMTI_6:
antecedent = encl;
break;
case SUMTI_TAIL:
antecedent = find_nth_child(encl, 1, SUMTI_6);
/* If there's a sumti_6 present I think the relative clause
applies to it, otherwise it's like the case above - does it
apply to the sumti_tail_1, or to something else??? */
break;
case SUMTI_TAIL_1:
antecedent = child_ref(encl, 0); /* the sumti_tail_1A */
break;
case FREE_VOCATIVE:
/* The relative clause applies to the whole thing (see text
around example 9.6 in the reference manual. (Strictly it
applies to the selbri or CMENE_seq, but ignore that nicety
for now.) */
antecedent = encl;
break;
default:
fprintf(stderr, "Shouldn't find relative clause in this context\n");
antecedent = NULL;
break;
}
/* Set the antecedent on the NOI to where it is, and put a property
on the antecedent node to warn the bracketer that it needs to
mark it. */
if (antecedent) {
XRequireBrac *xrb;
XAntecedent *xan;
xan = prop_antecedent(x, YES);
xan->node = antecedent;
xrb = prop_require_brac(antecedent, YES);
}
}
/*++++++++++++++++++++++++++++++++++++++
TreeNode *x
++++++++++++++++++++++++++++++++++++++*/
static void
process_keha(TreeNode *x)
{
TreeNode *rel;
/* Need to extend to deal with subscripted ke'a, where you have to
back-count out of nested relative clauses. */
rel = x->parent;
while ((rel->data.nonterm.type != RELATIVE_CLAUSE) &&
(rel->data.nonterm.type != CHUNKS)) {
rel = rel->parent;
}
if (rel->data.nonterm.type == RELATIVE_CLAUSE) {
/* Set property on ke'a to point back to containing clause */
prop_rel_clause_link(x, YES)->rel = rel;
/* Set property on containing clause to warn that it contains ke'a */
prop_contains_keha (rel, YES);
}
}
/*++++++++++++++++++++++++++++++++++++++
Do processing for relative clauses. The actions are as follows
1. For GOI-type relative clauses, see if the term following is of
the form <sumti> or <tag> <sumti>. This determines whether to
bother glossing the GOI cmavo in the text output.
2. For NOI-type relative clauses, there is more to do.
2a. Mark the NOI cmavo with a property to point back to the
antecedent of the relative clause.
2b. Look for each instance of ke'a in the text. Look for a
subscript on it. Try to backtrack out to the associated relative
clause, to point the ke'a at its antecedent.
2c. If ke'a occurs in a relative clause, mark a property on the NOI
cmavo. This indicates it should be glossed as 'such that' rather
than 'which'. (Maybe this criterion needs to be based on whether
any terms precede the selbri in the relative clause? It gets
awfully complex in some cases, e.g. if the relative clause is a
<gek_sentence> because the 2 branches may be different in this
regard.)
TreeNode *top
++++++++++++++++++++++++++++++++++++++*/
void
relative_clause_processing (TreeNode *x)
{
/* Traverse parse tree */
int nc, i;
struct nonterm *nt;
TreeNode *c;
if (x->type == N_NONTERM) {
nt = &x->data.nonterm;
/* Child scan first so that ke'a is processed before NOI */
nc = nt->nchildren;
for (i=0; i<nc; i++) {
c = nt->children[i];
relative_clause_processing(c);
}
if (nt->type == RELATIVE_CLAUSE) {
process_any_rel_clause(x);
}
if (nt->type == TERM_RELATIVE_CLAUSE) {
process_goi_clause(x);
} else if (nt->type == FULL_RELATIVE_CLAUSE) {
process_noi_clause(x);
}
} else if ((x->type == N_CMAVO) &&
(!strcmp(cmavo_table[x->data.cmavo.code].cmavo, "ke\'a"))) {
process_keha(x);
}
}