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