PostgreSQL Source Code git master
stem_UTF_8_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_UTF_8_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[] = { 0xC3, 0xB6, '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[4] = { 0xC3, 0xB6, '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{ 4, 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 {
200 int ret = skip_utf8(z->p, z->c, z->l, 3);
201 if (ret < 0) return 0;
202 z->c = ret;
203 }
204 i_x = z->c;
205 z->c = v_1;
206 }
207 {
208 int ret = out_grouping_U(z, g_v, 97, 246, 1);
209 if (ret < 0) return 0;
210 z->c += ret;
211 }
212 {
213 int ret = in_grouping_U(z, g_v, 97, 246, 1);
214 if (ret < 0) return 0;
215 z->c += ret;
216 }
217 ((SN_local *)z)->i_p1 = z->c;
218 if (((SN_local *)z)->i_p1 >= i_x) goto lab0;
219 ((SN_local *)z)->i_p1 = i_x;
220lab0:
221 return 1;
222}
223
224static int r_et_condition(struct SN_env * z) {
225 {
226 int v_1 = z->l - z->c;
227 if (out_grouping_b_U(z, g_v, 97, 246, 0)) return 0;
228 if (in_grouping_b_U(z, g_v, 97, 246, 0)) return 0;
229 if (z->c > z->lb) goto lab0;
230 return 0;
231 lab0:
232 z->c = z->l - v_1;
233 {
234 int v_2 = z->l - z->c;
235 if (z->c <= z->lb || z->p[z->c - 1] >> 5 != 3 || !((1059076 >> (z->p[z->c - 1] & 0x1f)) & 1)) goto lab1;
236 if (!find_among_b(z, a_0, 21, 0)) goto lab1;
237 return 0;
238 lab1:
239 z->c = z->l - v_2;
240 }
241 }
242 return 1;
243}
244
245static int r_main_suffix(struct SN_env * z) {
246 int among_var;
247 {
248 int v_1;
249 if (z->c < ((SN_local *)z)->i_p1) return 0;
250 v_1 = z->lb; z->lb = ((SN_local *)z)->i_p1;
251 z->ket = z->c;
252 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; }
253 among_var = find_among_b(z, a_1, 38, 0);
254 if (!among_var) { z->lb = v_1; return 0; }
255 z->bra = z->c;
256 z->lb = v_1;
257 }
258 switch (among_var) {
259 case 1:
260 {
261 int ret = slice_del(z);
262 if (ret < 0) return ret;
263 }
264 break;
265 case 2:
266 do {
267 int v_2 = z->l - z->c;
268 if (!(eq_s_b(z, 2, s_0))) goto lab0;
269 {
270 int ret = r_et_condition(z);
271 if (ret == 0) goto lab0;
272 if (ret < 0) return ret;
273 }
274 z->bra = z->c;
275 break;
276 lab0:
277 z->c = z->l - v_2;
278 if (in_grouping_b_U(z, g_s_ending, 98, 121, 0)) return 0;
279 } while (0);
280 {
281 int ret = slice_del(z);
282 if (ret < 0) return ret;
283 }
284 break;
285 case 3:
286 {
287 int ret = r_et_condition(z);
288 if (ret <= 0) return ret;
289 }
290 {
291 int ret = slice_del(z);
292 if (ret < 0) return ret;
293 }
294 break;
295 }
296 return 1;
297}
298
299static int r_consonant_pair(struct SN_env * z) {
300 {
301 int v_1;
302 if (z->c < ((SN_local *)z)->i_p1) return 0;
303 v_1 = z->lb; z->lb = ((SN_local *)z)->i_p1;
304 {
305 int v_2 = z->l - z->c;
306 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; }
307 if (!find_among_b(z, a_2, 7, 0)) { z->lb = v_1; return 0; }
308 z->c = z->l - v_2;
309 z->ket = z->c;
310 {
311 int ret = skip_b_utf8(z->p, z->c, z->lb, 1);
312 if (ret < 0) { z->lb = v_1; return 0; }
313 z->c = ret;
314 }
315 z->bra = z->c;
316 {
317 int ret = slice_del(z);
318 if (ret < 0) return ret;
319 }
320 }
321 z->lb = v_1;
322 }
323 return 1;
324}
325
326static int r_other_suffix(struct SN_env * z) {
327 int among_var;
328 {
329 int v_1;
330 if (z->c < ((SN_local *)z)->i_p1) return 0;
331 v_1 = z->lb; z->lb = ((SN_local *)z)->i_p1;
332 z->ket = z->c;
333 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; }
334 among_var = find_among_b(z, a_3, 5, 0);
335 if (!among_var) { z->lb = v_1; return 0; }
336 z->bra = z->c;
337 z->lb = v_1;
338 }
339 switch (among_var) {
340 case 1:
341 {
342 int ret = slice_del(z);
343 if (ret < 0) return ret;
344 }
345 break;
346 case 2:
347 if (in_grouping_b_U(z, g_ost_ending, 105, 118, 0)) return 0;
348 {
349 int ret = slice_from_s(z, 3, s_1);
350 if (ret < 0) return ret;
351 }
352 break;
353 case 3:
354 {
355 int ret = slice_from_s(z, 4, s_2);
356 if (ret < 0) return ret;
357 }
358 break;
359 }
360 return 1;
361}
362
363extern int swedish_UTF_8_stem(struct SN_env * z) {
364 {
365 int v_1 = z->c;
366 {
367 int ret = r_mark_regions(z);
368 if (ret < 0) return ret;
369 }
370 z->c = v_1;
371 }
372 z->lb = z->c; z->c = z->l;
373 {
374 int v_2 = z->l - z->c;
375 {
376 int ret = r_main_suffix(z);
377 if (ret < 0) return ret;
378 }
379 z->c = z->l - v_2;
380 }
381 {
382 int v_3 = z->l - z->c;
383 {
384 int ret = r_consonant_pair(z);
385 if (ret < 0) return ret;
386 }
387 z->c = z->l - v_3;
388 }
389 {
390 int v_4 = z->l - z->c;
391 {
392 int ret = r_other_suffix(z);
393 if (ret < 0) return ret;
394 }
395 z->c = z->l - v_4;
396 }
397 z->c = z->lb;
398 return 1;
399}
400
401extern struct SN_env * swedish_UTF_8_create_env(void) {
402 struct SN_env * z = SN_new_env(sizeof(SN_local));
403 if (z) {
404 ((SN_local *)z)->i_p1 = 0;
405 }
406 return z;
407}
408
409extern void swedish_UTF_8_close_env(struct SN_env * z) {
410 SN_delete_env(z);
411}
412
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)
int swedish_UTF_8_stem(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)
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_3_4[4]
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]
struct SN_env * swedish_UTF_8_create_env(void)
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_UTF_8_close_env(struct SN_env *z)
static const symbol s_2_3[2]
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_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
int out_grouping_U(struct SN_env *z, const unsigned char *s, int min, int max, int repeat)
Definition: utilities.c:157
int in_grouping_U(struct SN_env *z, const unsigned char *s, int min, int max, int repeat)
Definition: utilities.c:133
SNOWBALL_ERR slice_from_s(struct SN_env *z, int s_size, const symbol *s)
Definition: utilities.c:432
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 in_grouping_b_U(struct SN_env *z, const unsigned char *s, int min, int max, int repeat)
Definition: utilities.c:145
int skip_b_utf8(const symbol *p, int c, int limit, int n)
Definition: utilities.c:68
int eq_s_b(struct SN_env *z, int s_size, const symbol *s)
Definition: utilities.c:236
SNOWBALL_ERR slice_del(struct SN_env *z)
Definition: utilities.c:443
int out_grouping_b_U(struct SN_env *z, const unsigned char *s, int min, int max, int repeat)
Definition: utilities.c:169
int skip_utf8(const symbol *p, int c, int limit, int n)
Definition: utilities.c:43