PostgreSQL Source Code git master
stem_ISO_8859_1_indonesian.c
Go to the documentation of this file.
1/* Generated from indonesian.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;
13};
14
15typedef struct SN_local SN_local;
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20extern int indonesian_ISO_8859_1_stem(struct SN_env * z);
21#ifdef __cplusplus
22}
23#endif
24
25static int r_remove_suffix(struct SN_env * z);
26static int r_remove_second_order_prefix(struct SN_env * z);
27static int r_remove_first_order_prefix(struct SN_env * z);
28static int r_remove_possessive_pronoun(struct SN_env * z);
29static int r_remove_particle(struct SN_env * z);
30
31static const symbol s_0[] = { 's' };
32static const symbol s_1[] = { 's' };
33static const symbol s_2[] = { 'p' };
34static const symbol s_3[] = { 'p' };
35static const symbol s_4[] = { 'a', 'j', 'a', 'r' };
36static const symbol s_5[] = { 'a', 'j', 'a', 'r' };
37static const symbol s_6[] = { 'e', 'r' };
38
39static const symbol s_0_0[3] = { 'k', 'a', 'h' };
40static const symbol s_0_1[3] = { 'l', 'a', 'h' };
41static const symbol s_0_2[3] = { 'p', 'u', 'n' };
42static const struct among a_0[3] = {
43{ 3, s_0_0, 0, 1, 0},
44{ 3, s_0_1, 0, 1, 0},
45{ 3, s_0_2, 0, 1, 0}
46};
47
48static const symbol s_1_0[3] = { 'n', 'y', 'a' };
49static const symbol s_1_1[2] = { 'k', 'u' };
50static const symbol s_1_2[2] = { 'm', 'u' };
51static const struct among a_1[3] = {
52{ 3, s_1_0, 0, 1, 0},
53{ 2, s_1_1, 0, 1, 0},
54{ 2, s_1_2, 0, 1, 0}
55};
56
57static const symbol s_2_0[1] = { 'i' };
58static const symbol s_2_1[2] = { 'a', 'n' };
59static const struct among a_2[2] = {
60{ 1, s_2_0, 0, 2, 0},
61{ 2, s_2_1, 0, 1, 0}
62};
63
64static const symbol s_3_0[2] = { 'd', 'i' };
65static const symbol s_3_1[2] = { 'k', 'e' };
66static const symbol s_3_2[2] = { 'm', 'e' };
67static const symbol s_3_3[3] = { 'm', 'e', 'm' };
68static const symbol s_3_4[3] = { 'm', 'e', 'n' };
69static const symbol s_3_5[4] = { 'm', 'e', 'n', 'g' };
70static const symbol s_3_6[3] = { 'p', 'e', 'm' };
71static const symbol s_3_7[3] = { 'p', 'e', 'n' };
72static const symbol s_3_8[4] = { 'p', 'e', 'n', 'g' };
73static const symbol s_3_9[3] = { 't', 'e', 'r' };
74static const struct among a_3[10] = {
75{ 2, s_3_0, 0, 1, 0},
76{ 2, s_3_1, 0, 3, 0},
77{ 2, s_3_2, 0, 1, 0},
78{ 3, s_3_3, -1, 5, 0},
79{ 3, s_3_4, -2, 2, 0},
80{ 4, s_3_5, -1, 1, 0},
81{ 3, s_3_6, 0, 6, 0},
82{ 3, s_3_7, 0, 4, 0},
83{ 4, s_3_8, -1, 3, 0},
84{ 3, s_3_9, 0, 1, 0}
85};
86
87static const symbol s_4_0[2] = { 'b', 'e' };
88static const symbol s_4_1[2] = { 'p', 'e' };
89static const struct among a_4[2] = {
90{ 2, s_4_0, 0, 2, 0},
91{ 2, s_4_1, 0, 1, 0}
92};
93
94static const unsigned char g_vowel[] = { 17, 65, 16 };
95
96static int r_remove_particle(struct SN_env * z) {
97 z->ket = z->c;
98 if (z->c - 2 <= z->lb || (z->p[z->c - 1] != 104 && z->p[z->c - 1] != 110)) return 0;
99 if (!find_among_b(z, a_0, 3, 0)) return 0;
100 z->bra = z->c;
101 {
102 int ret = slice_del(z);
103 if (ret < 0) return ret;
104 }
105 ((SN_local *)z)->i_measure -= 1;
106 return 1;
107}
108
109static int r_remove_possessive_pronoun(struct SN_env * z) {
110 z->ket = z->c;
111 if (z->c - 1 <= z->lb || (z->p[z->c - 1] != 97 && z->p[z->c - 1] != 117)) return 0;
112 if (!find_among_b(z, a_1, 3, 0)) return 0;
113 z->bra = z->c;
114 {
115 int ret = slice_del(z);
116 if (ret < 0) return ret;
117 }
118 ((SN_local *)z)->i_measure -= 1;
119 return 1;
120}
121
122static int r_remove_suffix(struct SN_env * z) {
123 int among_var;
124 z->ket = z->c;
125 if (z->c <= z->lb || (z->p[z->c - 1] != 105 && z->p[z->c - 1] != 110)) return 0;
126 among_var = find_among_b(z, a_2, 2, 0);
127 if (!among_var) return 0;
128 z->bra = z->c;
129 switch (among_var) {
130 case 1:
131 do {
132 int v_1 = z->l - z->c;
133 if (((SN_local *)z)->i_prefix == 3) goto lab0;
134 if (((SN_local *)z)->i_prefix == 2) goto lab0;
135 if (z->c <= z->lb || z->p[z->c - 1] != 'k') goto lab0;
136 z->c--;
137 z->bra = z->c;
138 break;
139 lab0:
140 z->c = z->l - v_1;
141 if (((SN_local *)z)->i_prefix == 1) return 0;
142 } while (0);
143 break;
144 case 2:
145 if (((SN_local *)z)->i_prefix > 2) return 0;
146 {
147 int v_2 = z->l - z->c;
148 if (z->c <= z->lb || z->p[z->c - 1] != 's') goto lab1;
149 z->c--;
150 return 0;
151 lab1:
152 z->c = z->l - v_2;
153 }
154 break;
155 }
156 {
157 int ret = slice_del(z);
158 if (ret < 0) return ret;
159 }
160 ((SN_local *)z)->i_measure -= 1;
161 return 1;
162}
163
164static int r_remove_first_order_prefix(struct SN_env * z) {
165 int among_var;
166 z->bra = z->c;
167 if (z->c + 1 >= z->l || (z->p[z->c + 1] != 105 && z->p[z->c + 1] != 101)) return 0;
168 among_var = find_among(z, a_3, 10, 0);
169 if (!among_var) return 0;
170 z->ket = z->c;
171 switch (among_var) {
172 case 1:
173 {
174 int ret = slice_del(z);
175 if (ret < 0) return ret;
176 }
177 ((SN_local *)z)->i_prefix = 1;
178 ((SN_local *)z)->i_measure -= 1;
179 break;
180 case 2:
181 do {
182 int v_1 = z->c;
183 if (z->c == z->l || z->p[z->c] != 'y') goto lab0;
184 z->c++;
185 {
186 int v_2 = z->c;
187 if (in_grouping(z, g_vowel, 97, 117, 0)) goto lab0;
188 z->c = v_2;
189 }
190 z->ket = z->c;
191 {
192 int ret = slice_from_s(z, 1, s_0);
193 if (ret < 0) return ret;
194 }
195 ((SN_local *)z)->i_prefix = 1;
196 ((SN_local *)z)->i_measure -= 1;
197 break;
198 lab0:
199 z->c = v_1;
200 {
201 int ret = slice_del(z);
202 if (ret < 0) return ret;
203 }
204 ((SN_local *)z)->i_prefix = 1;
205 ((SN_local *)z)->i_measure -= 1;
206 } while (0);
207 break;
208 case 3:
209 {
210 int ret = slice_del(z);
211 if (ret < 0) return ret;
212 }
213 ((SN_local *)z)->i_prefix = 3;
214 ((SN_local *)z)->i_measure -= 1;
215 break;
216 case 4:
217 do {
218 int v_3 = z->c;
219 if (z->c == z->l || z->p[z->c] != 'y') goto lab1;
220 z->c++;
221 {
222 int v_4 = z->c;
223 if (in_grouping(z, g_vowel, 97, 117, 0)) goto lab1;
224 z->c = v_4;
225 }
226 z->ket = z->c;
227 {
228 int ret = slice_from_s(z, 1, s_1);
229 if (ret < 0) return ret;
230 }
231 ((SN_local *)z)->i_prefix = 3;
232 ((SN_local *)z)->i_measure -= 1;
233 break;
234 lab1:
235 z->c = v_3;
236 {
237 int ret = slice_del(z);
238 if (ret < 0) return ret;
239 }
240 ((SN_local *)z)->i_prefix = 3;
241 ((SN_local *)z)->i_measure -= 1;
242 } while (0);
243 break;
244 case 5:
245 ((SN_local *)z)->i_prefix = 1;
246 ((SN_local *)z)->i_measure -= 1;
247 do {
248 int v_5 = z->c;
249 {
250 int v_6 = z->c;
251 if (in_grouping(z, g_vowel, 97, 117, 0)) goto lab2;
252 z->c = v_6;
253 {
254 int ret = slice_from_s(z, 1, s_2);
255 if (ret < 0) return ret;
256 }
257 }
258 break;
259 lab2:
260 z->c = v_5;
261 {
262 int ret = slice_del(z);
263 if (ret < 0) return ret;
264 }
265 } while (0);
266 break;
267 case 6:
268 ((SN_local *)z)->i_prefix = 3;
269 ((SN_local *)z)->i_measure -= 1;
270 do {
271 int v_7 = z->c;
272 {
273 int v_8 = z->c;
274 if (in_grouping(z, g_vowel, 97, 117, 0)) goto lab3;
275 z->c = v_8;
276 {
277 int ret = slice_from_s(z, 1, s_3);
278 if (ret < 0) return ret;
279 }
280 }
281 break;
282 lab3:
283 z->c = v_7;
284 {
285 int ret = slice_del(z);
286 if (ret < 0) return ret;
287 }
288 } while (0);
289 break;
290 }
291 return 1;
292}
293
294static int r_remove_second_order_prefix(struct SN_env * z) {
295 int among_var;
296 z->bra = z->c;
297 if (z->c + 1 >= z->l || z->p[z->c + 1] != 101) return 0;
298 among_var = find_among(z, a_4, 2, 0);
299 if (!among_var) return 0;
300 switch (among_var) {
301 case 1:
302 do {
303 int v_1 = z->c;
304 if (z->c == z->l || z->p[z->c] != 'r') goto lab0;
305 z->c++;
306 z->ket = z->c;
307 ((SN_local *)z)->i_prefix = 2;
308 break;
309 lab0:
310 z->c = v_1;
311 if (z->c == z->l || z->p[z->c] != 'l') goto lab1;
312 z->c++;
313 z->ket = z->c;
314 if (!(eq_s(z, 4, s_4))) goto lab1;
315 break;
316 lab1:
317 z->c = v_1;
318 z->ket = z->c;
319 ((SN_local *)z)->i_prefix = 2;
320 } while (0);
321 break;
322 case 2:
323 do {
324 int v_2 = z->c;
325 if (z->c == z->l || z->p[z->c] != 'r') goto lab2;
326 z->c++;
327 z->ket = z->c;
328 break;
329 lab2:
330 z->c = v_2;
331 if (z->c == z->l || z->p[z->c] != 'l') goto lab3;
332 z->c++;
333 z->ket = z->c;
334 if (!(eq_s(z, 4, s_5))) goto lab3;
335 break;
336 lab3:
337 z->c = v_2;
338 z->ket = z->c;
339 if (out_grouping(z, g_vowel, 97, 117, 0)) return 0;
340 if (!(eq_s(z, 2, s_6))) return 0;
341 } while (0);
342 ((SN_local *)z)->i_prefix = 4;
343 break;
344 }
345 ((SN_local *)z)->i_measure -= 1;
346 {
347 int ret = slice_del(z);
348 if (ret < 0) return ret;
349 }
350 return 1;
351}
352
353extern int indonesian_ISO_8859_1_stem(struct SN_env * z) {
354 ((SN_local *)z)->i_measure = 0;
355 {
356 int v_1 = z->c;
357 while (1) {
358 int v_2 = z->c;
359 {
360 int ret = out_grouping(z, g_vowel, 97, 117, 1);
361 if (ret < 0) goto lab1;
362 z->c += ret;
363 }
364 ((SN_local *)z)->i_measure += 1;
365 continue;
366 lab1:
367 z->c = v_2;
368 break;
369 }
370 z->c = v_1;
371 }
372 if (((SN_local *)z)->i_measure <= 2) return 0;
373 ((SN_local *)z)->i_prefix = 0;
374 z->lb = z->c; z->c = z->l;
375 {
376 int v_3 = z->l - z->c;
377 {
378 int ret = r_remove_particle(z);
379 if (ret < 0) return ret;
380 }
381 z->c = z->l - v_3;
382 }
383 if (((SN_local *)z)->i_measure <= 2) return 0;
384 {
385 int v_4 = z->l - z->c;
386 {
387 int ret = r_remove_possessive_pronoun(z);
388 if (ret < 0) return ret;
389 }
390 z->c = z->l - v_4;
391 }
392 z->c = z->lb;
393 if (((SN_local *)z)->i_measure <= 2) return 0;
394 do {
395 int v_5 = z->c;
396 {
397 int v_6 = z->c;
398 {
399 int ret = r_remove_first_order_prefix(z);
400 if (ret == 0) goto lab2;
401 if (ret < 0) return ret;
402 }
403 {
404 int v_7 = z->c;
405 {
406 int v_8 = z->c;
407 if (((SN_local *)z)->i_measure <= 2) goto lab3;
408 z->lb = z->c; z->c = z->l;
409 {
410 int ret = r_remove_suffix(z);
411 if (ret == 0) goto lab3;
412 if (ret < 0) return ret;
413 }
414 z->c = z->lb;
415 z->c = v_8;
416 }
417 if (((SN_local *)z)->i_measure <= 2) goto lab3;
418 {
419 int ret = r_remove_second_order_prefix(z);
420 if (ret == 0) goto lab3;
421 if (ret < 0) return ret;
422 }
423 lab3:
424 z->c = v_7;
425 }
426 z->c = v_6;
427 }
428 break;
429 lab2:
430 z->c = v_5;
431 {
432 int v_9 = z->c;
433 {
434 int ret = r_remove_second_order_prefix(z);
435 if (ret < 0) return ret;
436 }
437 z->c = v_9;
438 }
439 {
440 int v_10 = z->c;
441 if (((SN_local *)z)->i_measure <= 2) goto lab4;
442 z->lb = z->c; z->c = z->l;
443 {
444 int ret = r_remove_suffix(z);
445 if (ret == 0) goto lab4;
446 if (ret < 0) return ret;
447 }
448 z->c = z->lb;
449 lab4:
450 z->c = v_10;
451 }
452 } while (0);
453 return 1;
454}
455
457 struct SN_env * z = SN_new_env(sizeof(SN_local));
458 if (z) {
459 ((SN_local *)z)->i_prefix = 0;
460 ((SN_local *)z)->i_measure = 0;
461 }
462 return z;
463}
464
466 SN_delete_env(z);
467}
468
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 symbol s_2[]
static const symbol s_0_2[3]
static const struct among a_2[2]
static const symbol s_3_5[4]
static const symbol s_3_9[3]
static const symbol s_4[]
static const symbol s_3_7[3]
static const symbol s_1_2[2]
static const symbol s_3_1[2]
static int r_remove_particle(struct SN_env *z)
static const symbol s_4_1[2]
static int r_remove_first_order_prefix(struct SN_env *z)
static const symbol s_2_0[1]
static const struct among a_0[3]
static const symbol s_6[]
void indonesian_ISO_8859_1_close_env(struct SN_env *z)
static int r_remove_suffix(struct SN_env *z)
static const symbol s_3[]
static const symbol s_3_0[2]
static const symbol s_1_1[2]
static const symbol s_0_0[3]
static int r_remove_possessive_pronoun(struct SN_env *z)
static const symbol s_0_1[3]
static const struct among a_3[10]
static const symbol s_3_6[3]
static const struct among a_4[2]
static const struct among a_1[3]
static const symbol s_1[]
static const symbol s_3_4[3]
struct SN_env * indonesian_ISO_8859_1_create_env(void)
static const symbol s_3_3[3]
static const symbol s_4_0[2]
static const symbol s_1_0[3]
static const symbol s_3_8[4]
static int r_remove_second_order_prefix(struct SN_env *z)
static const unsigned char g_vowel[]
static const symbol s_2_1[2]
static const symbol s_3_2[2]
int indonesian_ISO_8859_1_stem(struct SN_env *z)
static const symbol s_5[]
static const symbol s_0[]
Definition: api.h:15
int lb
Definition: api.h:17
symbol * p
Definition: api.h:16
int ket
Definition: api.h:17
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 eq_s(struct SN_env *z, int s_size, const symbol *s)
Definition: utilities.c:231
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 find_among(struct SN_env *z, const struct among *v, int v_size, int(*call_among_func)(struct SN_env *))
Definition: utilities.c:249