tracker-0.16.2/src/libstemmer/stem_UTF_8_danish.c

No issues found

  1 /*
  2  * Copyright (c) 2001, Dr Martin Porter
  3  * All rights reserved.
  4  *
  5  * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
  6  * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  7  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  8  * Neither the name of the <ORGANIZATION> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
  9  *
 10  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 11  */
 12 
 13 
 14 
 15 /* This file was generated automatically by the Snowball to ANSI C compiler */
 16 
 17 #include "header.h"
 18 
 19 extern int danish_UTF_8_stem(struct SN_env * z);
 20 static int r_undouble(struct SN_env * z);
 21 static int r_other_suffix(struct SN_env * z);
 22 static int r_consonant_pair(struct SN_env * z);
 23 static int r_main_suffix(struct SN_env * z);
 24 static int r_mark_regions(struct SN_env * z);
 25 
 26 extern struct SN_env * danish_UTF_8_create_env(void);
 27 extern void danish_UTF_8_close_env(struct SN_env * z);
 28 
 29 static symbol s_0_0[3] = { 'h', 'e', 'd' };
 30 static symbol s_0_1[5] = { 'e', 't', 'h', 'e', 'd' };
 31 static symbol s_0_2[4] = { 'e', 'r', 'e', 'd' };
 32 static symbol s_0_3[1] = { 'e' };
 33 static symbol s_0_4[5] = { 'e', 'r', 'e', 'd', 'e' };
 34 static symbol s_0_5[4] = { 'e', 'n', 'd', 'e' };
 35 static symbol s_0_6[6] = { 'e', 'r', 'e', 'n', 'd', 'e' };
 36 static symbol s_0_7[3] = { 'e', 'n', 'e' };
 37 static symbol s_0_8[4] = { 'e', 'r', 'n', 'e' };
 38 static symbol s_0_9[3] = { 'e', 'r', 'e' };
 39 static symbol s_0_10[2] = { 'e', 'n' };
 40 static symbol s_0_11[5] = { 'h', 'e', 'd', 'e', 'n' };
 41 static symbol s_0_12[4] = { 'e', 'r', 'e', 'n' };
 42 static symbol s_0_13[2] = { 'e', 'r' };
 43 static symbol s_0_14[5] = { 'h', 'e', 'd', 'e', 'r' };
 44 static symbol s_0_15[4] = { 'e', 'r', 'e', 'r' };
 45 static symbol s_0_16[1] = { 's' };
 46 static symbol s_0_17[4] = { 'h', 'e', 'd', 's' };
 47 static symbol s_0_18[2] = { 'e', 's' };
 48 static symbol s_0_19[5] = { 'e', 'n', 'd', 'e', 's' };
 49 static symbol s_0_20[7] = { 'e', 'r', 'e', 'n', 'd', 'e', 's' };
 50 static symbol s_0_21[4] = { 'e', 'n', 'e', 's' };
 51 static symbol s_0_22[5] = { 'e', 'r', 'n', 'e', 's' };
 52 static symbol s_0_23[4] = { 'e', 'r', 'e', 's' };
 53 static symbol s_0_24[3] = { 'e', 'n', 's' };
 54 static symbol s_0_25[6] = { 'h', 'e', 'd', 'e', 'n', 's' };
 55 static symbol s_0_26[5] = { 'e', 'r', 'e', 'n', 's' };
 56 static symbol s_0_27[3] = { 'e', 'r', 's' };
 57 static symbol s_0_28[3] = { 'e', 't', 's' };
 58 static symbol s_0_29[5] = { 'e', 'r', 'e', 't', 's' };
 59 static symbol s_0_30[2] = { 'e', 't' };
 60 static symbol s_0_31[4] = { 'e', 'r', 'e', 't' };
 61 
 62 static struct among a_0[32] =
 63 {
 64 /*  0 */ { 3, s_0_0, -1, 1, 0},
 65 /*  1 */ { 5, s_0_1, 0, 1, 0},
 66 /*  2 */ { 4, s_0_2, -1, 1, 0},
 67 /*  3 */ { 1, s_0_3, -1, 1, 0},
 68 /*  4 */ { 5, s_0_4, 3, 1, 0},
 69 /*  5 */ { 4, s_0_5, 3, 1, 0},
 70 /*  6 */ { 6, s_0_6, 5, 1, 0},
 71 /*  7 */ { 3, s_0_7, 3, 1, 0},
 72 /*  8 */ { 4, s_0_8, 3, 1, 0},
 73 /*  9 */ { 3, s_0_9, 3, 1, 0},
 74 /* 10 */ { 2, s_0_10, -1, 1, 0},
 75 /* 11 */ { 5, s_0_11, 10, 1, 0},
 76 /* 12 */ { 4, s_0_12, 10, 1, 0},
 77 /* 13 */ { 2, s_0_13, -1, 1, 0},
 78 /* 14 */ { 5, s_0_14, 13, 1, 0},
 79 /* 15 */ { 4, s_0_15, 13, 1, 0},
 80 /* 16 */ { 1, s_0_16, -1, 2, 0},
 81 /* 17 */ { 4, s_0_17, 16, 1, 0},
 82 /* 18 */ { 2, s_0_18, 16, 1, 0},
 83 /* 19 */ { 5, s_0_19, 18, 1, 0},
 84 /* 20 */ { 7, s_0_20, 19, 1, 0},
 85 /* 21 */ { 4, s_0_21, 18, 1, 0},
 86 /* 22 */ { 5, s_0_22, 18, 1, 0},
 87 /* 23 */ { 4, s_0_23, 18, 1, 0},
 88 /* 24 */ { 3, s_0_24, 16, 1, 0},
 89 /* 25 */ { 6, s_0_25, 24, 1, 0},
 90 /* 26 */ { 5, s_0_26, 24, 1, 0},
 91 /* 27 */ { 3, s_0_27, 16, 1, 0},
 92 /* 28 */ { 3, s_0_28, 16, 1, 0},
 93 /* 29 */ { 5, s_0_29, 28, 1, 0},
 94 /* 30 */ { 2, s_0_30, -1, 1, 0},
 95 /* 31 */ { 4, s_0_31, 30, 1, 0}
 96 };
 97 
 98 static symbol s_1_0[2] = { 'g', 'd' };
 99 static symbol s_1_1[2] = { 'd', 't' };
100 static symbol s_1_2[2] = { 'g', 't' };
101 static symbol s_1_3[2] = { 'k', 't' };
102 
103 static struct among a_1[4] =
104 {
105 /*  0 */ { 2, s_1_0, -1, -1, 0},
106 /*  1 */ { 2, s_1_1, -1, -1, 0},
107 /*  2 */ { 2, s_1_2, -1, -1, 0},
108 /*  3 */ { 2, s_1_3, -1, -1, 0}
109 };
110 
111 static symbol s_2_0[2] = { 'i', 'g' };
112 static symbol s_2_1[3] = { 'l', 'i', 'g' };
113 static symbol s_2_2[4] = { 'e', 'l', 'i', 'g' };
114 static symbol s_2_3[3] = { 'e', 'l', 's' };
115 static symbol s_2_4[5] = { 'l', 0xC3, 0xB8, 's', 't' };
116 
117 static struct among a_2[5] =
118 {
119 /*  0 */ { 2, s_2_0, -1, 1, 0},
120 /*  1 */ { 3, s_2_1, 0, 1, 0},
121 /*  2 */ { 4, s_2_2, 1, 1, 0},
122 /*  3 */ { 3, s_2_3, -1, 1, 0},
123 /*  4 */ { 5, s_2_4, -1, 2, 0}
124 };
125 
126 static unsigned char g_v[] = { 17, 65, 16, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 48, 0, 128 };
127 
128 static unsigned char g_s_ending[] = { 239, 254, 42, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16 };
129 
130 static symbol s_0[] = { 's', 't' };
131 static symbol s_1[] = { 'i', 'g' };
132 static symbol s_2[] = { 'l', 0xC3, 0xB8, 's' };
133 
134 static int r_mark_regions(struct SN_env * z) {
135     z->I[0] = z->l;
136     {	int c_test = z->c; /* test, line 33 */
137 	{   int c = skip_utf8(z->p, z->c, 0, z->l, + 3);
138 	    if (c < 0) return 0;
139 	    z->c = c; /* hop, line 33 */
140 	}
141 	z->I[1] = z->c; /* setmark x, line 33 */
142 	z->c = c_test;
143     }
144     while(1) { /* goto, line 34 */
145 	int c = z->c;
146 	if (!(in_grouping_U(z, g_v, 97, 248))) goto lab0;
147 	z->c = c;
148 	break;
149     lab0:
150 	z->c = c;
151 	{   int c = skip_utf8(z->p, z->c, 0, z->l, 1);
152 	    if (c < 0) return 0;
153 	    z->c = c; /* goto, line 34 */
154 	}
155     }
156     while(1) { /* gopast, line 34 */
157 	if (!(out_grouping_U(z, g_v, 97, 248))) goto lab1;
158 	break;
159     lab1:
160 	{   int c = skip_utf8(z->p, z->c, 0, z->l, 1);
161 	    if (c < 0) return 0;
162 	    z->c = c; /* gopast, line 34 */
163 	}
164     }
165     z->I[0] = z->c; /* setmark p1, line 34 */
166      /* try, line 35 */
167     if (!(z->I[0] < z->I[1])) goto lab2;
168     z->I[0] = z->I[1];
169 lab2:
170     return 1;
171 }
172 
173 static int r_main_suffix(struct SN_env * z) {
174     int among_var;
175     {	int m3; /* setlimit, line 41 */
176 	int m = z->l - z->c; (void) m;
177 	if (z->c < z->I[0]) return 0;
178 	z->c = z->I[0]; /* tomark, line 41 */
179 	m3 = z->lb; z->lb = z->c;
180 	z->c = z->l - m;
181 	z->ket = z->c; /* [, line 41 */
182 	among_var = find_among_b(z, a_0, 32); /* substring, line 41 */
183 	if (!(among_var)) { z->lb = m3; return 0; }
184 	z->bra = z->c; /* ], line 41 */
185 	z->lb = m3;
186     }
187     switch(among_var) {
188 	case 0: return 0;
189 	case 1:
190 	    {	int ret;
191 		ret = slice_del(z); /* delete, line 48 */
192 		if (ret < 0) return ret;
193 	    }
194 	    break;
195 	case 2:
196 	    if (!(in_grouping_b_U(z, g_s_ending, 97, 229))) return 0;
197 	    {	int ret;
198 		ret = slice_del(z); /* delete, line 50 */
199 		if (ret < 0) return ret;
200 	    }
201 	    break;
202     }
203     return 1;
204 }
205 
206 static int r_consonant_pair(struct SN_env * z) {
207     {	int m_test = z->l - z->c; /* test, line 55 */
208 	{   int m3; /* setlimit, line 56 */
209 	    int m = z->l - z->c; (void) m;
210 	    if (z->c < z->I[0]) return 0;
211 	    z->c = z->I[0]; /* tomark, line 56 */
212 	    m3 = z->lb; z->lb = z->c;
213 	    z->c = z->l - m;
214 	    z->ket = z->c; /* [, line 56 */
215 	    if (!(find_among_b(z, a_1, 4))) { z->lb = m3; return 0; } /* substring, line 56 */
216 	    z->bra = z->c; /* ], line 56 */
217 	    z->lb = m3;
218 	}
219 	z->c = z->l - m_test;
220     }
221     {	int c = skip_utf8(z->p, z->c, z->lb, 0, -1);
222 	if (c < 0) return 0;
223 	z->c = c; /* next, line 62 */
224     }
225     z->bra = z->c; /* ], line 62 */
226     {	int ret;
227 	ret = slice_del(z); /* delete, line 62 */
228 	if (ret < 0) return ret;
229     }
230     return 1;
231 }
232 
233 static int r_other_suffix(struct SN_env * z) {
234     int among_var;
235     {	int m = z->l - z->c; (void) m; /* do, line 66 */
236 	z->ket = z->c; /* [, line 66 */
237 	if (!(eq_s_b(z, 2, s_0))) goto lab0;
238 	z->bra = z->c; /* ], line 66 */
239 	if (!(eq_s_b(z, 2, s_1))) goto lab0;
240 	{   int ret;
241 	    ret = slice_del(z); /* delete, line 66 */
242 	    if (ret < 0) return ret;
243 	}
244     lab0:
245 	z->c = z->l - m;
246     }
247     {	int m3; /* setlimit, line 67 */
248 	int m = z->l - z->c; (void) m;
249 	if (z->c < z->I[0]) return 0;
250 	z->c = z->I[0]; /* tomark, line 67 */
251 	m3 = z->lb; z->lb = z->c;
252 	z->c = z->l - m;
253 	z->ket = z->c; /* [, line 67 */
254 	among_var = find_among_b(z, a_2, 5); /* substring, line 67 */
255 	if (!(among_var)) { z->lb = m3; return 0; }
256 	z->bra = z->c; /* ], line 67 */
257 	z->lb = m3;
258     }
259     switch(among_var) {
260 	case 0: return 0;
261 	case 1:
262 	    {	int ret;
263 		ret = slice_del(z); /* delete, line 70 */
264 		if (ret < 0) return ret;
265 	    }
266 	    {	int m = z->l - z->c; (void) m; /* do, line 70 */
267 		{   int ret = r_consonant_pair(z);
268 		    if (ret == 0) goto lab1; /* call consonant_pair, line 70 */
269 		    if (ret < 0) return ret;
270 		}
271 	    lab1:
272 		z->c = z->l - m;
273 	    }
274 	    break;
275 	case 2:
276 	    {	int ret;
277 		ret = slice_from_s(z, 4, s_2); /* <-, line 72 */
278 		if (ret < 0) return ret;
279 	    }
280 	    break;
281     }
282     return 1;
283 }
284 
285 static int r_undouble(struct SN_env * z) {
286     {	int m3; /* setlimit, line 76 */
287 	int m = z->l - z->c; (void) m;
288 	if (z->c < z->I[0]) return 0;
289 	z->c = z->I[0]; /* tomark, line 76 */
290 	m3 = z->lb; z->lb = z->c;
291 	z->c = z->l - m;
292 	z->ket = z->c; /* [, line 76 */
293 	if (!(out_grouping_b_U(z, g_v, 97, 248))) { z->lb = m3; return 0; }
294 	z->bra = z->c; /* ], line 76 */
295 	z->S[0] = slice_to(z, z->S[0]); /* -> ch, line 76 */
296 	if (z->S[0] == 0) return -1; /* -> ch, line 76 */
297 	z->lb = m3;
298     }
299     if (!(eq_v_b(z, z->S[0]))) return 0; /* name ch, line 77 */
300     {	int ret;
301 	ret = slice_del(z); /* delete, line 78 */
302 	if (ret < 0) return ret;
303     }
304     return 1;
305 }
306 
307 extern int danish_UTF_8_stem(struct SN_env * z) {
308     {	int c = z->c; /* do, line 84 */
309 	{   int ret = r_mark_regions(z);
310 	    if (ret == 0) goto lab0; /* call mark_regions, line 84 */
311 	    if (ret < 0) return ret;
312 	}
313     lab0:
314 	z->c = c;
315     }
316     z->lb = z->c; z->c = z->l; /* backwards, line 85 */
317 
318     {	int m = z->l - z->c; (void) m; /* do, line 86 */
319 	{   int ret = r_main_suffix(z);
320 	    if (ret == 0) goto lab1; /* call main_suffix, line 86 */
321 	    if (ret < 0) return ret;
322 	}
323     lab1:
324 	z->c = z->l - m;
325     }
326     {	int m = z->l - z->c; (void) m; /* do, line 87 */
327 	{   int ret = r_consonant_pair(z);
328 	    if (ret == 0) goto lab2; /* call consonant_pair, line 87 */
329 	    if (ret < 0) return ret;
330 	}
331     lab2:
332 	z->c = z->l - m;
333     }
334     {	int m = z->l - z->c; (void) m; /* do, line 88 */
335 	{   int ret = r_other_suffix(z);
336 	    if (ret == 0) goto lab3; /* call other_suffix, line 88 */
337 	    if (ret < 0) return ret;
338 	}
339     lab3:
340 	z->c = z->l - m;
341     }
342     {	int m = z->l - z->c; (void) m; /* do, line 89 */
343 	{   int ret = r_undouble(z);
344 	    if (ret == 0) goto lab4; /* call undouble, line 89 */
345 	    if (ret < 0) return ret;
346 	}
347     lab4:
348 	z->c = z->l - m;
349     }
350     z->c = z->lb;
351     return 1;
352 }
353 
354 extern struct SN_env * danish_UTF_8_create_env(void) { return SN_create_env(1, 2, 0); }
355 
356 extern void danish_UTF_8_close_env(struct SN_env * z) { SN_close_env(z); }