Line data Source code
1 : /* Generated from irish.sbl by Snowball 3.0.0 - https://snowballstem.org/ */
2 :
3 : #include "stem_UTF_8_irish.h"
4 :
5 : #include <stddef.h>
6 :
7 : #include "snowball_runtime.h"
8 :
9 : struct SN_local {
10 : struct SN_env z;
11 : int i_p2;
12 : int i_p1;
13 : int i_pV;
14 : };
15 :
16 : typedef struct SN_local SN_local;
17 :
18 : #ifdef __cplusplus
19 : extern "C" {
20 : #endif
21 : extern int irish_UTF_8_stem(struct SN_env * z);
22 : #ifdef __cplusplus
23 : }
24 : #endif
25 :
26 : static int r_verb_sfx(struct SN_env * z);
27 : static int r_deriv(struct SN_env * z);
28 : static int r_noun_sfx(struct SN_env * z);
29 : static int r_mark_regions(struct SN_env * z);
30 : static int r_initial_morph(struct SN_env * z);
31 : static int r_RV(struct SN_env * z);
32 : static int r_R2(struct SN_env * z);
33 : static int r_R1(struct SN_env * z);
34 :
35 : static const symbol s_0[] = { 'f' };
36 : static const symbol s_1[] = { 's' };
37 : static const symbol s_2[] = { 'b' };
38 : static const symbol s_3[] = { 'c' };
39 : static const symbol s_4[] = { 'd' };
40 : static const symbol s_5[] = { 'g' };
41 : static const symbol s_6[] = { 'p' };
42 : static const symbol s_7[] = { 't' };
43 : static const symbol s_8[] = { 'm' };
44 : static const symbol s_9[] = { 'a', 'r', 'c' };
45 : static const symbol s_10[] = { 'g', 'i', 'n' };
46 : static const symbol s_11[] = { 'g', 'r', 'a', 'f' };
47 : static const symbol s_12[] = { 'p', 'a', 'i', 't', 'e' };
48 : static const symbol s_13[] = { 0xC3, 0xB3, 'i', 'd' };
49 :
50 : static const symbol s_0_0[2] = { 'b', '\'' };
51 : static const symbol s_0_1[2] = { 'b', 'h' };
52 : static const symbol s_0_2[3] = { 'b', 'h', 'f' };
53 : static const symbol s_0_3[2] = { 'b', 'p' };
54 : static const symbol s_0_4[2] = { 'c', 'h' };
55 : static const symbol s_0_5[2] = { 'd', '\'' };
56 : static const symbol s_0_6[4] = { 'd', '\'', 'f', 'h' };
57 : static const symbol s_0_7[2] = { 'd', 'h' };
58 : static const symbol s_0_8[2] = { 'd', 't' };
59 : static const symbol s_0_9[2] = { 'f', 'h' };
60 : static const symbol s_0_10[2] = { 'g', 'c' };
61 : static const symbol s_0_11[2] = { 'g', 'h' };
62 : static const symbol s_0_12[2] = { 'h', '-' };
63 : static const symbol s_0_13[2] = { 'm', '\'' };
64 : static const symbol s_0_14[2] = { 'm', 'b' };
65 : static const symbol s_0_15[2] = { 'm', 'h' };
66 : static const symbol s_0_16[2] = { 'n', '-' };
67 : static const symbol s_0_17[2] = { 'n', 'd' };
68 : static const symbol s_0_18[2] = { 'n', 'g' };
69 : static const symbol s_0_19[2] = { 'p', 'h' };
70 : static const symbol s_0_20[2] = { 's', 'h' };
71 : static const symbol s_0_21[2] = { 't', '-' };
72 : static const symbol s_0_22[2] = { 't', 'h' };
73 : static const symbol s_0_23[2] = { 't', 's' };
74 : static const struct among a_0[24] = {
75 : { 2, s_0_0, 0, 1, 0},
76 : { 2, s_0_1, 0, 4, 0},
77 : { 3, s_0_2, -1, 2, 0},
78 : { 2, s_0_3, 0, 8, 0},
79 : { 2, s_0_4, 0, 5, 0},
80 : { 2, s_0_5, 0, 1, 0},
81 : { 4, s_0_6, -1, 2, 0},
82 : { 2, s_0_7, 0, 6, 0},
83 : { 2, s_0_8, 0, 9, 0},
84 : { 2, s_0_9, 0, 2, 0},
85 : { 2, s_0_10, 0, 5, 0},
86 : { 2, s_0_11, 0, 7, 0},
87 : { 2, s_0_12, 0, 1, 0},
88 : { 2, s_0_13, 0, 1, 0},
89 : { 2, s_0_14, 0, 4, 0},
90 : { 2, s_0_15, 0, 10, 0},
91 : { 2, s_0_16, 0, 1, 0},
92 : { 2, s_0_17, 0, 6, 0},
93 : { 2, s_0_18, 0, 7, 0},
94 : { 2, s_0_19, 0, 8, 0},
95 : { 2, s_0_20, 0, 3, 0},
96 : { 2, s_0_21, 0, 1, 0},
97 : { 2, s_0_22, 0, 9, 0},
98 : { 2, s_0_23, 0, 3, 0}
99 : };
100 :
101 : static const symbol s_1_0[7] = { 0xC3, 0xAD, 'o', 'c', 'h', 't', 'a' };
102 : static const symbol s_1_1[8] = { 'a', 0xC3, 0xAD, 'o', 'c', 'h', 't', 'a' };
103 : static const symbol s_1_2[3] = { 'i', 'r', 'e' };
104 : static const symbol s_1_3[4] = { 'a', 'i', 'r', 'e' };
105 : static const symbol s_1_4[3] = { 'a', 'b', 'h' };
106 : static const symbol s_1_5[4] = { 'e', 'a', 'b', 'h' };
107 : static const symbol s_1_6[3] = { 'i', 'b', 'h' };
108 : static const symbol s_1_7[4] = { 'a', 'i', 'b', 'h' };
109 : static const symbol s_1_8[3] = { 'a', 'm', 'h' };
110 : static const symbol s_1_9[4] = { 'e', 'a', 'm', 'h' };
111 : static const symbol s_1_10[3] = { 'i', 'm', 'h' };
112 : static const symbol s_1_11[4] = { 'a', 'i', 'm', 'h' };
113 : static const symbol s_1_12[6] = { 0xC3, 0xAD, 'o', 'c', 'h', 't' };
114 : static const symbol s_1_13[7] = { 'a', 0xC3, 0xAD, 'o', 'c', 'h', 't' };
115 : static const symbol s_1_14[4] = { 'i', 'r', 0xC3, 0xAD };
116 : static const symbol s_1_15[5] = { 'a', 'i', 'r', 0xC3, 0xAD };
117 : static const struct among a_1[16] = {
118 : { 7, s_1_0, 0, 1, 0},
119 : { 8, s_1_1, -1, 1, 0},
120 : { 3, s_1_2, 0, 2, 0},
121 : { 4, s_1_3, -1, 2, 0},
122 : { 3, s_1_4, 0, 1, 0},
123 : { 4, s_1_5, -1, 1, 0},
124 : { 3, s_1_6, 0, 1, 0},
125 : { 4, s_1_7, -1, 1, 0},
126 : { 3, s_1_8, 0, 1, 0},
127 : { 4, s_1_9, -1, 1, 0},
128 : { 3, s_1_10, 0, 1, 0},
129 : { 4, s_1_11, -1, 1, 0},
130 : { 6, s_1_12, 0, 1, 0},
131 : { 7, s_1_13, -1, 1, 0},
132 : { 4, s_1_14, 0, 2, 0},
133 : { 5, s_1_15, -1, 2, 0}
134 : };
135 :
136 : static const symbol s_2_0[9] = { 0xC3, 0xB3, 'i', 'd', 'e', 'a', 'c', 'h', 'a' };
137 : static const symbol s_2_1[7] = { 'p', 'a', 't', 'a', 'c', 'h', 'a' };
138 : static const symbol s_2_2[5] = { 'a', 'c', 'h', 't', 'a' };
139 : static const symbol s_2_3[8] = { 'a', 'r', 'c', 'a', 'c', 'h', 't', 'a' };
140 : static const symbol s_2_4[6] = { 'e', 'a', 'c', 'h', 't', 'a' };
141 : static const symbol s_2_5[12] = { 'g', 'r', 'a', 'f', 'a', 0xC3, 0xAD, 'o', 'c', 'h', 't', 'a' };
142 : static const symbol s_2_6[5] = { 'p', 'a', 'i', 't', 'e' };
143 : static const symbol s_2_7[3] = { 'a', 'c', 'h' };
144 : static const symbol s_2_8[4] = { 'e', 'a', 'c', 'h' };
145 : static const symbol s_2_9[8] = { 0xC3, 0xB3, 'i', 'd', 'e', 'a', 'c', 'h' };
146 : static const symbol s_2_10[7] = { 'g', 'i', 'n', 'e', 'a', 'c', 'h' };
147 : static const symbol s_2_11[6] = { 'p', 'a', 't', 'a', 'c', 'h' };
148 : static const symbol s_2_12[10] = { 'g', 'r', 'a', 'f', 'a', 0xC3, 0xAD, 'o', 'c', 'h' };
149 : static const symbol s_2_13[7] = { 'p', 'a', 't', 'a', 'i', 'g', 'h' };
150 : static const symbol s_2_14[7] = { 0xC3, 0xB3, 'i', 'd', 'i', 'g', 'h' };
151 : static const symbol s_2_15[8] = { 'a', 'c', 'h', 't', 0xC3, 0xBA, 'i', 'l' };
152 : static const symbol s_2_16[9] = { 'e', 'a', 'c', 'h', 't', 0xC3, 0xBA, 'i', 'l' };
153 : static const symbol s_2_17[6] = { 'g', 'i', 'n', 'e', 'a', 's' };
154 : static const symbol s_2_18[5] = { 'g', 'i', 'n', 'i', 's' };
155 : static const symbol s_2_19[4] = { 'a', 'c', 'h', 't' };
156 : static const symbol s_2_20[7] = { 'a', 'r', 'c', 'a', 'c', 'h', 't' };
157 : static const symbol s_2_21[5] = { 'e', 'a', 'c', 'h', 't' };
158 : static const symbol s_2_22[11] = { 'g', 'r', 'a', 'f', 'a', 0xC3, 0xAD, 'o', 'c', 'h', 't' };
159 : static const symbol s_2_23[10] = { 'a', 'r', 'c', 'a', 'c', 'h', 't', 'a', 0xC3, 0xAD };
160 : static const symbol s_2_24[14] = { 'g', 'r', 'a', 'f', 'a', 0xC3, 0xAD, 'o', 'c', 'h', 't', 'a', 0xC3, 0xAD };
161 : static const struct among a_2[25] = {
162 : { 9, s_2_0, 0, 6, 0},
163 : { 7, s_2_1, 0, 5, 0},
164 : { 5, s_2_2, 0, 1, 0},
165 : { 8, s_2_3, -1, 2, 0},
166 : { 6, s_2_4, -2, 1, 0},
167 : { 12, s_2_5, 0, 4, 0},
168 : { 5, s_2_6, 0, 5, 0},
169 : { 3, s_2_7, 0, 1, 0},
170 : { 4, s_2_8, -1, 1, 0},
171 : { 8, s_2_9, -1, 6, 0},
172 : { 7, s_2_10, -2, 3, 0},
173 : { 6, s_2_11, -4, 5, 0},
174 : { 10, s_2_12, 0, 4, 0},
175 : { 7, s_2_13, 0, 5, 0},
176 : { 7, s_2_14, 0, 6, 0},
177 : { 8, s_2_15, 0, 1, 0},
178 : { 9, s_2_16, -1, 1, 0},
179 : { 6, s_2_17, 0, 3, 0},
180 : { 5, s_2_18, 0, 3, 0},
181 : { 4, s_2_19, 0, 1, 0},
182 : { 7, s_2_20, -1, 2, 0},
183 : { 5, s_2_21, -2, 1, 0},
184 : { 11, s_2_22, 0, 4, 0},
185 : { 10, s_2_23, 0, 2, 0},
186 : { 14, s_2_24, 0, 4, 0}
187 : };
188 :
189 : static const symbol s_3_0[4] = { 'i', 'm', 'i', 'd' };
190 : static const symbol s_3_1[5] = { 'a', 'i', 'm', 'i', 'd' };
191 : static const symbol s_3_2[5] = { 0xC3, 0xAD, 'm', 'i', 'd' };
192 : static const symbol s_3_3[6] = { 'a', 0xC3, 0xAD, 'm', 'i', 'd' };
193 : static const symbol s_3_4[3] = { 'a', 'd', 'h' };
194 : static const symbol s_3_5[4] = { 'e', 'a', 'd', 'h' };
195 : static const symbol s_3_6[5] = { 'f', 'a', 'i', 'd', 'h' };
196 : static const symbol s_3_7[4] = { 'f', 'i', 'd', 'h' };
197 : static const symbol s_3_8[4] = { 0xC3, 0xA1, 'i', 'l' };
198 : static const symbol s_3_9[3] = { 'a', 'i', 'n' };
199 : static const symbol s_3_10[4] = { 't', 'e', 'a', 'r' };
200 : static const symbol s_3_11[3] = { 't', 'a', 'r' };
201 : static const struct among a_3[12] = {
202 : { 4, s_3_0, 0, 1, 0},
203 : { 5, s_3_1, -1, 1, 0},
204 : { 5, s_3_2, 0, 1, 0},
205 : { 6, s_3_3, -1, 1, 0},
206 : { 3, s_3_4, 0, 2, 0},
207 : { 4, s_3_5, -1, 2, 0},
208 : { 5, s_3_6, 0, 1, 0},
209 : { 4, s_3_7, 0, 1, 0},
210 : { 4, s_3_8, 0, 2, 0},
211 : { 3, s_3_9, 0, 2, 0},
212 : { 4, s_3_10, 0, 2, 0},
213 : { 3, s_3_11, 0, 2, 0}
214 : };
215 :
216 : static const unsigned char g_v[] = { 17, 65, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 17, 4, 2 };
217 :
218 0 : static int r_mark_regions(struct SN_env * z) {
219 0 : ((SN_local *)z)->i_pV = z->l;
220 0 : ((SN_local *)z)->i_p1 = z->l;
221 0 : ((SN_local *)z)->i_p2 = z->l;
222 : {
223 0 : int v_1 = z->c;
224 : {
225 0 : int ret = out_grouping_U(z, g_v, 97, 250, 1);
226 0 : if (ret < 0) goto lab0;
227 0 : z->c += ret;
228 : }
229 0 : ((SN_local *)z)->i_pV = z->c;
230 : {
231 0 : int ret = in_grouping_U(z, g_v, 97, 250, 1);
232 0 : if (ret < 0) goto lab0;
233 0 : z->c += ret;
234 : }
235 0 : ((SN_local *)z)->i_p1 = z->c;
236 : {
237 0 : int ret = out_grouping_U(z, g_v, 97, 250, 1);
238 0 : if (ret < 0) goto lab0;
239 0 : z->c += ret;
240 : }
241 : {
242 0 : int ret = in_grouping_U(z, g_v, 97, 250, 1);
243 0 : if (ret < 0) goto lab0;
244 0 : z->c += ret;
245 : }
246 0 : ((SN_local *)z)->i_p2 = z->c;
247 0 : lab0:
248 0 : z->c = v_1;
249 : }
250 0 : return 1;
251 : }
252 :
253 0 : static int r_initial_morph(struct SN_env * z) {
254 : int among_var;
255 0 : z->bra = z->c;
256 0 : among_var = find_among(z, a_0, 24, 0);
257 0 : if (!among_var) return 0;
258 0 : z->ket = z->c;
259 0 : switch (among_var) {
260 0 : case 1:
261 : {
262 0 : int ret = slice_del(z);
263 0 : if (ret < 0) return ret;
264 : }
265 0 : break;
266 0 : case 2:
267 : {
268 0 : int ret = slice_from_s(z, 1, s_0);
269 0 : if (ret < 0) return ret;
270 : }
271 0 : break;
272 0 : case 3:
273 : {
274 0 : int ret = slice_from_s(z, 1, s_1);
275 0 : if (ret < 0) return ret;
276 : }
277 0 : break;
278 0 : case 4:
279 : {
280 0 : int ret = slice_from_s(z, 1, s_2);
281 0 : if (ret < 0) return ret;
282 : }
283 0 : break;
284 0 : case 5:
285 : {
286 0 : int ret = slice_from_s(z, 1, s_3);
287 0 : if (ret < 0) return ret;
288 : }
289 0 : break;
290 0 : case 6:
291 : {
292 0 : int ret = slice_from_s(z, 1, s_4);
293 0 : if (ret < 0) return ret;
294 : }
295 0 : break;
296 0 : case 7:
297 : {
298 0 : int ret = slice_from_s(z, 1, s_5);
299 0 : if (ret < 0) return ret;
300 : }
301 0 : break;
302 0 : case 8:
303 : {
304 0 : int ret = slice_from_s(z, 1, s_6);
305 0 : if (ret < 0) return ret;
306 : }
307 0 : break;
308 0 : case 9:
309 : {
310 0 : int ret = slice_from_s(z, 1, s_7);
311 0 : if (ret < 0) return ret;
312 : }
313 0 : break;
314 0 : case 10:
315 : {
316 0 : int ret = slice_from_s(z, 1, s_8);
317 0 : if (ret < 0) return ret;
318 : }
319 0 : break;
320 : }
321 0 : return 1;
322 : }
323 :
324 0 : static int r_RV(struct SN_env * z) {
325 0 : return ((SN_local *)z)->i_pV <= z->c;
326 : }
327 :
328 0 : static int r_R1(struct SN_env * z) {
329 0 : return ((SN_local *)z)->i_p1 <= z->c;
330 : }
331 :
332 0 : static int r_R2(struct SN_env * z) {
333 0 : return ((SN_local *)z)->i_p2 <= z->c;
334 : }
335 :
336 0 : static int r_noun_sfx(struct SN_env * z) {
337 : int among_var;
338 0 : z->ket = z->c;
339 0 : among_var = find_among_b(z, a_1, 16, 0);
340 0 : if (!among_var) return 0;
341 0 : z->bra = z->c;
342 0 : switch (among_var) {
343 0 : case 1:
344 : {
345 0 : int ret = r_R1(z);
346 0 : if (ret <= 0) return ret;
347 : }
348 : {
349 0 : int ret = slice_del(z);
350 0 : if (ret < 0) return ret;
351 : }
352 0 : break;
353 0 : case 2:
354 : {
355 0 : int ret = r_R2(z);
356 0 : if (ret <= 0) return ret;
357 : }
358 : {
359 0 : int ret = slice_del(z);
360 0 : if (ret < 0) return ret;
361 : }
362 0 : break;
363 : }
364 0 : return 1;
365 : }
366 :
367 0 : static int r_deriv(struct SN_env * z) {
368 : int among_var;
369 0 : z->ket = z->c;
370 0 : among_var = find_among_b(z, a_2, 25, 0);
371 0 : if (!among_var) return 0;
372 0 : z->bra = z->c;
373 0 : switch (among_var) {
374 0 : case 1:
375 : {
376 0 : int ret = r_R2(z);
377 0 : if (ret <= 0) return ret;
378 : }
379 : {
380 0 : int ret = slice_del(z);
381 0 : if (ret < 0) return ret;
382 : }
383 0 : break;
384 0 : case 2:
385 : {
386 0 : int ret = slice_from_s(z, 3, s_9);
387 0 : if (ret < 0) return ret;
388 : }
389 0 : break;
390 0 : case 3:
391 : {
392 0 : int ret = slice_from_s(z, 3, s_10);
393 0 : if (ret < 0) return ret;
394 : }
395 0 : break;
396 0 : case 4:
397 : {
398 0 : int ret = slice_from_s(z, 4, s_11);
399 0 : if (ret < 0) return ret;
400 : }
401 0 : break;
402 0 : case 5:
403 : {
404 0 : int ret = slice_from_s(z, 5, s_12);
405 0 : if (ret < 0) return ret;
406 : }
407 0 : break;
408 0 : case 6:
409 : {
410 0 : int ret = slice_from_s(z, 4, s_13);
411 0 : if (ret < 0) return ret;
412 : }
413 0 : break;
414 : }
415 0 : return 1;
416 : }
417 :
418 0 : static int r_verb_sfx(struct SN_env * z) {
419 : int among_var;
420 0 : z->ket = z->c;
421 0 : if (z->c - 2 <= z->lb || z->p[z->c - 1] >> 5 != 3 || !((282896 >> (z->p[z->c - 1] & 0x1f)) & 1)) return 0;
422 0 : among_var = find_among_b(z, a_3, 12, 0);
423 0 : if (!among_var) return 0;
424 0 : z->bra = z->c;
425 0 : switch (among_var) {
426 0 : case 1:
427 : {
428 0 : int ret = r_RV(z);
429 0 : if (ret <= 0) return ret;
430 : }
431 : {
432 0 : int ret = slice_del(z);
433 0 : if (ret < 0) return ret;
434 : }
435 0 : break;
436 0 : case 2:
437 : {
438 0 : int ret = r_R1(z);
439 0 : if (ret <= 0) return ret;
440 : }
441 : {
442 0 : int ret = slice_del(z);
443 0 : if (ret < 0) return ret;
444 : }
445 0 : break;
446 : }
447 0 : return 1;
448 : }
449 :
450 0 : extern int irish_UTF_8_stem(struct SN_env * z) {
451 : {
452 0 : int v_1 = z->c;
453 : {
454 0 : int ret = r_initial_morph(z);
455 0 : if (ret < 0) return ret;
456 : }
457 0 : z->c = v_1;
458 : }
459 : {
460 0 : int ret = r_mark_regions(z);
461 0 : if (ret < 0) return ret;
462 : }
463 0 : z->lb = z->c; z->c = z->l;
464 : {
465 0 : int v_2 = z->l - z->c;
466 : {
467 0 : int ret = r_noun_sfx(z);
468 0 : if (ret < 0) return ret;
469 : }
470 0 : z->c = z->l - v_2;
471 : }
472 : {
473 0 : int v_3 = z->l - z->c;
474 : {
475 0 : int ret = r_deriv(z);
476 0 : if (ret < 0) return ret;
477 : }
478 0 : z->c = z->l - v_3;
479 : }
480 : {
481 0 : int v_4 = z->l - z->c;
482 : {
483 0 : int ret = r_verb_sfx(z);
484 0 : if (ret < 0) return ret;
485 : }
486 0 : z->c = z->l - v_4;
487 : }
488 0 : z->c = z->lb;
489 0 : return 1;
490 : }
491 :
492 0 : extern struct SN_env * irish_UTF_8_create_env(void) {
493 0 : struct SN_env * z = SN_new_env(sizeof(SN_local));
494 0 : if (z) {
495 0 : ((SN_local *)z)->i_p2 = 0;
496 0 : ((SN_local *)z)->i_p1 = 0;
497 0 : ((SN_local *)z)->i_pV = 0;
498 : }
499 0 : return z;
500 : }
501 :
502 0 : extern void irish_UTF_8_close_env(struct SN_env * z) {
503 0 : SN_delete_env(z);
504 0 : }
505 :
|