PostgreSQL Source Code git master
stem_UTF_8_norwegian.c
Go to the documentation of this file.
1/* Generated from norwegian.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 norwegian_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);
28
29static const symbol s_0[] = { 'e', 'r' };
30
31static const symbol s_0_1[3] = { 'i', 'n', 'd' };
32static const symbol s_0_2[2] = { 'k', 'k' };
33static const symbol s_0_3[2] = { 'n', 'k' };
34static const symbol s_0_4[3] = { 'a', 'm', 'm' };
35static const symbol s_0_5[3] = { 'o', 'm', 'm' };
36static const symbol s_0_6[3] = { 'k', 'a', 'p' };
37static const symbol s_0_7[4] = { 's', 'k', 'a', 'p' };
38static const symbol s_0_8[2] = { 'p', 'p' };
39static const symbol s_0_9[2] = { 'l', 't' };
40static const symbol s_0_10[3] = { 'a', 's', 't' };
41static const symbol s_0_11[4] = { 0xC3, 0xB8, 's', 't' };
42static const symbol s_0_12[1] = { 'v' };
43static const symbol s_0_13[3] = { 'h', 'a', 'v' };
44static const symbol s_0_14[3] = { 'g', 'i', 'v' };
45static const struct among a_0[15] = {
46{ 0, 0, 0, 1, 0},
47{ 3, s_0_1, -1, -1, 0},
48{ 2, s_0_2, -2, -1, 0},
49{ 2, s_0_3, -3, -1, 0},
50{ 3, s_0_4, -4, -1, 0},
51{ 3, s_0_5, -5, -1, 0},
52{ 3, s_0_6, -6, -1, 0},
53{ 4, s_0_7, -1, 1, 0},
54{ 2, s_0_8, -8, -1, 0},
55{ 2, s_0_9, -9, -1, 0},
56{ 3, s_0_10, -10, -1, 0},
57{ 4, s_0_11, -11, -1, 0},
58{ 1, s_0_12, -12, -1, 0},
59{ 3, s_0_13, -1, 1, 0},
60{ 3, s_0_14, -2, 1, 0}
61};
62
63static const symbol s_1_0[1] = { 'a' };
64static const symbol s_1_1[1] = { 'e' };
65static const symbol s_1_2[3] = { 'e', 'd', 'e' };
66static const symbol s_1_3[4] = { 'a', 'n', 'd', 'e' };
67static const symbol s_1_4[4] = { 'e', 'n', 'd', 'e' };
68static const symbol s_1_5[3] = { 'a', 'n', 'e' };
69static const symbol s_1_6[3] = { 'e', 'n', 'e' };
70static const symbol s_1_7[6] = { 'h', 'e', 't', 'e', 'n', 'e' };
71static const symbol s_1_8[4] = { 'e', 'r', 't', 'e' };
72static const symbol s_1_9[2] = { 'e', 'n' };
73static const symbol s_1_10[5] = { 'h', 'e', 't', 'e', 'n' };
74static const symbol s_1_11[2] = { 'a', 'r' };
75static const symbol s_1_12[2] = { 'e', 'r' };
76static const symbol s_1_13[5] = { 'h', 'e', 't', 'e', 'r' };
77static const symbol s_1_14[1] = { 's' };
78static const symbol s_1_15[2] = { 'a', 's' };
79static const symbol s_1_16[2] = { 'e', 's' };
80static const symbol s_1_17[4] = { 'e', 'd', 'e', 's' };
81static const symbol s_1_18[5] = { 'e', 'n', 'd', 'e', 's' };
82static const symbol s_1_19[4] = { 'e', 'n', 'e', 's' };
83static const symbol s_1_20[7] = { 'h', 'e', 't', 'e', 'n', 'e', 's' };
84static const symbol s_1_21[3] = { 'e', 'n', 's' };
85static const symbol s_1_22[6] = { 'h', 'e', 't', 'e', 'n', 's' };
86static const symbol s_1_23[3] = { 'e', 'r', 's' };
87static const symbol s_1_24[3] = { 'e', 't', 's' };
88static const symbol s_1_25[2] = { 'e', 't' };
89static const symbol s_1_26[3] = { 'h', 'e', 't' };
90static const symbol s_1_27[3] = { 'e', 'r', 't' };
91static const symbol s_1_28[3] = { 'a', 's', 't' };
92static const struct among a_1[29] = {
93{ 1, s_1_0, 0, 1, 0},
94{ 1, s_1_1, 0, 1, 0},
95{ 3, s_1_2, -1, 1, 0},
96{ 4, s_1_3, -2, 1, 0},
97{ 4, s_1_4, -3, 1, 0},
98{ 3, s_1_5, -4, 1, 0},
99{ 3, s_1_6, -5, 1, 0},
100{ 6, s_1_7, -1, 1, 0},
101{ 4, s_1_8, -7, 4, 0},
102{ 2, s_1_9, 0, 1, 0},
103{ 5, s_1_10, -1, 1, 0},
104{ 2, s_1_11, 0, 1, 0},
105{ 2, s_1_12, 0, 1, 0},
106{ 5, s_1_13, -1, 1, 0},
107{ 1, s_1_14, 0, 3, 0},
108{ 2, s_1_15, -1, 1, 0},
109{ 2, s_1_16, -2, 1, 0},
110{ 4, s_1_17, -1, 1, 0},
111{ 5, s_1_18, -2, 1, 0},
112{ 4, s_1_19, -3, 1, 0},
113{ 7, s_1_20, -1, 1, 0},
114{ 3, s_1_21, -7, 1, 0},
115{ 6, s_1_22, -1, 1, 0},
116{ 3, s_1_23, -9, 2, 0},
117{ 3, s_1_24, -10, 1, 0},
118{ 2, s_1_25, 0, 1, 0},
119{ 3, s_1_26, -1, 1, 0},
120{ 3, s_1_27, 0, 4, 0},
121{ 3, s_1_28, 0, 1, 0}
122};
123
124static const symbol s_2_0[2] = { 'd', 't' };
125static const symbol s_2_1[2] = { 'v', 't' };
126static const struct among a_2[2] = {
127{ 2, s_2_0, 0, -1, 0},
128{ 2, s_2_1, 0, -1, 0}
129};
130
131static const symbol s_3_0[3] = { 'l', 'e', 'g' };
132static const symbol s_3_1[4] = { 'e', 'l', 'e', 'g' };
133static const symbol s_3_2[2] = { 'i', 'g' };
134static const symbol s_3_3[3] = { 'e', 'i', 'g' };
135static const symbol s_3_4[3] = { 'l', 'i', 'g' };
136static const symbol s_3_5[4] = { 'e', 'l', 'i', 'g' };
137static const symbol s_3_6[3] = { 'e', 'l', 's' };
138static const symbol s_3_7[3] = { 'l', 'o', 'v' };
139static const symbol s_3_8[4] = { 'e', 'l', 'o', 'v' };
140static const symbol s_3_9[4] = { 's', 'l', 'o', 'v' };
141static const symbol s_3_10[7] = { 'h', 'e', 't', 's', 'l', 'o', 'v' };
142static const struct among a_3[11] = {
143{ 3, s_3_0, 0, 1, 0},
144{ 4, s_3_1, -1, 1, 0},
145{ 2, s_3_2, 0, 1, 0},
146{ 3, s_3_3, -1, 1, 0},
147{ 3, s_3_4, -2, 1, 0},
148{ 4, s_3_5, -1, 1, 0},
149{ 3, s_3_6, 0, 1, 0},
150{ 3, s_3_7, 0, 1, 0},
151{ 4, s_3_8, -1, 1, 0},
152{ 4, s_3_9, -2, 1, 0},
153{ 7, s_3_10, -1, 1, 0}
154};
155
156static const unsigned char g_v[] = { 17, 65, 16, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 48, 2, 142 };
157
158static const unsigned char g_s_ending[] = { 119, 125, 148, 1 };
159
160static int r_mark_regions(struct SN_env * z) {
161 int i_x;
162 ((SN_local *)z)->i_p1 = z->l;
163 {
164 int v_1 = z->c;
165 {
166 int ret = skip_utf8(z->p, z->c, z->l, 3);
167 if (ret < 0) return 0;
168 z->c = ret;
169 }
170 i_x = z->c;
171 z->c = v_1;
172 }
173 {
174 int ret = out_grouping_U(z, g_v, 97, 248, 1);
175 if (ret < 0) return 0;
176 z->c += ret;
177 }
178 {
179 int ret = in_grouping_U(z, g_v, 97, 248, 1);
180 if (ret < 0) return 0;
181 z->c += ret;
182 }
183 ((SN_local *)z)->i_p1 = z->c;
184 if (((SN_local *)z)->i_p1 >= i_x) goto lab0;
185 ((SN_local *)z)->i_p1 = i_x;
186lab0:
187 return 1;
188}
189
190static int r_main_suffix(struct SN_env * z) {
191 int among_var;
192 {
193 int v_1;
194 if (z->c < ((SN_local *)z)->i_p1) return 0;
195 v_1 = z->lb; z->lb = ((SN_local *)z)->i_p1;
196 z->ket = z->c;
197 if (z->c <= z->lb || z->p[z->c - 1] >> 5 != 3 || !((1851426 >> (z->p[z->c - 1] & 0x1f)) & 1)) { z->lb = v_1; return 0; }
198 among_var = find_among_b(z, a_1, 29, 0);
199 if (!among_var) { z->lb = v_1; return 0; }
200 z->bra = z->c;
201 z->lb = v_1;
202 }
203 switch (among_var) {
204 case 1:
205 {
206 int ret = slice_del(z);
207 if (ret < 0) return ret;
208 }
209 break;
210 case 2:
211 if (z->c <= z->lb || z->p[z->c - 1] >> 5 != 3 || !((5318672 >> (z->p[z->c - 1] & 0x1f)) & 1)) among_var = 1; else
212 among_var = find_among_b(z, a_0, 15, 0);
213 switch (among_var) {
214 case 1:
215 {
216 int ret = slice_del(z);
217 if (ret < 0) return ret;
218 }
219 break;
220 }
221 break;
222 case 3:
223 do {
224 int v_2 = z->l - z->c;
225 if (in_grouping_b_U(z, g_s_ending, 98, 122, 0)) goto lab0;
226 break;
227 lab0:
228 z->c = z->l - v_2;
229 if (z->c <= z->lb || z->p[z->c - 1] != 'r') goto lab1;
230 z->c--;
231 {
232 int v_3 = z->l - z->c;
233 if (z->c <= z->lb || z->p[z->c - 1] != 'e') goto lab2;
234 z->c--;
235 goto lab1;
236 lab2:
237 z->c = z->l - v_3;
238 }
239 break;
240 lab1:
241 z->c = z->l - v_2;
242 if (z->c <= z->lb || z->p[z->c - 1] != 'k') return 0;
243 z->c--;
244 if (out_grouping_b_U(z, g_v, 97, 248, 0)) return 0;
245 } while (0);
246 {
247 int ret = slice_del(z);
248 if (ret < 0) return ret;
249 }
250 break;
251 case 4:
252 {
253 int ret = slice_from_s(z, 2, s_0);
254 if (ret < 0) return ret;
255 }
256 break;
257 }
258 return 1;
259}
260
261static int r_consonant_pair(struct SN_env * z) {
262 {
263 int v_1 = z->l - z->c;
264 {
265 int v_2;
266 if (z->c < ((SN_local *)z)->i_p1) return 0;
267 v_2 = z->lb; z->lb = ((SN_local *)z)->i_p1;
268 z->ket = z->c;
269 if (z->c - 1 <= z->lb || z->p[z->c - 1] != 116) { z->lb = v_2; return 0; }
270 if (!find_among_b(z, a_2, 2, 0)) { z->lb = v_2; return 0; }
271 z->bra = z->c;
272 z->lb = v_2;
273 }
274 z->c = z->l - v_1;
275 }
276 {
277 int ret = skip_b_utf8(z->p, z->c, z->lb, 1);
278 if (ret < 0) return 0;
279 z->c = ret;
280 }
281 z->bra = z->c;
282 {
283 int ret = slice_del(z);
284 if (ret < 0) return ret;
285 }
286 return 1;
287}
288
289static int r_other_suffix(struct SN_env * z) {
290 {
291 int v_1;
292 if (z->c < ((SN_local *)z)->i_p1) return 0;
293 v_1 = z->lb; z->lb = ((SN_local *)z)->i_p1;
294 z->ket = z->c;
295 if (z->c - 1 <= z->lb || z->p[z->c - 1] >> 5 != 3 || !((4718720 >> (z->p[z->c - 1] & 0x1f)) & 1)) { z->lb = v_1; return 0; }
296 if (!find_among_b(z, a_3, 11, 0)) { z->lb = v_1; return 0; }
297 z->bra = z->c;
298 z->lb = v_1;
299 }
300 {
301 int ret = slice_del(z);
302 if (ret < 0) return ret;
303 }
304 return 1;
305}
306
307extern int norwegian_UTF_8_stem(struct SN_env * z) {
308 {
309 int v_1 = z->c;
310 {
311 int ret = r_mark_regions(z);
312 if (ret < 0) return ret;
313 }
314 z->c = v_1;
315 }
316 z->lb = z->c; z->c = z->l;
317 {
318 int v_2 = z->l - z->c;
319 {
320 int ret = r_main_suffix(z);
321 if (ret < 0) return ret;
322 }
323 z->c = z->l - v_2;
324 }
325 {
326 int v_3 = z->l - z->c;
327 {
328 int ret = r_consonant_pair(z);
329 if (ret < 0) return ret;
330 }
331 z->c = z->l - v_3;
332 }
333 {
334 int v_4 = z->l - z->c;
335 {
336 int ret = r_other_suffix(z);
337 if (ret < 0) return ret;
338 }
339 z->c = z->l - v_4;
340 }
341 z->c = z->lb;
342 return 1;
343}
344
345extern struct SN_env * norwegian_UTF_8_create_env(void) {
346 struct SN_env * z = SN_new_env(sizeof(SN_local));
347 if (z) {
348 ((SN_local *)z)->i_p1 = 0;
349 }
350 return z;
351}
352
353extern void norwegian_UTF_8_close_env(struct SN_env * z) {
354 SN_delete_env(z);
355}
356
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 struct among a_2[2]
static const symbol s_3_5[4]
int norwegian_UTF_8_stem(struct SN_env *z)
static const symbol s_1_24[3]
static const symbol s_1_9[2]
static const symbol s_1_14[1]
static const symbol s_3_7[3]
static const symbol s_1_6[3]
static const symbol s_1_5[3]
static const symbol s_0_5[3]
static const symbol s_0_8[2]
static const symbol s_0_10[3]
static int r_other_suffix(struct SN_env *z)
static int r_consonant_pair(struct SN_env *z)
static const struct among a_0[15]
static const symbol s_2_0[2]
static int r_main_suffix(struct SN_env *z)
static const symbol s_1_3[4]
static const symbol s_1_27[3]
static const symbol s_1_25[2]
static const symbol s_1_4[4]
static const symbol s_0_12[1]
struct SN_env * norwegian_UTF_8_create_env(void)
static const symbol s_3_0[3]
static const symbol s_1_15[2]
static const symbol s_0_13[3]
static const symbol s_1_17[4]
static const symbol s_3_9[4]
static const symbol s_1_20[7]
static const symbol s_1_28[3]
static const symbol s_1_21[3]
static const symbol s_0_1[3]
static const symbol s_3_6[3]
static const symbol s_1_23[3]
static const symbol s_3_10[7]
static const symbol s_1_11[2]
static const symbol s_0_11[4]
static const symbol s_1_13[5]
static const symbol s_1_18[5]
static const symbol s_0_7[4]
static const symbol s_1_1[1]
static const symbol s_0_14[3]
static const symbol s_3_4[3]
static const symbol s_1_2[3]
static const symbol s_3_1[4]
static const symbol s_3_3[3]
static const symbol s_1_0[1]
static const symbol s_1_26[3]
static int r_mark_regions(struct SN_env *z)
static const symbol s_1_22[6]
static const symbol s_3_8[4]
static const symbol s_0_6[3]
static const symbol s_0_2[2]
static const symbol s_1_10[5]
static const symbol s_1_16[2]
static const struct among a_1[29]
static const struct among a_3[11]
static const symbol s_1_7[6]
static const symbol s_0_3[2]
static const symbol s_2_1[2]
static const unsigned char g_v[]
static const unsigned char g_s_ending[]
static const symbol s_1_8[4]
static const symbol s_1_19[4]
static const symbol s_0_9[2]
static const symbol s_3_2[2]
static const symbol s_1_12[2]
static const symbol s_0[]
static const symbol s_0_4[3]
void norwegian_UTF_8_close_env(struct SN_env *z)
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
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