PostgreSQL Source Code git master
stem_UTF_8_danish.c
Go to the documentation of this file.
1/* Generated from danish.sbl by Snowball 3.0.0 - https://snowballstem.org/ */
2
3#include "stem_UTF_8_danish.h"
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 symbol * s_ch;
13};
14
15typedef struct SN_local SN_local;
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20extern int danish_UTF_8_stem(struct SN_env * z);
21#ifdef __cplusplus
22}
23#endif
24
25static int r_undouble(struct SN_env * z);
26static int r_other_suffix(struct SN_env * z);
27static int r_consonant_pair(struct SN_env * z);
28static int r_main_suffix(struct SN_env * z);
29static int r_mark_regions(struct SN_env * z);
30
31static const symbol s_0[] = { 's', 't' };
32static const symbol s_1[] = { 'i', 'g' };
33static const symbol s_2[] = { 'l', 0xC3, 0xB8, 's' };
34
35static const symbol s_0_0[3] = { 'h', 'e', 'd' };
36static const symbol s_0_1[5] = { 'e', 't', 'h', 'e', 'd' };
37static const symbol s_0_2[4] = { 'e', 'r', 'e', 'd' };
38static const symbol s_0_3[1] = { 'e' };
39static const symbol s_0_4[5] = { 'e', 'r', 'e', 'd', 'e' };
40static const symbol s_0_5[4] = { 'e', 'n', 'd', 'e' };
41static const symbol s_0_6[6] = { 'e', 'r', 'e', 'n', 'd', 'e' };
42static const symbol s_0_7[3] = { 'e', 'n', 'e' };
43static const symbol s_0_8[4] = { 'e', 'r', 'n', 'e' };
44static const symbol s_0_9[3] = { 'e', 'r', 'e' };
45static const symbol s_0_10[2] = { 'e', 'n' };
46static const symbol s_0_11[5] = { 'h', 'e', 'd', 'e', 'n' };
47static const symbol s_0_12[4] = { 'e', 'r', 'e', 'n' };
48static const symbol s_0_13[2] = { 'e', 'r' };
49static const symbol s_0_14[5] = { 'h', 'e', 'd', 'e', 'r' };
50static const symbol s_0_15[4] = { 'e', 'r', 'e', 'r' };
51static const symbol s_0_16[1] = { 's' };
52static const symbol s_0_17[4] = { 'h', 'e', 'd', 's' };
53static const symbol s_0_18[2] = { 'e', 's' };
54static const symbol s_0_19[5] = { 'e', 'n', 'd', 'e', 's' };
55static const symbol s_0_20[7] = { 'e', 'r', 'e', 'n', 'd', 'e', 's' };
56static const symbol s_0_21[4] = { 'e', 'n', 'e', 's' };
57static const symbol s_0_22[5] = { 'e', 'r', 'n', 'e', 's' };
58static const symbol s_0_23[4] = { 'e', 'r', 'e', 's' };
59static const symbol s_0_24[3] = { 'e', 'n', 's' };
60static const symbol s_0_25[6] = { 'h', 'e', 'd', 'e', 'n', 's' };
61static const symbol s_0_26[5] = { 'e', 'r', 'e', 'n', 's' };
62static const symbol s_0_27[3] = { 'e', 'r', 's' };
63static const symbol s_0_28[3] = { 'e', 't', 's' };
64static const symbol s_0_29[5] = { 'e', 'r', 'e', 't', 's' };
65static const symbol s_0_30[2] = { 'e', 't' };
66static const symbol s_0_31[4] = { 'e', 'r', 'e', 't' };
67static const struct among a_0[32] = {
68{ 3, s_0_0, 0, 1, 0},
69{ 5, s_0_1, -1, 1, 0},
70{ 4, s_0_2, 0, 1, 0},
71{ 1, s_0_3, 0, 1, 0},
72{ 5, s_0_4, -1, 1, 0},
73{ 4, s_0_5, -2, 1, 0},
74{ 6, s_0_6, -1, 1, 0},
75{ 3, s_0_7, -4, 1, 0},
76{ 4, s_0_8, -5, 1, 0},
77{ 3, s_0_9, -6, 1, 0},
78{ 2, s_0_10, 0, 1, 0},
79{ 5, s_0_11, -1, 1, 0},
80{ 4, s_0_12, -2, 1, 0},
81{ 2, s_0_13, 0, 1, 0},
82{ 5, s_0_14, -1, 1, 0},
83{ 4, s_0_15, -2, 1, 0},
84{ 1, s_0_16, 0, 2, 0},
85{ 4, s_0_17, -1, 1, 0},
86{ 2, s_0_18, -2, 1, 0},
87{ 5, s_0_19, -1, 1, 0},
88{ 7, s_0_20, -1, 1, 0},
89{ 4, s_0_21, -3, 1, 0},
90{ 5, s_0_22, -4, 1, 0},
91{ 4, s_0_23, -5, 1, 0},
92{ 3, s_0_24, -8, 1, 0},
93{ 6, s_0_25, -1, 1, 0},
94{ 5, s_0_26, -2, 1, 0},
95{ 3, s_0_27, -11, 1, 0},
96{ 3, s_0_28, -12, 1, 0},
97{ 5, s_0_29, -1, 1, 0},
98{ 2, s_0_30, 0, 1, 0},
99{ 4, s_0_31, -1, 1, 0}
100};
101
102static const symbol s_1_0[2] = { 'g', 'd' };
103static const symbol s_1_1[2] = { 'd', 't' };
104static const symbol s_1_2[2] = { 'g', 't' };
105static const symbol s_1_3[2] = { 'k', 't' };
106static const struct among a_1[4] = {
107{ 2, s_1_0, 0, -1, 0},
108{ 2, s_1_1, 0, -1, 0},
109{ 2, s_1_2, 0, -1, 0},
110{ 2, s_1_3, 0, -1, 0}
111};
112
113static const symbol s_2_0[2] = { 'i', 'g' };
114static const symbol s_2_1[3] = { 'l', 'i', 'g' };
115static const symbol s_2_2[4] = { 'e', 'l', 'i', 'g' };
116static const symbol s_2_3[3] = { 'e', 'l', 's' };
117static const symbol s_2_4[5] = { 'l', 0xC3, 0xB8, 's', 't' };
118static const struct among a_2[5] = {
119{ 2, s_2_0, 0, 1, 0},
120{ 3, s_2_1, -1, 1, 0},
121{ 4, s_2_2, -1, 1, 0},
122{ 3, s_2_3, 0, 1, 0},
123{ 5, s_2_4, 0, 2, 0}
124};
125
126static const unsigned char g_c[] = { 119, 223, 119, 1 };
127
128static const unsigned char g_v[] = { 17, 65, 16, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 48, 0, 128 };
129
130static const unsigned char g_s_ending[] = { 239, 254, 42, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16 };
131
132static int r_mark_regions(struct SN_env * z) {
133 int i_x;
134 ((SN_local *)z)->i_p1 = z->l;
135 {
136 int v_1 = z->c;
137 {
138 int ret = skip_utf8(z->p, z->c, z->l, 3);
139 if (ret < 0) return 0;
140 z->c = ret;
141 }
142 i_x = z->c;
143 z->c = v_1;
144 }
145 {
146 int ret = out_grouping_U(z, g_v, 97, 248, 1);
147 if (ret < 0) return 0;
148 z->c += ret;
149 }
150 {
151 int ret = in_grouping_U(z, g_v, 97, 248, 1);
152 if (ret < 0) return 0;
153 z->c += ret;
154 }
155 ((SN_local *)z)->i_p1 = z->c;
156 if (((SN_local *)z)->i_p1 >= i_x) goto lab0;
157 ((SN_local *)z)->i_p1 = i_x;
158lab0:
159 return 1;
160}
161
162static int r_main_suffix(struct SN_env * z) {
163 int among_var;
164 {
165 int v_1;
166 if (z->c < ((SN_local *)z)->i_p1) return 0;
167 v_1 = z->lb; z->lb = ((SN_local *)z)->i_p1;
168 z->ket = z->c;
169 if (z->c <= z->lb || z->p[z->c - 1] >> 5 != 3 || !((1851440 >> (z->p[z->c - 1] & 0x1f)) & 1)) { z->lb = v_1; return 0; }
170 among_var = find_among_b(z, a_0, 32, 0);
171 if (!among_var) { z->lb = v_1; return 0; }
172 z->bra = z->c;
173 z->lb = v_1;
174 }
175 switch (among_var) {
176 case 1:
177 {
178 int ret = slice_del(z);
179 if (ret < 0) return ret;
180 }
181 break;
182 case 2:
183 if (in_grouping_b_U(z, g_s_ending, 97, 229, 0)) return 0;
184 {
185 int ret = slice_del(z);
186 if (ret < 0) return ret;
187 }
188 break;
189 }
190 return 1;
191}
192
193static int r_consonant_pair(struct SN_env * z) {
194 {
195 int v_1 = z->l - z->c;
196 {
197 int v_2;
198 if (z->c < ((SN_local *)z)->i_p1) return 0;
199 v_2 = z->lb; z->lb = ((SN_local *)z)->i_p1;
200 z->ket = z->c;
201 if (z->c - 1 <= z->lb || (z->p[z->c - 1] != 100 && z->p[z->c - 1] != 116)) { z->lb = v_2; return 0; }
202 if (!find_among_b(z, a_1, 4, 0)) { z->lb = v_2; return 0; }
203 z->bra = z->c;
204 z->lb = v_2;
205 }
206 z->c = z->l - v_1;
207 }
208 {
209 int ret = skip_b_utf8(z->p, z->c, z->lb, 1);
210 if (ret < 0) return 0;
211 z->c = ret;
212 }
213 z->bra = z->c;
214 {
215 int ret = slice_del(z);
216 if (ret < 0) return ret;
217 }
218 return 1;
219}
220
221static int r_other_suffix(struct SN_env * z) {
222 int among_var;
223 {
224 int v_1 = z->l - z->c;
225 z->ket = z->c;
226 if (!(eq_s_b(z, 2, s_0))) goto lab0;
227 z->bra = z->c;
228 if (!(eq_s_b(z, 2, s_1))) goto lab0;
229 {
230 int ret = slice_del(z);
231 if (ret < 0) return ret;
232 }
233 lab0:
234 z->c = z->l - v_1;
235 }
236 {
237 int v_2;
238 if (z->c < ((SN_local *)z)->i_p1) return 0;
239 v_2 = z->lb; z->lb = ((SN_local *)z)->i_p1;
240 z->ket = z->c;
241 if (z->c - 1 <= z->lb || z->p[z->c - 1] >> 5 != 3 || !((1572992 >> (z->p[z->c - 1] & 0x1f)) & 1)) { z->lb = v_2; return 0; }
242 among_var = find_among_b(z, a_2, 5, 0);
243 if (!among_var) { z->lb = v_2; return 0; }
244 z->bra = z->c;
245 z->lb = v_2;
246 }
247 switch (among_var) {
248 case 1:
249 {
250 int ret = slice_del(z);
251 if (ret < 0) return ret;
252 }
253 {
254 int v_3 = z->l - z->c;
255 {
256 int ret = r_consonant_pair(z);
257 if (ret < 0) return ret;
258 }
259 z->c = z->l - v_3;
260 }
261 break;
262 case 2:
263 {
264 int ret = slice_from_s(z, 4, s_2);
265 if (ret < 0) return ret;
266 }
267 break;
268 }
269 return 1;
270}
271
272static int r_undouble(struct SN_env * z) {
273 {
274 int v_1;
275 if (z->c < ((SN_local *)z)->i_p1) return 0;
276 v_1 = z->lb; z->lb = ((SN_local *)z)->i_p1;
277 z->ket = z->c;
278 if (in_grouping_b_U(z, g_c, 98, 122, 0)) { z->lb = v_1; return 0; }
279 z->bra = z->c;
280 {
281 int ret = slice_to(z, &((SN_local *)z)->s_ch);
282 if (ret < 0) return ret;
283 }
284 z->lb = v_1;
285 }
286 if (!(eq_v_b(z, ((SN_local *)z)->s_ch))) return 0;
287 {
288 int ret = slice_del(z);
289 if (ret < 0) return ret;
290 }
291 return 1;
292}
293
294extern int danish_UTF_8_stem(struct SN_env * z) {
295 {
296 int v_1 = z->c;
297 {
298 int ret = r_mark_regions(z);
299 if (ret < 0) return ret;
300 }
301 z->c = v_1;
302 }
303 z->lb = z->c; z->c = z->l;
304 {
305 int v_2 = z->l - z->c;
306 {
307 int ret = r_main_suffix(z);
308 if (ret < 0) return ret;
309 }
310 z->c = z->l - v_2;
311 }
312 {
313 int v_3 = z->l - z->c;
314 {
315 int ret = r_consonant_pair(z);
316 if (ret < 0) return ret;
317 }
318 z->c = z->l - v_3;
319 }
320 {
321 int v_4 = z->l - z->c;
322 {
323 int ret = r_other_suffix(z);
324 if (ret < 0) return ret;
325 }
326 z->c = z->l - v_4;
327 }
328 {
329 int v_5 = z->l - z->c;
330 {
331 int ret = r_undouble(z);
332 if (ret < 0) return ret;
333 }
334 z->c = z->l - v_5;
335 }
336 z->c = z->lb;
337 return 1;
338}
339
340extern struct SN_env * danish_UTF_8_create_env(void) {
341 struct SN_env * z = SN_new_env(sizeof(SN_local));
342 if (z) {
343 ((SN_local *)z)->i_p1 = 0;
344 ((SN_local *)z)->s_ch = NULL;
345
346 if ((((SN_local *)z)->s_ch = create_s()) == NULL) {
348 return NULL;
349 }
350 }
351 return z;
352}
353
354extern void danish_UTF_8_close_env(struct SN_env * z) {
355 if (z) {
356 lose_s(((SN_local *)z)->s_ch);
357 }
358 SN_delete_env(z);
359}
360
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_0_24[3]
static const struct among a_2[5]
static const symbol s_0_2[4]
static const symbol s_2[]
static const symbol s_0_15[4]
static const unsigned char g_c[]
static const struct among a_0[32]
static const symbol s_0_13[2]
static const symbol s_0_20[7]
static const symbol s_1_2[2]
static const symbol s_0_14[5]
static int r_other_suffix(struct SN_env *z)
static int r_consonant_pair(struct SN_env *z)
static const symbol s_0_12[4]
static const symbol s_2_3[3]
static const symbol s_0_31[4]
static const symbol s_2_0[2]
static int r_main_suffix(struct SN_env *z)
static const struct among a_1[4]
static const symbol s_1_3[2]
static const symbol s_2_1[3]
static const symbol s_1_0[2]
void danish_UTF_8_close_env(struct SN_env *z)
static const symbol s_0_5[4]
static const symbol s_2_2[4]
static const symbol s_0_11[5]
static const symbol s_0_1[5]
static const symbol s_0_30[2]
static const symbol s_2_4[5]
static const symbol s_0_17[4]
static const symbol s_1_1[2]
static const symbol s_0_0[3]
static int r_undouble(struct SN_env *z)
int danish_UTF_8_stem(struct SN_env *z)
static const symbol s_0_19[5]
static const symbol s_0_18[2]
static const symbol s_0_23[4]
static const symbol s_0_27[3]
static const symbol s_0_16[1]
static const symbol s_0_28[3]
static const symbol s_0_29[5]
static const symbol s_0_9[3]
struct SN_env * danish_UTF_8_create_env(void)
static const symbol s_0_22[5]
static const symbol s_1[]
static int r_mark_regions(struct SN_env *z)
static const symbol s_0_3[1]
static const symbol s_0_6[6]
static const symbol s_0_8[4]
static const symbol s_0_25[6]
static const symbol s_0_7[3]
static const symbol s_0_26[5]
static const symbol s_0_10[2]
static const unsigned char g_v[]
static const unsigned char g_s_ending[]
static const symbol s_0_21[4]
static const symbol s_0[]
static const symbol s_0_4[5]
Definition: api.h:15
int lb
Definition: api.h:17
symbol * p
Definition: api.h:16
int ket
Definition: api.h:17
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
int eq_v_b(struct SN_env *z, const symbol *p)
Definition: utilities.c:245
SNOWBALL_ERR slice_from_s(struct SN_env *z, int s_size, const symbol *s)
Definition: utilities.c:432
SNOWBALL_ERR slice_to(struct SN_env *z, symbol **p)
Definition: utilities.c:478
void lose_s(symbol *p)
Definition: utilities.c:31
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
symbol * create_s(void)
Definition: utilities.c:20
int skip_utf8(const symbol *p, int c, int limit, int n)
Definition: utilities.c:43