PostgreSQL Source Code git master
stem_ISO_8859_1_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_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);
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[3] = { 0xF8, '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{ 3, 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 if (z->c + 3 > z->l) return 0;
166 z->c += 3;
167 i_x = z->c;
168 z->c = v_1;
169 }
170 {
171 int ret = out_grouping(z, g_v, 97, 248, 1);
172 if (ret < 0) return 0;
173 z->c += ret;
174 }
175 {
176 int ret = in_grouping(z, g_v, 97, 248, 1);
177 if (ret < 0) return 0;
178 z->c += ret;
179 }
180 ((SN_local *)z)->i_p1 = z->c;
181 if (((SN_local *)z)->i_p1 >= i_x) goto lab0;
182 ((SN_local *)z)->i_p1 = i_x;
183lab0:
184 return 1;
185}
186
187static int r_main_suffix(struct SN_env * z) {
188 int among_var;
189 {
190 int v_1;
191 if (z->c < ((SN_local *)z)->i_p1) return 0;
192 v_1 = z->lb; z->lb = ((SN_local *)z)->i_p1;
193 z->ket = z->c;
194 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; }
195 among_var = find_among_b(z, a_1, 29, 0);
196 if (!among_var) { z->lb = v_1; return 0; }
197 z->bra = z->c;
198 z->lb = v_1;
199 }
200 switch (among_var) {
201 case 1:
202 {
203 int ret = slice_del(z);
204 if (ret < 0) return ret;
205 }
206 break;
207 case 2:
208 if (z->c <= z->lb || z->p[z->c - 1] >> 5 != 3 || !((5318672 >> (z->p[z->c - 1] & 0x1f)) & 1)) among_var = 1; else
209 among_var = find_among_b(z, a_0, 15, 0);
210 switch (among_var) {
211 case 1:
212 {
213 int ret = slice_del(z);
214 if (ret < 0) return ret;
215 }
216 break;
217 }
218 break;
219 case 3:
220 do {
221 int v_2 = z->l - z->c;
222 if (in_grouping_b(z, g_s_ending, 98, 122, 0)) goto lab0;
223 break;
224 lab0:
225 z->c = z->l - v_2;
226 if (z->c <= z->lb || z->p[z->c - 1] != 'r') goto lab1;
227 z->c--;
228 {
229 int v_3 = z->l - z->c;
230 if (z->c <= z->lb || z->p[z->c - 1] != 'e') goto lab2;
231 z->c--;
232 goto lab1;
233 lab2:
234 z->c = z->l - v_3;
235 }
236 break;
237 lab1:
238 z->c = z->l - v_2;
239 if (z->c <= z->lb || z->p[z->c - 1] != 'k') return 0;
240 z->c--;
241 if (out_grouping_b(z, g_v, 97, 248, 0)) return 0;
242 } while (0);
243 {
244 int ret = slice_del(z);
245 if (ret < 0) return ret;
246 }
247 break;
248 case 4:
249 {
250 int ret = slice_from_s(z, 2, s_0);
251 if (ret < 0) return ret;
252 }
253 break;
254 }
255 return 1;
256}
257
258static int r_consonant_pair(struct SN_env * z) {
259 {
260 int v_1 = z->l - z->c;
261 {
262 int v_2;
263 if (z->c < ((SN_local *)z)->i_p1) return 0;
264 v_2 = z->lb; z->lb = ((SN_local *)z)->i_p1;
265 z->ket = z->c;
266 if (z->c - 1 <= z->lb || z->p[z->c - 1] != 116) { z->lb = v_2; return 0; }
267 if (!find_among_b(z, a_2, 2, 0)) { z->lb = v_2; return 0; }
268 z->bra = z->c;
269 z->lb = v_2;
270 }
271 z->c = z->l - v_1;
272 }
273 if (z->c <= z->lb) return 0;
274 z->c--;
275 z->bra = z->c;
276 {
277 int ret = slice_del(z);
278 if (ret < 0) return ret;
279 }
280 return 1;
281}
282
283static int r_other_suffix(struct SN_env * z) {
284 {
285 int v_1;
286 if (z->c < ((SN_local *)z)->i_p1) return 0;
287 v_1 = z->lb; z->lb = ((SN_local *)z)->i_p1;
288 z->ket = z->c;
289 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; }
290 if (!find_among_b(z, a_3, 11, 0)) { z->lb = v_1; return 0; }
291 z->bra = z->c;
292 z->lb = v_1;
293 }
294 {
295 int ret = slice_del(z);
296 if (ret < 0) return ret;
297 }
298 return 1;
299}
300
301extern int norwegian_ISO_8859_1_stem(struct SN_env * z) {
302 {
303 int v_1 = z->c;
304 {
305 int ret = r_mark_regions(z);
306 if (ret < 0) return ret;
307 }
308 z->c = v_1;
309 }
310 z->lb = z->c; z->c = z->l;
311 {
312 int v_2 = z->l - z->c;
313 {
314 int ret = r_main_suffix(z);
315 if (ret < 0) return ret;
316 }
317 z->c = z->l - v_2;
318 }
319 {
320 int v_3 = z->l - z->c;
321 {
322 int ret = r_consonant_pair(z);
323 if (ret < 0) return ret;
324 }
325 z->c = z->l - v_3;
326 }
327 {
328 int v_4 = z->l - z->c;
329 {
330 int ret = r_other_suffix(z);
331 if (ret < 0) return ret;
332 }
333 z->c = z->l - v_4;
334 }
335 z->c = z->lb;
336 return 1;
337}
338
340 struct SN_env * z = SN_new_env(sizeof(SN_local));
341 if (z) {
342 ((SN_local *)z)->i_p1 = 0;
343 }
344 return z;
345}
346
347extern void norwegian_ISO_8859_1_close_env(struct SN_env * z) {
348 SN_delete_env(z);
349}
350
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
int norwegian_ISO_8859_1_stem(struct SN_env *z)
static const struct among a_2[2]
static const symbol s_3_5[4]
static const symbol s_0_11[3]
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)
void norwegian_ISO_8859_1_close_env(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]
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_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]
struct SN_env * norwegian_ISO_8859_1_create_env(void)
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]
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 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