| 1 |
/* Generated by Snowball 2.2.0 - https://snowballstem.org/ */ |
| 2 |
|
| 3 |
#include "header.h" |
| 4 |
|
| 5 |
#ifdef __cplusplus |
| 6 |
extern "C" { |
| 7 |
#endif |
| 8 |
extern int indonesian_ISO_8859_1_stem(struct SN_env * z); |
| 9 |
#ifdef __cplusplus |
| 10 |
} |
| 11 |
#endif |
| 12 |
static int r_VOWEL(struct SN_env * z); |
| 13 |
static int r_SUFFIX_I_OK(struct SN_env * z); |
| 14 |
static int r_SUFFIX_AN_OK(struct SN_env * z); |
| 15 |
static int r_SUFFIX_KAN_OK(struct SN_env * z); |
| 16 |
static int r_KER(struct SN_env * z); |
| 17 |
static int r_remove_suffix(struct SN_env * z); |
| 18 |
static int r_remove_second_order_prefix(struct SN_env * z); |
| 19 |
static int r_remove_first_order_prefix(struct SN_env * z); |
| 20 |
static int r_remove_possessive_pronoun(struct SN_env * z); |
| 21 |
static int r_remove_particle(struct SN_env * z); |
| 22 |
#ifdef __cplusplus |
| 23 |
extern "C" { |
| 24 |
#endif |
| 25 |
|
| 26 |
|
| 27 |
extern struct SN_env * indonesian_ISO_8859_1_create_env(void); |
| 28 |
extern void indonesian_ISO_8859_1_close_env(struct SN_env * z); |
| 29 |
|
| 30 |
|
| 31 |
#ifdef __cplusplus |
| 32 |
} |
| 33 |
#endif |
| 34 |
static const symbol s_0_0[3] = { 'k', 'a', 'h' }; |
| 35 |
static const symbol s_0_1[3] = { 'l', 'a', 'h' }; |
| 36 |
static const symbol s_0_2[3] = { 'p', 'u', 'n' }; |
| 37 |
|
| 38 |
static 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 |
|
| 45 |
static const symbol s_1_0[3] = { 'n', 'y', 'a' }; |
| 46 |
static const symbol s_1_1[2] = { 'k', 'u' }; |
| 47 |
static const symbol s_1_2[2] = { 'm', 'u' }; |
| 48 |
|
| 49 |
static 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 |
|
| 56 |
static const symbol s_2_0[1] = { 'i' }; |
| 57 |
static const symbol s_2_1[2] = { 'a', 'n' }; |
| 58 |
static const symbol s_2_2[3] = { 'k', 'a', 'n' }; |
| 59 |
|
| 60 |
static 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 |
|
| 67 |
static const symbol s_3_0[2] = { 'd', 'i' }; |
| 68 |
static const symbol s_3_1[2] = { 'k', 'e' }; |
| 69 |
static const symbol s_3_2[2] = { 'm', 'e' }; |
| 70 |
static const symbol s_3_3[3] = { 'm', 'e', 'm' }; |
| 71 |
static const symbol s_3_4[3] = { 'm', 'e', 'n' }; |
| 72 |
static const symbol s_3_5[4] = { 'm', 'e', 'n', 'g' }; |
| 73 |
static const symbol s_3_6[4] = { 'm', 'e', 'n', 'y' }; |
| 74 |
static const symbol s_3_7[3] = { 'p', 'e', 'm' }; |
| 75 |
static const symbol s_3_8[3] = { 'p', 'e', 'n' }; |
| 76 |
static const symbol s_3_9[4] = { 'p', 'e', 'n', 'g' }; |
| 77 |
static const symbol s_3_10[4] = { 'p', 'e', 'n', 'y' }; |
| 78 |
static const symbol s_3_11[3] = { 't', 'e', 'r' }; |
| 79 |
|
| 80 |
static 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 |
|
| 96 |
static const symbol s_4_0[2] = { 'b', 'e' }; |
| 97 |
static const symbol s_4_1[7] = { 'b', 'e', 'l', 'a', 'j', 'a', 'r' }; |
| 98 |
static const symbol s_4_2[3] = { 'b', 'e', 'r' }; |
| 99 |
static const symbol s_4_3[2] = { 'p', 'e' }; |
| 100 |
static const symbol s_4_4[7] = { 'p', 'e', 'l', 'a', 'j', 'a', 'r' }; |
| 101 |
static const symbol s_4_5[3] = { 'p', 'e', 'r' }; |
| 102 |
|
| 103 |
static 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 |
|
| 113 |
static const unsigned char g_vowel[] = { 17, 65, 16 }; |
| 114 |
|
| 115 |
static const symbol s_0[] = { 'e', 'r' }; |
| 116 |
static const symbol s_1[] = { 's' }; |
| 117 |
static const symbol s_2[] = { 's' }; |
| 118 |
static const symbol s_3[] = { 'p' }; |
| 119 |
static const symbol s_4[] = { 'p' }; |
| 120 |
static const symbol s_5[] = { 'a', 'j', 'a', 'r' }; |
| 121 |
static const symbol s_6[] = { 'a', 'j', 'a', 'r' }; |
| 122 |
|
| 123 |
static 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 |
|
| 135 |
static 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 |
|
| 147 |
static 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 |
|
| 154 |
static int r_SUFFIX_AN_OK(struct SN_env * z) { |
| 155 |
return z->I[0] != 1; |
| 156 |
} |
| 157 |
|
| 158 |
static int r_SUFFIX_I_OK(struct SN_env * z) { |
| 159 |
if (z->I[0] > 2) return 0; |
| 160 |
{ int m1 = z->l - z->c; (void)m1; |
| 161 |
if (z->c <= z->lb || z->p[z->c - 1] != 's') goto lab0; |
| 162 |
z->c--; |
| 163 |
return 0; |
| 164 |
lab0: |
| 165 |
z->c = z->l - m1; |
| 166 |
} |
| 167 |
return 1; |
| 168 |
} |
| 169 |
|
| 170 |
static int r_remove_suffix(struct SN_env * z) { |
| 171 |
z->ket = z->c; |
| 172 |
if (z->c <= z->lb || (z->p[z->c - 1] != 105 && z->p[z->c - 1] != 110)) return 0; |
| 173 |
if (!find_among_b(z, a_2, 3)) return 0; |
| 174 |
z->bra = z->c; |
| 175 |
{ int ret = slice_del(z); |
| 176 |
if (ret < 0) return ret; |
| 177 |
} |
| 178 |
z->I[1] -= 1; |
| 179 |
return 1; |
| 180 |
} |
| 181 |
|
| 182 |
static int r_VOWEL(struct SN_env * z) { |
| 183 |
if (in_grouping(z, g_vowel, 97, 117, 0)) return 0; |
| 184 |
return 1; |
| 185 |
} |
| 186 |
|
| 187 |
static int r_KER(struct SN_env * z) { |
| 188 |
if (out_grouping(z, g_vowel, 97, 117, 0)) return 0; |
| 189 |
if (!(eq_s(z, 2, s_0))) return 0; |
| 190 |
return 1; |
| 191 |
} |
| 192 |
|
| 193 |
static int r_remove_first_order_prefix(struct SN_env * z) { |
| 194 |
int among_var; |
| 195 |
z->bra = z->c; |
| 196 |
if (z->c + 1 >= z->l || (z->p[z->c + 1] != 105 && z->p[z->c + 1] != 101)) return 0; |
| 197 |
among_var = find_among(z, a_3, 12); |
| 198 |
if (!among_var) return 0; |
| 199 |
z->ket = z->c; |
| 200 |
switch (among_var) { |
| 201 |
case 1: |
| 202 |
{ int ret = slice_del(z); |
| 203 |
if (ret < 0) return ret; |
| 204 |
} |
| 205 |
z->I[0] = 1; |
| 206 |
z->I[1] -= 1; |
| 207 |
break; |
| 208 |
case 2: |
| 209 |
{ int ret = slice_del(z); |
| 210 |
if (ret < 0) return ret; |
| 211 |
} |
| 212 |
z->I[0] = 3; |
| 213 |
z->I[1] -= 1; |
| 214 |
break; |
| 215 |
case 3: |
| 216 |
z->I[0] = 1; |
| 217 |
{ int ret = slice_from_s(z, 1, s_1); |
| 218 |
if (ret < 0) return ret; |
| 219 |
} |
| 220 |
z->I[1] -= 1; |
| 221 |
break; |
| 222 |
case 4: |
| 223 |
z->I[0] = 3; |
| 224 |
{ int ret = slice_from_s(z, 1, s_2); |
| 225 |
if (ret < 0) return ret; |
| 226 |
} |
| 227 |
z->I[1] -= 1; |
| 228 |
break; |
| 229 |
case 5: |
| 230 |
z->I[0] = 1; |
| 231 |
z->I[1] -= 1; |
| 232 |
{ int c1 = z->c; |
| 233 |
{ int c2 = z->c; |
| 234 |
if (in_grouping(z, g_vowel, 97, 117, 0)) goto lab1; |
| 235 |
z->c = c2; |
| 236 |
{ int ret = slice_from_s(z, 1, s_3); |
| 237 |
if (ret < 0) return ret; |
| 238 |
} |
| 239 |
} |
| 240 |
goto lab0; |
| 241 |
lab1: |
| 242 |
z->c = c1; |
| 243 |
{ int ret = slice_del(z); |
| 244 |
if (ret < 0) return ret; |
| 245 |
} |
| 246 |
} |
| 247 |
lab0: |
| 248 |
break; |
| 249 |
case 6: |
| 250 |
z->I[0] = 3; |
| 251 |
z->I[1] -= 1; |
| 252 |
{ int c3 = z->c; |
| 253 |
{ int c4 = z->c; |
| 254 |
if (in_grouping(z, g_vowel, 97, 117, 0)) goto lab3; |
| 255 |
z->c = c4; |
| 256 |
{ int ret = slice_from_s(z, 1, s_4); |
| 257 |
if (ret < 0) return ret; |
| 258 |
} |
| 259 |
} |
| 260 |
goto lab2; |
| 261 |
lab3: |
| 262 |
z->c = c3; |
| 263 |
{ int ret = slice_del(z); |
| 264 |
if (ret < 0) return ret; |
| 265 |
} |
| 266 |
} |
| 267 |
lab2: |
| 268 |
break; |
| 269 |
} |
| 270 |
return 1; |
| 271 |
} |
| 272 |
|
| 273 |
static int r_remove_second_order_prefix(struct SN_env * z) { |
| 274 |
int among_var; |
| 275 |
z->bra = z->c; |
| 276 |
if (z->c + 1 >= z->l || z->p[z->c + 1] != 101) return 0; |
| 277 |
among_var = find_among(z, a_4, 6); |
| 278 |
if (!among_var) return 0; |
| 279 |
z->ket = z->c; |
| 280 |
switch (among_var) { |
| 281 |
case 1: |
| 282 |
{ int ret = slice_del(z); |
| 283 |
if (ret < 0) return ret; |
| 284 |
} |
| 285 |
z->I[0] = 2; |
| 286 |
z->I[1] -= 1; |
| 287 |
break; |
| 288 |
case 2: |
| 289 |
{ int ret = slice_from_s(z, 4, s_5); |
| 290 |
if (ret < 0) return ret; |
| 291 |
} |
| 292 |
z->I[1] -= 1; |
| 293 |
break; |
| 294 |
case 3: |
| 295 |
{ int ret = slice_del(z); |
| 296 |
if (ret < 0) return ret; |
| 297 |
} |
| 298 |
z->I[0] = 4; |
| 299 |
z->I[1] -= 1; |
| 300 |
break; |
| 301 |
case 4: |
| 302 |
{ int ret = slice_from_s(z, 4, s_6); |
| 303 |
if (ret < 0) return ret; |
| 304 |
} |
| 305 |
z->I[0] = 4; |
| 306 |
z->I[1] -= 1; |
| 307 |
break; |
| 308 |
} |
| 309 |
return 1; |
| 310 |
} |
| 311 |
|
| 312 |
extern int indonesian_ISO_8859_1_stem(struct SN_env * z) { |
| 313 |
z->I[1] = 0; |
| 314 |
{ int c1 = z->c; |
| 315 |
while(1) { |
| 316 |
int c2 = z->c; |
| 317 |
|
| 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 |
} |
| 400 |
lab2: |
| 401 |
return 1; |
| 402 |
} |
| 403 |
|
| 404 |
extern struct SN_env * indonesian_ISO_8859_1_create_env(void) { return SN_create_env(0, 2); } |
| 405 |
|
| 406 |
extern void indonesian_ISO_8859_1_close_env(struct SN_env * z) { SN_close_env(z, 0); } |
| 407 |
|