xapian-core  1.4.27
indonesian.cc
Go to the documentation of this file.
1 /* Generated by Snowball 2.0.0 - https://snowballstem.org/ */
2 
3 
4 #include <config.h>
5 #include <limits.h>
6 #include "indonesian.h"
7 
8 static int tr_VOWEL(Xapian::StemImplementation * this_ptr) {
9  return (static_cast<Xapian::InternalStemIndonesian *>(this_ptr))->r_VOWEL();
10 }
11 
13  return (static_cast<Xapian::InternalStemIndonesian *>(this_ptr))->r_SUFFIX_I_OK();
14 }
15 
17  return (static_cast<Xapian::InternalStemIndonesian *>(this_ptr))->r_SUFFIX_AN_OK();
18 }
19 
21  return (static_cast<Xapian::InternalStemIndonesian *>(this_ptr))->r_SUFFIX_KAN_OK();
22 }
23 
24 static int tr_KER(Xapian::StemImplementation * this_ptr) {
25  return (static_cast<Xapian::InternalStemIndonesian *>(this_ptr))->r_KER();
26 }
27 
28 static const among_function af[5] =
29 {
30 /* 1 */ tr_VOWEL,
31 /* 2 */ tr_SUFFIX_I_OK,
32 /* 3 */ tr_SUFFIX_AN_OK,
33 /* 4 */ tr_SUFFIX_KAN_OK,
34 /* 5 */ tr_KER
35 };
36 
37 static const symbol s_pool[] = {
38 #define s_0_0 0
39 'k', 'a', 'h',
40 #define s_0_1 3
41 'l', 'a', 'h',
42 #define s_0_2 6
43 'p', 'u', 'n',
44 #define s_1_0 9
45 'n', 'y', 'a',
46 #define s_1_1 12
47 'k', 'u',
48 #define s_1_2 14
49 'm', 'u',
50 #define s_2_0 16
51 'i',
52 #define s_2_1 (s_2_2 + 1)
53 #define s_2_2 17
54 'k', 'a', 'n',
55 #define s_3_0 20
56 'd', 'i',
57 #define s_3_1 22
58 'k', 'e',
59 #define s_3_2 s_3_3
60 #define s_3_3 24
61 'm', 'e', 'm',
62 #define s_3_4 s_3_5
63 #define s_3_5 27
64 'm', 'e', 'n', 'g',
65 #define s_3_6 31
66 'm', 'e', 'n', 'y',
67 #define s_3_7 35
68 'p', 'e', 'm',
69 #define s_3_8 s_3_9
70 #define s_3_9 38
71 'p', 'e', 'n', 'g',
72 #define s_3_10 42
73 'p', 'e', 'n', 'y',
74 #define s_3_11 46
75 't', 'e', 'r',
76 #define s_4_0 s_4_1
77 #define s_4_1 49
78 'b', 'e', 'l', 'a', 'j', 'a', 'r',
79 #define s_4_2 56
80 'b', 'e', 'r',
81 #define s_4_3 s_4_4
82 #define s_4_4 59
83 'p', 'e', 'l', 'a', 'j', 'a', 'r',
84 #define s_4_5 66
85 'p', 'e', 'r',
86 };
87 
88 
89 static const struct among a_0[3] =
90 {
91 /* 0 */ { 3, s_0_0, -1, 1},
92 /* 1 */ { 3, s_0_1, -1, 1},
93 /* 2 */ { 3, s_0_2, -1, 1}
94 };
95 
96 
97 static const struct among a_1[3] =
98 {
99 /* 0 */ { 3, s_1_0, -1, 1},
100 /* 1 */ { 2, s_1_1, -1, 1},
101 /* 2 */ { 2, s_1_2, -1, 1}
102 };
103 
104 
105 static const struct among a_2[3] =
106 {
107 /* 0 */ { 1, s_2_0, -1, 1},
108 /* 1 */ { 2, s_2_1, -1, 1},
109 /* 2 */ { 3, s_2_2, 1, 1}
110 };
111 
112 static const unsigned char af_2[3] =
113 {
114 /* 0 */ 2 /* tr_SUFFIX_I_OK */,
115 /* 1 */ 3 /* tr_SUFFIX_AN_OK */,
116 /* 2 */ 4 /* tr_SUFFIX_KAN_OK */
117 };
118 
119 
120 static const struct among a_3[12] =
121 {
122 /* 0 */ { 2, s_3_0, -1, 1},
123 /* 1 */ { 2, s_3_1, -1, 2},
124 /* 2 */ { 2, s_3_2, -1, 1},
125 /* 3 */ { 3, s_3_3, 2, 5},
126 /* 4 */ { 3, s_3_4, 2, 1},
127 /* 5 */ { 4, s_3_5, 4, 1},
128 /* 6 */ { 4, s_3_6, 4, 3},
129 /* 7 */ { 3, s_3_7, -1, 6},
130 /* 8 */ { 3, s_3_8, -1, 2},
131 /* 9 */ { 4, s_3_9, 8, 2},
132 /* 10 */ { 4, s_3_10, 8, 4},
133 /* 11 */ { 3, s_3_11, -1, 1}
134 };
135 
136 static const unsigned char af_3[12] =
137 {
138 /* 0 */ 0,
139 /* 1 */ 0,
140 /* 2 */ 0,
141 /* 3 */ 0,
142 /* 4 */ 0,
143 /* 5 */ 0,
144 /* 6 */ 1 /* tr_VOWEL */,
145 /* 7 */ 0,
146 /* 8 */ 0,
147 /* 9 */ 0,
148 /* 10 */ 1 /* tr_VOWEL */,
149 /* 11 */ 0
150 };
151 
152 
153 static const struct among a_4[6] =
154 {
155 /* 0 */ { 2, s_4_0, -1, 3},
156 /* 1 */ { 7, s_4_1, 0, 4},
157 /* 2 */ { 3, s_4_2, 0, 3},
158 /* 3 */ { 2, s_4_3, -1, 1},
159 /* 4 */ { 7, s_4_4, 3, 2},
160 /* 5 */ { 3, s_4_5, 3, 1}
161 };
162 
163 static const unsigned char af_4[6] =
164 {
165 /* 0 */ 5 /* tr_KER */,
166 /* 1 */ 0,
167 /* 2 */ 0,
168 /* 3 */ 0,
169 /* 4 */ 0,
170 /* 5 */ 0
171 };
172 
173 static const unsigned char g_vowel[] = { 17, 65, 16 };
174 
175 static const symbol s_0[] = { 'e', 'r' };
176 static const symbol s_1[] = { 's' };
177 static const symbol s_2[] = { 's' };
178 static const symbol s_3[] = { 'p' };
179 static const symbol s_4[] = { 'p' };
180 static const symbol s_5[] = { 'a', 'j', 'a', 'r' };
181 static const symbol s_6[] = { 'a', 'j', 'a', 'r' };
182 
184  ket = c;
185  if (c - 2 <= lb || (p[c - 1] != 104 && p[c - 1] != 110)) return 0;
186  if (!(find_among_b(s_pool, a_0, 3, 0, 0))) return 0;
187  bra = c;
188  { int ret = slice_del();
189  if (ret < 0) return ret;
190  }
191  I_measure -= 1;
192  return 1;
193 }
194 
196  ket = c;
197  if (c - 1 <= lb || (p[c - 1] != 97 && p[c - 1] != 117)) return 0;
198  if (!(find_among_b(s_pool, a_1, 3, 0, 0))) return 0;
199  bra = c;
200  { int ret = slice_del();
201  if (ret < 0) return ret;
202  }
203  I_measure -= 1;
204  return 1;
205 }
206 
208 
209  if (!(I_prefix != 3)) return 0;
210  if (!(I_prefix != 2)) return 0;
211  return 1;
212 }
213 
215  if (!(I_prefix != 1)) return 0;
216  return 1;
217 }
218 
220  if (!(I_prefix <= 2)) return 0;
221  { int m1 = l - c; (void)m1;
222  if (c <= lb || p[c - 1] != 's') goto lab0;
223  c--;
224  return 0;
225  lab0:
226  c = l - m1;
227  }
228  return 1;
229 }
230 
232  ket = c;
233  if (c <= lb || (p[c - 1] != 105 && p[c - 1] != 110)) return 0;
234  if (!(find_among_b(s_pool, a_2, 3, af_2, af))) return 0;
235  bra = c;
236  { int ret = slice_del();
237  if (ret < 0) return ret;
238  }
239  I_measure -= 1;
240  return 1;
241 }
242 
244  if (in_grouping_U(g_vowel, 97, 117, 0)) return 0;
245  return 1;
246 }
247 
249  if (out_grouping_U(g_vowel, 97, 117, 0)) return 0;
250  if (!(eq_s(2, s_0))) return 0;
251  return 1;
252 }
253 
255  int among_var;
256  bra = c;
257  if (c + 1 >= l || (p[c + 1] != 105 && p[c + 1] != 101)) return 0;
258  among_var = find_among(s_pool, a_3, 12, af_3, af);
259  if (!(among_var)) return 0;
260  ket = c;
261  switch (among_var) {
262  case 1:
263  { int ret = slice_del();
264  if (ret < 0) return ret;
265  }
266  I_prefix = 1;
267  I_measure -= 1;
268  break;
269  case 2:
270  { int ret = slice_del();
271  if (ret < 0) return ret;
272  }
273  I_prefix = 3;
274  I_measure -= 1;
275  break;
276  case 3:
277  I_prefix = 1;
278  { int ret = slice_from_s(1, s_1);
279  if (ret < 0) return ret;
280  }
281  I_measure -= 1;
282  break;
283  case 4:
284  I_prefix = 3;
285  { int ret = slice_from_s(1, s_2);
286  if (ret < 0) return ret;
287  }
288  I_measure -= 1;
289  break;
290  case 5:
291  I_prefix = 1;
292  I_measure -= 1;
293  { int c1 = c;
294  { int c2 = c;
295  if (in_grouping_U(g_vowel, 97, 117, 0)) goto lab1;
296  c = c2;
297  { int ret = slice_from_s(1, s_3);
298  if (ret < 0) return ret;
299  }
300  }
301  goto lab0;
302  lab1:
303  c = c1;
304  { int ret = slice_del();
305  if (ret < 0) return ret;
306  }
307  }
308  lab0:
309  break;
310  case 6:
311  I_prefix = 3;
312  I_measure -= 1;
313  { int c3 = c;
314  { int c4 = c;
315  if (in_grouping_U(g_vowel, 97, 117, 0)) goto lab3;
316  c = c4;
317  { int ret = slice_from_s(1, s_4);
318  if (ret < 0) return ret;
319  }
320  }
321  goto lab2;
322  lab3:
323  c = c3;
324  { int ret = slice_del();
325  if (ret < 0) return ret;
326  }
327  }
328  lab2:
329  break;
330  }
331  return 1;
332 }
333 
335  int among_var;
336  bra = c;
337  if (c + 1 >= l || p[c + 1] != 101) return 0;
338  among_var = find_among(s_pool, a_4, 6, af_4, af);
339  if (!(among_var)) return 0;
340  ket = c;
341  switch (among_var) {
342  case 1:
343  { int ret = slice_del();
344  if (ret < 0) return ret;
345  }
346  I_prefix = 2;
347  I_measure -= 1;
348  break;
349  case 2:
350  { int ret = slice_from_s(4, s_5);
351  if (ret < 0) return ret;
352  }
353  I_measure -= 1;
354  break;
355  case 3:
356  { int ret = slice_del();
357  if (ret < 0) return ret;
358  }
359  I_prefix = 4;
360  I_measure -= 1;
361  break;
362  case 4:
363  { int ret = slice_from_s(4, s_6);
364  if (ret < 0) return ret;
365  }
366  I_prefix = 4;
367  I_measure -= 1;
368  break;
369  }
370  return 1;
371 }
372 
374  I_measure = 0;
375  { int c1 = c;
376  while(1) {
377  int c2 = c;
378  {
379  int ret = out_grouping_U(g_vowel, 97, 117, 1);
380  if (ret < 0) goto lab1;
381  c += ret;
382  }
383  I_measure += 1;
384  continue;
385  lab1:
386  c = c2;
387  break;
388  }
389  c = c1;
390  }
391  if (!(I_measure > 2)) return 0;
392  I_prefix = 0;
393  lb = c; c = l;
394 
395  { int m3 = l - c; (void)m3;
396  { int ret = r_remove_particle();
397  if (ret < 0) return ret;
398  }
399  c = l - m3;
400  }
401  if (!(I_measure > 2)) return 0;
402  { int m4 = l - c; (void)m4;
403  { int ret = r_remove_possessive_pronoun();
404  if (ret < 0) return ret;
405  }
406  c = l - m4;
407  }
408  c = lb;
409  if (!(I_measure > 2)) return 0;
410  { int c5 = c;
411  { int c_test6 = c;
412  { int ret = r_remove_first_order_prefix();
413  if (ret == 0) goto lab3;
414  if (ret < 0) return ret;
415  }
416  { int c7 = c;
417  { int c_test8 = c;
418  if (!(I_measure > 2)) goto lab4;
419  lb = c; c = l;
420 
421  { int ret = r_remove_suffix();
422  if (ret == 0) goto lab4;
423  if (ret < 0) return ret;
424  }
425  c = lb;
426  c = c_test8;
427  }
428  if (!(I_measure > 2)) goto lab4;
429  { int ret = r_remove_second_order_prefix();
430  if (ret == 0) goto lab4;
431  if (ret < 0) return ret;
432  }
433  lab4:
434  c = c7;
435  }
436  c = c_test6;
437  }
438  goto lab2;
439  lab3:
440  c = c5;
441  { int c9 = c;
442  { int ret = r_remove_second_order_prefix();
443  if (ret < 0) return ret;
444  }
445  c = c9;
446  }
447  { int c10 = c;
448  if (!(I_measure > 2)) goto lab5;
449  lb = c; c = l;
450 
451  { int ret = r_remove_suffix();
452  if (ret == 0) goto lab5;
453  if (ret < 0) return ret;
454  }
455  c = lb;
456  lab5:
457  c = c10;
458  }
459  }
460 lab2:
461  return 1;
462 }
463 
465  : I_prefix(0), I_measure(0)
466 {
467 }
468 
470 {
471 }
472 
473 std::string
475 {
476  return "indonesian";
477 }
static const struct among a_0[3]
Definition: indonesian.cc:89
#define s_3_3
#define s_3_1
#define s_2_1
#define s_2_0
#define s_4_5
#define s_3_2
int find_among_b(const symbol *pool, const struct among *v, int v_size, const unsigned char *fnum, const among_function *f)
#define s_1_0
#define s_2_2
static const unsigned char af_2[3]
Definition: indonesian.cc:112
#define s_4_2
static int tr_SUFFIX_AN_OK(Xapian::StemImplementation *this_ptr)
Definition: indonesian.cc:16
#define s_3_7
#define s_3_6
static const among_function af[5]
Definition: indonesian.cc:28
#define s_1_1
int eq_s(int s_size, const symbol *s)
#define s_3_10
#define s_0_0
static int tr_KER(Xapian::StemImplementation *this_ptr)
Definition: indonesian.cc:24
static const symbol s_6[]
Definition: indonesian.cc:181
static const struct among a_3[12]
Definition: indonesian.cc:120
int slice_from_s(int s_size, const symbol *s)
static int tr_VOWEL(Xapian::StemImplementation *this_ptr)
Definition: indonesian.cc:8
#define s_3_11
#define s_1_2
static const struct among a_1[3]
Definition: indonesian.cc:97
#define s_3_0
#define s_3_9
#define s_3_5
#define s_4_0
unsigned short symbol
Definition: header.h:6
#define s_4_1
int(* among_function)(Xapian::StemImplementation *)
Definition: steminternal.h:36
static int tr_SUFFIX_I_OK(Xapian::StemImplementation *this_ptr)
Definition: indonesian.cc:12
std::string get_description() const
Return a string describing this object.
Definition: indonesian.cc:474
static const unsigned char af_4[6]
Definition: indonesian.cc:163
#define s_0_2
static const symbol s_2[]
Definition: indonesian.cc:177
int stem()
Virtual method implemented by the subclass to actually do the work.
Definition: indonesian.cc:373
static const unsigned char g_vowel[]
Definition: indonesian.cc:173
static const struct among a_2[3]
Definition: indonesian.cc:105
Class representing a stemming algorithm implementation.
Definition: stem.h:38
Definition: header.h:191
#define s_0_1
static const symbol s_3[]
Definition: indonesian.cc:178
static const symbol s_4[]
Definition: indonesian.cc:179
#define s_4_4
static const symbol s_pool[]
Definition: indonesian.cc:37
static int tr_SUFFIX_KAN_OK(Xapian::StemImplementation *this_ptr)
Definition: indonesian.cc:20
#define s_4_3
static const symbol s_5[]
Definition: indonesian.cc:180
int find_among(const symbol *pool, const struct among *v, int v_size, const unsigned char *fnum, const among_function *f)
int out_grouping_U(const unsigned char *s, int min, int max, int repeat)
#define s_3_4
static const symbol s_1[]
Definition: indonesian.cc:176
static const struct among a_4[6]
Definition: indonesian.cc:153
static const symbol s_0[]
Definition: indonesian.cc:175
#define s_3_8
static const unsigned char af_3[12]
Definition: indonesian.cc:136
int in_grouping_U(const unsigned char *s, int min, int max, int repeat)