Line data Source code
1 : /* Generated from norwegian.sbl by Snowball 3.0.0 - https://snowballstem.org/ */
2 :
3 : #include "stem_ISO_8859_1_norwegian.h"
4 :
5 : #include <stddef.h>
6 :
7 : #include "snowball_runtime.h"
8 :
9 : struct SN_local {
10 : struct SN_env z;
11 : int i_p1;
12 : };
13 :
14 : typedef struct SN_local SN_local;
15 :
16 : #ifdef __cplusplus
17 : extern "C" {
18 : #endif
19 : extern int norwegian_ISO_8859_1_stem(struct SN_env * z);
20 : #ifdef __cplusplus
21 : }
22 : #endif
23 :
24 : static int r_other_suffix(struct SN_env * z);
25 : static int r_consonant_pair(struct SN_env * z);
26 : static int r_main_suffix(struct SN_env * z);
27 : static int r_mark_regions(struct SN_env * z);
28 :
29 : static const symbol s_0[] = { 'e', 'r' };
30 :
31 : static const symbol s_0_1[3] = { 'i', 'n', 'd' };
32 : static const symbol s_0_2[2] = { 'k', 'k' };
33 : static const symbol s_0_3[2] = { 'n', 'k' };
34 : static const symbol s_0_4[3] = { 'a', 'm', 'm' };
35 : static const symbol s_0_5[3] = { 'o', 'm', 'm' };
36 : static const symbol s_0_6[3] = { 'k', 'a', 'p' };
37 : static const symbol s_0_7[4] = { 's', 'k', 'a', 'p' };
38 : static const symbol s_0_8[2] = { 'p', 'p' };
39 : static const symbol s_0_9[2] = { 'l', 't' };
40 : static const symbol s_0_10[3] = { 'a', 's', 't' };
41 : static const symbol s_0_11[3] = { 0xF8, 's', 't' };
42 : static const symbol s_0_12[1] = { 'v' };
43 : static const symbol s_0_13[3] = { 'h', 'a', 'v' };
44 : static const symbol s_0_14[3] = { 'g', 'i', 'v' };
45 : static 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 :
63 : static const symbol s_1_0[1] = { 'a' };
64 : static const symbol s_1_1[1] = { 'e' };
65 : static const symbol s_1_2[3] = { 'e', 'd', 'e' };
66 : static const symbol s_1_3[4] = { 'a', 'n', 'd', 'e' };
67 : static const symbol s_1_4[4] = { 'e', 'n', 'd', 'e' };
68 : static const symbol s_1_5[3] = { 'a', 'n', 'e' };
69 : static const symbol s_1_6[3] = { 'e', 'n', 'e' };
70 : static const symbol s_1_7[6] = { 'h', 'e', 't', 'e', 'n', 'e' };
71 : static const symbol s_1_8[4] = { 'e', 'r', 't', 'e' };
72 : static const symbol s_1_9[2] = { 'e', 'n' };
73 : static const symbol s_1_10[5] = { 'h', 'e', 't', 'e', 'n' };
74 : static const symbol s_1_11[2] = { 'a', 'r' };
75 : static const symbol s_1_12[2] = { 'e', 'r' };
76 : static const symbol s_1_13[5] = { 'h', 'e', 't', 'e', 'r' };
77 : static const symbol s_1_14[1] = { 's' };
78 : static const symbol s_1_15[2] = { 'a', 's' };
79 : static const symbol s_1_16[2] = { 'e', 's' };
80 : static const symbol s_1_17[4] = { 'e', 'd', 'e', 's' };
81 : static const symbol s_1_18[5] = { 'e', 'n', 'd', 'e', 's' };
82 : static const symbol s_1_19[4] = { 'e', 'n', 'e', 's' };
83 : static const symbol s_1_20[7] = { 'h', 'e', 't', 'e', 'n', 'e', 's' };
84 : static const symbol s_1_21[3] = { 'e', 'n', 's' };
85 : static const symbol s_1_22[6] = { 'h', 'e', 't', 'e', 'n', 's' };
86 : static const symbol s_1_23[3] = { 'e', 'r', 's' };
87 : static const symbol s_1_24[3] = { 'e', 't', 's' };
88 : static const symbol s_1_25[2] = { 'e', 't' };
89 : static const symbol s_1_26[3] = { 'h', 'e', 't' };
90 : static const symbol s_1_27[3] = { 'e', 'r', 't' };
91 : static const symbol s_1_28[3] = { 'a', 's', 't' };
92 : static 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 :
124 : static const symbol s_2_0[2] = { 'd', 't' };
125 : static const symbol s_2_1[2] = { 'v', 't' };
126 : static const struct among a_2[2] = {
127 : { 2, s_2_0, 0, -1, 0},
128 : { 2, s_2_1, 0, -1, 0}
129 : };
130 :
131 : static const symbol s_3_0[3] = { 'l', 'e', 'g' };
132 : static const symbol s_3_1[4] = { 'e', 'l', 'e', 'g' };
133 : static const symbol s_3_2[2] = { 'i', 'g' };
134 : static const symbol s_3_3[3] = { 'e', 'i', 'g' };
135 : static const symbol s_3_4[3] = { 'l', 'i', 'g' };
136 : static const symbol s_3_5[4] = { 'e', 'l', 'i', 'g' };
137 : static const symbol s_3_6[3] = { 'e', 'l', 's' };
138 : static const symbol s_3_7[3] = { 'l', 'o', 'v' };
139 : static const symbol s_3_8[4] = { 'e', 'l', 'o', 'v' };
140 : static const symbol s_3_9[4] = { 's', 'l', 'o', 'v' };
141 : static const symbol s_3_10[7] = { 'h', 'e', 't', 's', 'l', 'o', 'v' };
142 : static 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 :
156 : static 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 :
158 : static const unsigned char g_s_ending[] = { 119, 125, 148, 1 };
159 :
160 0 : static int r_mark_regions(struct SN_env * z) {
161 : int i_x;
162 0 : ((SN_local *)z)->i_p1 = z->l;
163 : {
164 0 : int v_1 = z->c;
165 0 : if (z->c + 3 > z->l) return 0;
166 0 : z->c += 3;
167 0 : i_x = z->c;
168 0 : z->c = v_1;
169 : }
170 : {
171 0 : int ret = out_grouping(z, g_v, 97, 248, 1);
172 0 : if (ret < 0) return 0;
173 0 : z->c += ret;
174 : }
175 : {
176 0 : int ret = in_grouping(z, g_v, 97, 248, 1);
177 0 : if (ret < 0) return 0;
178 0 : z->c += ret;
179 : }
180 0 : ((SN_local *)z)->i_p1 = z->c;
181 0 : if (((SN_local *)z)->i_p1 >= i_x) goto lab0;
182 0 : ((SN_local *)z)->i_p1 = i_x;
183 0 : lab0:
184 0 : return 1;
185 : }
186 :
187 0 : static int r_main_suffix(struct SN_env * z) {
188 : int among_var;
189 : {
190 : int v_1;
191 0 : if (z->c < ((SN_local *)z)->i_p1) return 0;
192 0 : v_1 = z->lb; z->lb = ((SN_local *)z)->i_p1;
193 0 : z->ket = z->c;
194 0 : 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 0 : among_var = find_among_b(z, a_1, 29, 0);
196 0 : if (!among_var) { z->lb = v_1; return 0; }
197 0 : z->bra = z->c;
198 0 : z->lb = v_1;
199 : }
200 0 : switch (among_var) {
201 0 : case 1:
202 : {
203 0 : int ret = slice_del(z);
204 0 : if (ret < 0) return ret;
205 : }
206 0 : break;
207 0 : case 2:
208 0 : 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 0 : among_var = find_among_b(z, a_0, 15, 0);
210 : switch (among_var) {
211 0 : case 1:
212 : {
213 0 : int ret = slice_del(z);
214 0 : if (ret < 0) return ret;
215 : }
216 0 : break;
217 : }
218 0 : break;
219 0 : case 3:
220 : do {
221 0 : int v_2 = z->l - z->c;
222 0 : if (in_grouping_b(z, g_s_ending, 98, 122, 0)) goto lab0;
223 0 : break;
224 0 : lab0:
225 0 : z->c = z->l - v_2;
226 0 : if (z->c <= z->lb || z->p[z->c - 1] != 'r') goto lab1;
227 0 : z->c--;
228 : {
229 0 : int v_3 = z->l - z->c;
230 0 : if (z->c <= z->lb || z->p[z->c - 1] != 'e') goto lab2;
231 0 : z->c--;
232 0 : goto lab1;
233 0 : lab2:
234 0 : z->c = z->l - v_3;
235 : }
236 0 : break;
237 0 : lab1:
238 0 : z->c = z->l - v_2;
239 0 : if (z->c <= z->lb || z->p[z->c - 1] != 'k') return 0;
240 0 : z->c--;
241 0 : if (out_grouping_b(z, g_v, 97, 248, 0)) return 0;
242 : } while (0);
243 : {
244 0 : int ret = slice_del(z);
245 0 : if (ret < 0) return ret;
246 : }
247 0 : break;
248 0 : case 4:
249 : {
250 0 : int ret = slice_from_s(z, 2, s_0);
251 0 : if (ret < 0) return ret;
252 : }
253 0 : break;
254 : }
255 0 : return 1;
256 : }
257 :
258 0 : static int r_consonant_pair(struct SN_env * z) {
259 : {
260 0 : int v_1 = z->l - z->c;
261 : {
262 : int v_2;
263 0 : if (z->c < ((SN_local *)z)->i_p1) return 0;
264 0 : v_2 = z->lb; z->lb = ((SN_local *)z)->i_p1;
265 0 : z->ket = z->c;
266 0 : if (z->c - 1 <= z->lb || z->p[z->c - 1] != 116) { z->lb = v_2; return 0; }
267 0 : if (!find_among_b(z, a_2, 2, 0)) { z->lb = v_2; return 0; }
268 0 : z->bra = z->c;
269 0 : z->lb = v_2;
270 : }
271 0 : z->c = z->l - v_1;
272 : }
273 0 : if (z->c <= z->lb) return 0;
274 0 : z->c--;
275 0 : z->bra = z->c;
276 : {
277 0 : int ret = slice_del(z);
278 0 : if (ret < 0) return ret;
279 : }
280 0 : return 1;
281 : }
282 :
283 0 : static int r_other_suffix(struct SN_env * z) {
284 : {
285 : int v_1;
286 0 : if (z->c < ((SN_local *)z)->i_p1) return 0;
287 0 : v_1 = z->lb; z->lb = ((SN_local *)z)->i_p1;
288 0 : z->ket = z->c;
289 0 : 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 0 : if (!find_among_b(z, a_3, 11, 0)) { z->lb = v_1; return 0; }
291 0 : z->bra = z->c;
292 0 : z->lb = v_1;
293 : }
294 : {
295 0 : int ret = slice_del(z);
296 0 : if (ret < 0) return ret;
297 : }
298 0 : return 1;
299 : }
300 :
301 0 : extern int norwegian_ISO_8859_1_stem(struct SN_env * z) {
302 : {
303 0 : int v_1 = z->c;
304 : {
305 0 : int ret = r_mark_regions(z);
306 0 : if (ret < 0) return ret;
307 : }
308 0 : z->c = v_1;
309 : }
310 0 : z->lb = z->c; z->c = z->l;
311 : {
312 0 : int v_2 = z->l - z->c;
313 : {
314 0 : int ret = r_main_suffix(z);
315 0 : if (ret < 0) return ret;
316 : }
317 0 : z->c = z->l - v_2;
318 : }
319 : {
320 0 : int v_3 = z->l - z->c;
321 : {
322 0 : int ret = r_consonant_pair(z);
323 0 : if (ret < 0) return ret;
324 : }
325 0 : z->c = z->l - v_3;
326 : }
327 : {
328 0 : int v_4 = z->l - z->c;
329 : {
330 0 : int ret = r_other_suffix(z);
331 0 : if (ret < 0) return ret;
332 : }
333 0 : z->c = z->l - v_4;
334 : }
335 0 : z->c = z->lb;
336 0 : return 1;
337 : }
338 :
339 0 : extern struct SN_env * norwegian_ISO_8859_1_create_env(void) {
340 0 : struct SN_env * z = SN_new_env(sizeof(SN_local));
341 0 : if (z) {
342 0 : ((SN_local *)z)->i_p1 = 0;
343 : }
344 0 : return z;
345 : }
346 :
347 0 : extern void norwegian_ISO_8859_1_close_env(struct SN_env * z) {
348 0 : SN_delete_env(z);
349 0 : }
350 :
|