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