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