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