Line data Source code
1 : /* Generated from swedish.sbl by Snowball 3.0.0 - https://snowballstem.org/ */
2 :
3 : #include "stem_ISO_8859_1_swedish.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_p1;
12 : };
13 :
14 : typedef struct SN_local SN_local;
15 :
16 : #ifdef __cplusplus
17 : extern "C" {
18 : #endif
19 : extern int swedish_ISO_8859_1_stem(struct SN_env * z);
20 : #ifdef __cplusplus
21 : }
22 : #endif
23 :
24 : static int r_other_suffix(struct SN_env * z);
25 : static int r_consonant_pair(struct SN_env * z);
26 : static int r_main_suffix(struct SN_env * z);
27 : static int r_mark_regions(struct SN_env * z);
28 : static int r_et_condition(struct SN_env * z);
29 :
30 : static const symbol s_0[] = { 'e', 't' };
31 : static const symbol s_1[] = { 0xF6, 's' };
32 : static const symbol s_2[] = { 'f', 'u', 'l', 'l' };
33 :
34 : static const symbol s_0_0[3] = { 'f', 'a', 'b' };
35 : static const symbol s_0_1[1] = { 'h' };
36 : static const symbol s_0_2[3] = { 'p', 'a', 'k' };
37 : static const symbol s_0_3[3] = { 'r', 'a', 'k' };
38 : static const symbol s_0_4[4] = { 's', 't', 'a', 'k' };
39 : static const symbol s_0_5[3] = { 'k', 'o', 'm' };
40 : static const symbol s_0_6[3] = { 'i', 'e', 't' };
41 : static const symbol s_0_7[3] = { 'c', 'i', 't' };
42 : static const symbol s_0_8[3] = { 'd', 'i', 't' };
43 : static const symbol s_0_9[4] = { 'a', 'l', 'i', 't' };
44 : static const symbol s_0_10[4] = { 'i', 'l', 'i', 't' };
45 : static const symbol s_0_11[3] = { 'm', 'i', 't' };
46 : static const symbol s_0_12[3] = { 'n', 'i', 't' };
47 : static const symbol s_0_13[3] = { 'p', 'i', 't' };
48 : static const symbol s_0_14[3] = { 'r', 'i', 't' };
49 : static const symbol s_0_15[3] = { 's', 'i', 't' };
50 : static const symbol s_0_16[3] = { 't', 'i', 't' };
51 : static const symbol s_0_17[3] = { 'u', 'i', 't' };
52 : static const symbol s_0_18[4] = { 'i', 'v', 'i', 't' };
53 : static const symbol s_0_19[4] = { 'k', 'v', 'i', 't' };
54 : static const symbol s_0_20[3] = { 'x', 'i', 't' };
55 : static const struct among a_0[21] = {
56 : { 3, s_0_0, 0, -1, 0},
57 : { 1, s_0_1, 0, -1, 0},
58 : { 3, s_0_2, 0, -1, 0},
59 : { 3, s_0_3, 0, -1, 0},
60 : { 4, s_0_4, 0, -1, 0},
61 : { 3, s_0_5, 0, -1, 0},
62 : { 3, s_0_6, 0, -1, 0},
63 : { 3, s_0_7, 0, -1, 0},
64 : { 3, s_0_8, 0, -1, 0},
65 : { 4, s_0_9, 0, -1, 0},
66 : { 4, s_0_10, 0, -1, 0},
67 : { 3, s_0_11, 0, -1, 0},
68 : { 3, s_0_12, 0, -1, 0},
69 : { 3, s_0_13, 0, -1, 0},
70 : { 3, s_0_14, 0, -1, 0},
71 : { 3, s_0_15, 0, -1, 0},
72 : { 3, s_0_16, 0, -1, 0},
73 : { 3, s_0_17, 0, -1, 0},
74 : { 4, s_0_18, 0, -1, 0},
75 : { 4, s_0_19, 0, -1, 0},
76 : { 3, s_0_20, 0, -1, 0}
77 : };
78 :
79 : static const symbol s_1_0[1] = { 'a' };
80 : static const symbol s_1_1[4] = { 'a', 'r', 'n', 'a' };
81 : static const symbol s_1_2[4] = { 'e', 'r', 'n', 'a' };
82 : static const symbol s_1_3[7] = { 'h', 'e', 't', 'e', 'r', 'n', 'a' };
83 : static const symbol s_1_4[4] = { 'o', 'r', 'n', 'a' };
84 : static const symbol s_1_5[2] = { 'a', 'd' };
85 : static const symbol s_1_6[1] = { 'e' };
86 : static const symbol s_1_7[3] = { 'a', 'd', 'e' };
87 : static const symbol s_1_8[4] = { 'a', 'n', 'd', 'e' };
88 : static const symbol s_1_9[4] = { 'a', 'r', 'n', 'e' };
89 : static const symbol s_1_10[3] = { 'a', 'r', 'e' };
90 : static const symbol s_1_11[4] = { 'a', 's', 't', 'e' };
91 : static const symbol s_1_12[2] = { 'e', 'n' };
92 : static const symbol s_1_13[5] = { 'a', 'n', 'd', 'e', 'n' };
93 : static const symbol s_1_14[4] = { 'a', 'r', 'e', 'n' };
94 : static const symbol s_1_15[5] = { 'h', 'e', 't', 'e', 'n' };
95 : static const symbol s_1_16[3] = { 'e', 'r', 'n' };
96 : static const symbol s_1_17[2] = { 'a', 'r' };
97 : static const symbol s_1_18[2] = { 'e', 'r' };
98 : static const symbol s_1_19[5] = { 'h', 'e', 't', 'e', 'r' };
99 : static const symbol s_1_20[2] = { 'o', 'r' };
100 : static const symbol s_1_21[1] = { 's' };
101 : static const symbol s_1_22[2] = { 'a', 's' };
102 : static const symbol s_1_23[5] = { 'a', 'r', 'n', 'a', 's' };
103 : static const symbol s_1_24[5] = { 'e', 'r', 'n', 'a', 's' };
104 : static const symbol s_1_25[5] = { 'o', 'r', 'n', 'a', 's' };
105 : static const symbol s_1_26[2] = { 'e', 's' };
106 : static const symbol s_1_27[4] = { 'a', 'd', 'e', 's' };
107 : static const symbol s_1_28[5] = { 'a', 'n', 'd', 'e', 's' };
108 : static const symbol s_1_29[3] = { 'e', 'n', 's' };
109 : static const symbol s_1_30[5] = { 'a', 'r', 'e', 'n', 's' };
110 : static const symbol s_1_31[6] = { 'h', 'e', 't', 'e', 'n', 's' };
111 : static const symbol s_1_32[4] = { 'e', 'r', 'n', 's' };
112 : static const symbol s_1_33[2] = { 'a', 't' };
113 : static const symbol s_1_34[2] = { 'e', 't' };
114 : static const symbol s_1_35[5] = { 'a', 'n', 'd', 'e', 't' };
115 : static const symbol s_1_36[3] = { 'h', 'e', 't' };
116 : static const symbol s_1_37[3] = { 'a', 's', 't' };
117 : static const struct among a_1[38] = {
118 : { 1, s_1_0, 0, 1, 0},
119 : { 4, s_1_1, -1, 1, 0},
120 : { 4, s_1_2, -2, 1, 0},
121 : { 7, s_1_3, -1, 1, 0},
122 : { 4, s_1_4, -4, 1, 0},
123 : { 2, s_1_5, 0, 1, 0},
124 : { 1, s_1_6, 0, 1, 0},
125 : { 3, s_1_7, -1, 1, 0},
126 : { 4, s_1_8, -2, 1, 0},
127 : { 4, s_1_9, -3, 1, 0},
128 : { 3, s_1_10, -4, 1, 0},
129 : { 4, s_1_11, -5, 1, 0},
130 : { 2, s_1_12, 0, 1, 0},
131 : { 5, s_1_13, -1, 1, 0},
132 : { 4, s_1_14, -2, 1, 0},
133 : { 5, s_1_15, -3, 1, 0},
134 : { 3, s_1_16, 0, 1, 0},
135 : { 2, s_1_17, 0, 1, 0},
136 : { 2, s_1_18, 0, 1, 0},
137 : { 5, s_1_19, -1, 1, 0},
138 : { 2, s_1_20, 0, 1, 0},
139 : { 1, s_1_21, 0, 2, 0},
140 : { 2, s_1_22, -1, 1, 0},
141 : { 5, s_1_23, -1, 1, 0},
142 : { 5, s_1_24, -2, 1, 0},
143 : { 5, s_1_25, -3, 1, 0},
144 : { 2, s_1_26, -5, 1, 0},
145 : { 4, s_1_27, -1, 1, 0},
146 : { 5, s_1_28, -2, 1, 0},
147 : { 3, s_1_29, -8, 1, 0},
148 : { 5, s_1_30, -1, 1, 0},
149 : { 6, s_1_31, -2, 1, 0},
150 : { 4, s_1_32, -11, 1, 0},
151 : { 2, s_1_33, 0, 1, 0},
152 : { 2, s_1_34, 0, 3, 0},
153 : { 5, s_1_35, -1, 1, 0},
154 : { 3, s_1_36, -2, 1, 0},
155 : { 3, s_1_37, 0, 1, 0}
156 : };
157 :
158 : static const symbol s_2_0[2] = { 'd', 'd' };
159 : static const symbol s_2_1[2] = { 'g', 'd' };
160 : static const symbol s_2_2[2] = { 'n', 'n' };
161 : static const symbol s_2_3[2] = { 'd', 't' };
162 : static const symbol s_2_4[2] = { 'g', 't' };
163 : static const symbol s_2_5[2] = { 'k', 't' };
164 : static const symbol s_2_6[2] = { 't', 't' };
165 : static const struct among a_2[7] = {
166 : { 2, s_2_0, 0, -1, 0},
167 : { 2, s_2_1, 0, -1, 0},
168 : { 2, s_2_2, 0, -1, 0},
169 : { 2, s_2_3, 0, -1, 0},
170 : { 2, s_2_4, 0, -1, 0},
171 : { 2, s_2_5, 0, -1, 0},
172 : { 2, s_2_6, 0, -1, 0}
173 : };
174 :
175 : static const symbol s_3_0[2] = { 'i', 'g' };
176 : static const symbol s_3_1[3] = { 'l', 'i', 'g' };
177 : static const symbol s_3_2[3] = { 'e', 'l', 's' };
178 : static const symbol s_3_3[5] = { 'f', 'u', 'l', 'l', 't' };
179 : static const symbol s_3_4[3] = { 0xF6, 's', 't' };
180 : static const struct among a_3[5] = {
181 : { 2, s_3_0, 0, 1, 0},
182 : { 3, s_3_1, -1, 1, 0},
183 : { 3, s_3_2, 0, 1, 0},
184 : { 5, s_3_3, 0, 3, 0},
185 : { 3, s_3_4, 0, 2, 0}
186 : };
187 :
188 : static const unsigned char g_v[] = { 17, 65, 16, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 32 };
189 :
190 : static const unsigned char g_s_ending[] = { 119, 127, 149 };
191 :
192 : static const unsigned char g_ost_ending[] = { 173, 58 };
193 :
194 0 : static int r_mark_regions(struct SN_env * z) {
195 : int i_x;
196 0 : ((SN_local *)z)->i_p1 = z->l;
197 : {
198 0 : int v_1 = z->c;
199 0 : if (z->c + 3 > z->l) return 0;
200 0 : z->c += 3;
201 0 : i_x = z->c;
202 0 : z->c = v_1;
203 : }
204 : {
205 0 : int ret = out_grouping(z, g_v, 97, 246, 1);
206 0 : if (ret < 0) return 0;
207 0 : z->c += ret;
208 : }
209 : {
210 0 : int ret = in_grouping(z, g_v, 97, 246, 1);
211 0 : if (ret < 0) return 0;
212 0 : z->c += ret;
213 : }
214 0 : ((SN_local *)z)->i_p1 = z->c;
215 0 : if (((SN_local *)z)->i_p1 >= i_x) goto lab0;
216 0 : ((SN_local *)z)->i_p1 = i_x;
217 0 : lab0:
218 0 : return 1;
219 : }
220 :
221 0 : static int r_et_condition(struct SN_env * z) {
222 : {
223 0 : int v_1 = z->l - z->c;
224 0 : if (out_grouping_b(z, g_v, 97, 246, 0)) return 0;
225 0 : if (in_grouping_b(z, g_v, 97, 246, 0)) return 0;
226 0 : if (z->c > z->lb) goto lab0;
227 0 : return 0;
228 0 : lab0:
229 0 : z->c = z->l - v_1;
230 : {
231 0 : int v_2 = z->l - z->c;
232 0 : if (z->c <= z->lb || z->p[z->c - 1] >> 5 != 3 || !((1059076 >> (z->p[z->c - 1] & 0x1f)) & 1)) goto lab1;
233 0 : if (!find_among_b(z, a_0, 21, 0)) goto lab1;
234 0 : return 0;
235 0 : lab1:
236 0 : z->c = z->l - v_2;
237 : }
238 : }
239 0 : return 1;
240 : }
241 :
242 0 : static int r_main_suffix(struct SN_env * z) {
243 : int among_var;
244 : {
245 : int v_1;
246 0 : if (z->c < ((SN_local *)z)->i_p1) return 0;
247 0 : v_1 = z->lb; z->lb = ((SN_local *)z)->i_p1;
248 0 : z->ket = z->c;
249 0 : if (z->c <= z->lb || z->p[z->c - 1] >> 5 != 3 || !((1851442 >> (z->p[z->c - 1] & 0x1f)) & 1)) { z->lb = v_1; return 0; }
250 0 : among_var = find_among_b(z, a_1, 38, 0);
251 0 : if (!among_var) { z->lb = v_1; return 0; }
252 0 : z->bra = z->c;
253 0 : z->lb = v_1;
254 : }
255 0 : switch (among_var) {
256 0 : case 1:
257 : {
258 0 : int ret = slice_del(z);
259 0 : if (ret < 0) return ret;
260 : }
261 0 : break;
262 0 : case 2:
263 : do {
264 0 : int v_2 = z->l - z->c;
265 0 : if (!(eq_s_b(z, 2, s_0))) goto lab0;
266 : {
267 0 : int ret = r_et_condition(z);
268 0 : if (ret == 0) goto lab0;
269 0 : if (ret < 0) return ret;
270 : }
271 0 : z->bra = z->c;
272 0 : break;
273 0 : lab0:
274 0 : z->c = z->l - v_2;
275 0 : if (in_grouping_b(z, g_s_ending, 98, 121, 0)) return 0;
276 : } while (0);
277 : {
278 0 : int ret = slice_del(z);
279 0 : if (ret < 0) return ret;
280 : }
281 0 : break;
282 0 : case 3:
283 : {
284 0 : int ret = r_et_condition(z);
285 0 : if (ret <= 0) return ret;
286 : }
287 : {
288 0 : int ret = slice_del(z);
289 0 : if (ret < 0) return ret;
290 : }
291 0 : break;
292 : }
293 0 : return 1;
294 : }
295 :
296 0 : static int r_consonant_pair(struct SN_env * z) {
297 : {
298 : int v_1;
299 0 : if (z->c < ((SN_local *)z)->i_p1) return 0;
300 0 : v_1 = z->lb; z->lb = ((SN_local *)z)->i_p1;
301 : {
302 0 : int v_2 = z->l - z->c;
303 0 : if (z->c - 1 <= z->lb || z->p[z->c - 1] >> 5 != 3 || !((1064976 >> (z->p[z->c - 1] & 0x1f)) & 1)) { z->lb = v_1; return 0; }
304 0 : if (!find_among_b(z, a_2, 7, 0)) { z->lb = v_1; return 0; }
305 0 : z->c = z->l - v_2;
306 0 : z->ket = z->c;
307 0 : if (z->c <= z->lb) { z->lb = v_1; return 0; }
308 0 : z->c--;
309 0 : z->bra = z->c;
310 : {
311 0 : int ret = slice_del(z);
312 0 : if (ret < 0) return ret;
313 : }
314 : }
315 0 : z->lb = v_1;
316 : }
317 0 : return 1;
318 : }
319 :
320 0 : static int r_other_suffix(struct SN_env * z) {
321 : int among_var;
322 : {
323 : int v_1;
324 0 : if (z->c < ((SN_local *)z)->i_p1) return 0;
325 0 : v_1 = z->lb; z->lb = ((SN_local *)z)->i_p1;
326 0 : z->ket = z->c;
327 0 : if (z->c - 1 <= z->lb || z->p[z->c - 1] >> 5 != 3 || !((1572992 >> (z->p[z->c - 1] & 0x1f)) & 1)) { z->lb = v_1; return 0; }
328 0 : among_var = find_among_b(z, a_3, 5, 0);
329 0 : if (!among_var) { z->lb = v_1; return 0; }
330 0 : z->bra = z->c;
331 0 : z->lb = v_1;
332 : }
333 0 : switch (among_var) {
334 0 : case 1:
335 : {
336 0 : int ret = slice_del(z);
337 0 : if (ret < 0) return ret;
338 : }
339 0 : break;
340 0 : case 2:
341 0 : if (in_grouping_b(z, g_ost_ending, 105, 118, 0)) return 0;
342 : {
343 0 : int ret = slice_from_s(z, 2, s_1);
344 0 : if (ret < 0) return ret;
345 : }
346 0 : break;
347 0 : case 3:
348 : {
349 0 : int ret = slice_from_s(z, 4, s_2);
350 0 : if (ret < 0) return ret;
351 : }
352 0 : break;
353 : }
354 0 : return 1;
355 : }
356 :
357 0 : extern int swedish_ISO_8859_1_stem(struct SN_env * z) {
358 : {
359 0 : int v_1 = z->c;
360 : {
361 0 : int ret = r_mark_regions(z);
362 0 : if (ret < 0) return ret;
363 : }
364 0 : z->c = v_1;
365 : }
366 0 : z->lb = z->c; z->c = z->l;
367 : {
368 0 : int v_2 = z->l - z->c;
369 : {
370 0 : int ret = r_main_suffix(z);
371 0 : if (ret < 0) return ret;
372 : }
373 0 : z->c = z->l - v_2;
374 : }
375 : {
376 0 : int v_3 = z->l - z->c;
377 : {
378 0 : int ret = r_consonant_pair(z);
379 0 : if (ret < 0) return ret;
380 : }
381 0 : z->c = z->l - v_3;
382 : }
383 : {
384 0 : int v_4 = z->l - z->c;
385 : {
386 0 : int ret = r_other_suffix(z);
387 0 : if (ret < 0) return ret;
388 : }
389 0 : z->c = z->l - v_4;
390 : }
391 0 : z->c = z->lb;
392 0 : return 1;
393 : }
394 :
395 0 : extern struct SN_env * swedish_ISO_8859_1_create_env(void) {
396 0 : struct SN_env * z = SN_new_env(sizeof(SN_local));
397 0 : if (z) {
398 0 : ((SN_local *)z)->i_p1 = 0;
399 : }
400 0 : return z;
401 : }
402 :
403 0 : extern void swedish_ISO_8859_1_close_env(struct SN_env * z) {
404 0 : SN_delete_env(z);
405 0 : }
406 :
|