xapian-core  2.0.0
indonesian.cc
Go to the documentation of this file.
1 /* Generated from indonesian.sbl by Snowball 3.0.0 - https://snowballstem.org/ */
2 
3 #include <config.h>
4 
5 #define SNOWBALL_RUNTIME_THROW_EXCEPTIONS
6 #include "indonesian.h"
7 
8 #include <stddef.h>
9 
11 
12 static int r_remove_suffix(struct SN_env * z);
13 static int r_remove_second_order_prefix(struct SN_env * z);
14 static int r_remove_first_order_prefix(struct SN_env * z);
15 static int r_remove_possessive_pronoun(struct SN_env * z);
16 static int r_remove_particle(struct SN_env * z);
17 
18 static const symbol s_0[] = { 's' };
19 static const symbol s_1[] = { 's' };
20 static const symbol s_2[] = { 'p' };
21 static const symbol s_3[] = { 'p' };
22 static const symbol s_4[] = { 'a', 'j', 'a', 'r' };
23 static const symbol s_5[] = { 'a', 'j', 'a', 'r' };
24 static const symbol s_6[] = { 'e', 'r' };
25 
26 static const symbol s_0_0[3] = { 'k', 'a', 'h' };
27 static const symbol s_0_1[3] = { 'l', 'a', 'h' };
28 static const symbol s_0_2[3] = { 'p', 'u', 'n' };
29 static const struct among a_0[3] = {
30 { 3, s_0_0, 0, 1, 0},
31 { 3, s_0_1, 0, 1, 0},
32 { 3, s_0_2, 0, 1, 0}
33 };
34 
35 static const symbol s_1_0[3] = { 'n', 'y', 'a' };
36 static const symbol s_1_1[2] = { 'k', 'u' };
37 static const symbol s_1_2[2] = { 'm', 'u' };
38 static const struct among a_1[3] = {
39 { 3, s_1_0, 0, 1, 0},
40 { 2, s_1_1, 0, 1, 0},
41 { 2, s_1_2, 0, 1, 0}
42 };
43 
44 static const symbol s_2_0[1] = { 'i' };
45 static const symbol s_2_1[2] = { 'a', 'n' };
46 static const struct among a_2[2] = {
47 { 1, s_2_0, 0, 2, 0},
48 { 2, s_2_1, 0, 1, 0}
49 };
50 
51 static const symbol s_3_0[2] = { 'd', 'i' };
52 static const symbol s_3_1[2] = { 'k', 'e' };
53 static const symbol s_3_2[2] = { 'm', 'e' };
54 static const symbol s_3_3[3] = { 'm', 'e', 'm' };
55 static const symbol s_3_4[3] = { 'm', 'e', 'n' };
56 static const symbol s_3_5[4] = { 'm', 'e', 'n', 'g' };
57 static const symbol s_3_6[3] = { 'p', 'e', 'm' };
58 static const symbol s_3_7[3] = { 'p', 'e', 'n' };
59 static const symbol s_3_8[4] = { 'p', 'e', 'n', 'g' };
60 static const symbol s_3_9[3] = { 't', 'e', 'r' };
61 static const struct among a_3[10] = {
62 { 2, s_3_0, 0, 1, 0},
63 { 2, s_3_1, 0, 3, 0},
64 { 2, s_3_2, 0, 1, 0},
65 { 3, s_3_3, -1, 5, 0},
66 { 3, s_3_4, -2, 2, 0},
67 { 4, s_3_5, -1, 1, 0},
68 { 3, s_3_6, 0, 6, 0},
69 { 3, s_3_7, 0, 4, 0},
70 { 4, s_3_8, -1, 3, 0},
71 { 3, s_3_9, 0, 1, 0}
72 };
73 
74 static const symbol s_4_0[2] = { 'b', 'e' };
75 static const symbol s_4_1[2] = { 'p', 'e' };
76 static const struct among a_4[2] = {
77 { 2, s_4_0, 0, 2, 0},
78 { 2, s_4_1, 0, 1, 0}
79 };
80 
81 static const unsigned char g_vowel[] = { 17, 65, 16 };
82 
83 static int r_remove_particle(struct SN_env * z) {
84  z->ket = z->c;
85  if (z->c - 2 <= z->lb || (z->p[z->c - 1] != 104 && z->p[z->c - 1] != 110)) return 0;
86  if (!find_among_b(z, a_0, 3, 0)) return 0;
87  z->bra = z->c;
88  slice_del(z);
89  ((SN_local *)z)->i_measure -= 1;
90  return 1;
91 }
92 
93 static int r_remove_possessive_pronoun(struct SN_env * z) {
94  z->ket = z->c;
95  if (z->c - 1 <= z->lb || (z->p[z->c - 1] != 97 && z->p[z->c - 1] != 117)) return 0;
96  if (!find_among_b(z, a_1, 3, 0)) return 0;
97  z->bra = z->c;
98  slice_del(z);
99  ((SN_local *)z)->i_measure -= 1;
100  return 1;
101 }
102 
103 static int r_remove_suffix(struct SN_env * z) {
104  int among_var;
105  z->ket = z->c;
106  if (z->c <= z->lb || (z->p[z->c - 1] != 105 && z->p[z->c - 1] != 110)) return 0;
107  among_var = find_among_b(z, a_2, 2, 0);
108  if (!among_var) return 0;
109  z->bra = z->c;
110  switch (among_var) {
111  case 1:
112  do {
113  int v_1 = z->l - z->c;
114  if (((SN_local *)z)->i_prefix == 3) goto lab0;
115  if (((SN_local *)z)->i_prefix == 2) goto lab0;
116  if (z->c <= z->lb || z->p[z->c - 1] != 'k') goto lab0;
117  z->c--;
118  z->bra = z->c;
119  break;
120  lab0:
121  z->c = z->l - v_1;
122  if (((SN_local *)z)->i_prefix == 1) return 0;
123  } while (0);
124  break;
125  case 2:
126  if (((SN_local *)z)->i_prefix > 2) return 0;
127  {
128  int v_2 = z->l - z->c;
129  if (z->c <= z->lb || z->p[z->c - 1] != 's') goto lab1;
130  z->c--;
131  return 0;
132  lab1:
133  z->c = z->l - v_2;
134  }
135  break;
136  }
137  slice_del(z);
138  ((SN_local *)z)->i_measure -= 1;
139  return 1;
140 }
141 
142 static int r_remove_first_order_prefix(struct SN_env * z) {
143  int among_var;
144  z->bra = z->c;
145  if (z->c + 1 >= z->l || (z->p[z->c + 1] != 105 && z->p[z->c + 1] != 101)) return 0;
146  among_var = find_among(z, a_3, 10, 0);
147  if (!among_var) return 0;
148  z->ket = z->c;
149  switch (among_var) {
150  case 1:
151  slice_del(z);
152  ((SN_local *)z)->i_prefix = 1;
153  ((SN_local *)z)->i_measure -= 1;
154  break;
155  case 2:
156  do {
157  int v_1 = z->c;
158  if (z->c == z->l || z->p[z->c] != 'y') goto lab0;
159  z->c++;
160  {
161  int v_2 = z->c;
162  if (in_grouping_U(z, g_vowel, 97, 117, 0)) goto lab0;
163  z->c = v_2;
164  }
165  z->ket = z->c;
166  slice_from_s(z, 1, s_0);
167  ((SN_local *)z)->i_prefix = 1;
168  ((SN_local *)z)->i_measure -= 1;
169  break;
170  lab0:
171  z->c = v_1;
172  slice_del(z);
173  ((SN_local *)z)->i_prefix = 1;
174  ((SN_local *)z)->i_measure -= 1;
175  } while (0);
176  break;
177  case 3:
178  slice_del(z);
179  ((SN_local *)z)->i_prefix = 3;
180  ((SN_local *)z)->i_measure -= 1;
181  break;
182  case 4:
183  do {
184  int v_3 = z->c;
185  if (z->c == z->l || z->p[z->c] != 'y') goto lab1;
186  z->c++;
187  {
188  int v_4 = z->c;
189  if (in_grouping_U(z, g_vowel, 97, 117, 0)) goto lab1;
190  z->c = v_4;
191  }
192  z->ket = z->c;
193  slice_from_s(z, 1, s_1);
194  ((SN_local *)z)->i_prefix = 3;
195  ((SN_local *)z)->i_measure -= 1;
196  break;
197  lab1:
198  z->c = v_3;
199  slice_del(z);
200  ((SN_local *)z)->i_prefix = 3;
201  ((SN_local *)z)->i_measure -= 1;
202  } while (0);
203  break;
204  case 5:
205  ((SN_local *)z)->i_prefix = 1;
206  ((SN_local *)z)->i_measure -= 1;
207  do {
208  int v_5 = z->c;
209  {
210  int v_6 = z->c;
211  if (in_grouping_U(z, g_vowel, 97, 117, 0)) goto lab2;
212  z->c = v_6;
213  slice_from_s(z, 1, s_2);
214  }
215  break;
216  lab2:
217  z->c = v_5;
218  slice_del(z);
219  } while (0);
220  break;
221  case 6:
222  ((SN_local *)z)->i_prefix = 3;
223  ((SN_local *)z)->i_measure -= 1;
224  do {
225  int v_7 = z->c;
226  {
227  int v_8 = z->c;
228  if (in_grouping_U(z, g_vowel, 97, 117, 0)) goto lab3;
229  z->c = v_8;
230  slice_from_s(z, 1, s_3);
231  }
232  break;
233  lab3:
234  z->c = v_7;
235  slice_del(z);
236  } while (0);
237  break;
238  }
239  return 1;
240 }
241 
242 static int r_remove_second_order_prefix(struct SN_env * z) {
243  int among_var;
244  z->bra = z->c;
245  if (z->c + 1 >= z->l || z->p[z->c + 1] != 101) return 0;
246  among_var = find_among(z, a_4, 2, 0);
247  if (!among_var) return 0;
248  switch (among_var) {
249  case 1:
250  do {
251  int v_1 = z->c;
252  if (z->c == z->l || z->p[z->c] != 'r') goto lab0;
253  z->c++;
254  z->ket = z->c;
255  ((SN_local *)z)->i_prefix = 2;
256  break;
257  lab0:
258  z->c = v_1;
259  if (z->c == z->l || z->p[z->c] != 'l') goto lab1;
260  z->c++;
261  z->ket = z->c;
262  if (!(eq_s(z, 4, s_4))) goto lab1;
263  break;
264  lab1:
265  z->c = v_1;
266  z->ket = z->c;
267  ((SN_local *)z)->i_prefix = 2;
268  } while (0);
269  break;
270  case 2:
271  do {
272  int v_2 = z->c;
273  if (z->c == z->l || z->p[z->c] != 'r') goto lab2;
274  z->c++;
275  z->ket = z->c;
276  break;
277  lab2:
278  z->c = v_2;
279  if (z->c == z->l || z->p[z->c] != 'l') goto lab3;
280  z->c++;
281  z->ket = z->c;
282  if (!(eq_s(z, 4, s_5))) goto lab3;
283  break;
284  lab3:
285  z->c = v_2;
286  z->ket = z->c;
287  if (out_grouping_U(z, g_vowel, 97, 117, 0)) return 0;
288  if (!(eq_s(z, 2, s_6))) return 0;
289  } while (0);
290  ((SN_local *)z)->i_prefix = 4;
291  break;
292  }
293  ((SN_local *)z)->i_measure -= 1;
294  slice_del(z);
295  return 1;
296 }
297 
299  ((SN_local *)z)->i_measure = 0;
300  {
301  int v_1 = z->c;
302  while (1) {
303  int v_2 = z->c;
304  {
305  int ret = out_grouping_U(z, g_vowel, 97, 117, 1);
306  if (ret < 0) goto lab1;
307  z->c += ret;
308  }
309  ((SN_local *)z)->i_measure += 1;
310  continue;
311  lab1:
312  z->c = v_2;
313  break;
314  }
315  z->c = v_1;
316  }
317  if (((SN_local *)z)->i_measure <= 2) return 0;
318  ((SN_local *)z)->i_prefix = 0;
319  z->lb = z->c; z->c = z->l;
320  {
321  int v_3 = z->l - z->c;
323  z->c = z->l - v_3;
324  }
325  if (((SN_local *)z)->i_measure <= 2) return 0;
326  {
327  int v_4 = z->l - z->c;
329  z->c = z->l - v_4;
330  }
331  z->c = z->lb;
332  if (((SN_local *)z)->i_measure <= 2) return 0;
333  do {
334  int v_5 = z->c;
335  {
336  int v_6 = z->c;
337  if (!r_remove_first_order_prefix(z)) goto lab2;
338  {
339  int v_7 = z->c;
340  {
341  int v_8 = z->c;
342  if (((SN_local *)z)->i_measure <= 2) goto lab3;
343  z->lb = z->c; z->c = z->l;
344  if (!r_remove_suffix(z)) goto lab3;
345  z->c = z->lb;
346  z->c = v_8;
347  }
348  if (((SN_local *)z)->i_measure <= 2) goto lab3;
349  if (!r_remove_second_order_prefix(z)) goto lab3;
350  lab3:
351  z->c = v_7;
352  }
353  z->c = v_6;
354  }
355  break;
356  lab2:
357  z->c = v_5;
358  {
359  int v_9 = z->c;
361  z->c = v_9;
362  }
363  {
364  int v_10 = z->c;
365  if (((SN_local *)z)->i_measure <= 2) goto lab4;
366  z->lb = z->c; z->c = z->l;
367  if (!r_remove_suffix(z)) goto lab4;
368  z->c = z->lb;
369  lab4:
370  z->c = v_10;
371  }
372  } while (0);
373  return 1;
374 }
unsigned char symbol
Definition: api.h:4
static int stem(struct SN_env *z)
Definition: indonesian.cc:298
static const symbol s_2[]
Definition: indonesian.cc:20
static const symbol s_0_2[3]
Definition: indonesian.cc:28
static const struct among a_2[2]
Definition: indonesian.cc:46
static const symbol s_3_5[4]
Definition: indonesian.cc:56
static const symbol s_3_9[3]
Definition: indonesian.cc:60
static const symbol s_4[]
Definition: indonesian.cc:22
static const symbol s_3_7[3]
Definition: indonesian.cc:58
static const symbol s_1_2[2]
Definition: indonesian.cc:37
static const symbol s_3_1[2]
Definition: indonesian.cc:52
static int r_remove_particle(struct SN_env *z)
Definition: indonesian.cc:83
static const symbol s_4_1[2]
Definition: indonesian.cc:75
static int r_remove_first_order_prefix(struct SN_env *z)
Definition: indonesian.cc:142
static const symbol s_2_0[1]
Definition: indonesian.cc:44
static const struct among a_0[3]
Definition: indonesian.cc:29
static const symbol s_6[]
Definition: indonesian.cc:24
static int r_remove_suffix(struct SN_env *z)
Definition: indonesian.cc:103
Xapian::Internal::Snowball::Indonesian::SN_local SN_local
Definition: indonesian.cc:10
static const symbol s_3[]
Definition: indonesian.cc:21
static const symbol s_3_0[2]
Definition: indonesian.cc:51
static const symbol s_1_1[2]
Definition: indonesian.cc:36
static const symbol s_0_0[3]
Definition: indonesian.cc:26
static int r_remove_possessive_pronoun(struct SN_env *z)
Definition: indonesian.cc:93
static const symbol s_0_1[3]
Definition: indonesian.cc:27
static const struct among a_3[10]
Definition: indonesian.cc:61
static const symbol s_3_6[3]
Definition: indonesian.cc:57
static const struct among a_4[2]
Definition: indonesian.cc:76
static const struct among a_1[3]
Definition: indonesian.cc:38
static const symbol s_1[]
Definition: indonesian.cc:19
static const symbol s_3_4[3]
Definition: indonesian.cc:55
static const symbol s_3_3[3]
Definition: indonesian.cc:54
static const symbol s_4_0[2]
Definition: indonesian.cc:74
static const symbol s_1_0[3]
Definition: indonesian.cc:35
static const symbol s_3_8[4]
Definition: indonesian.cc:59
static int r_remove_second_order_prefix(struct SN_env *z)
Definition: indonesian.cc:242
static const unsigned char g_vowel[]
Definition: indonesian.cc:81
static const symbol s_2_1[2]
Definition: indonesian.cc:45
static const symbol s_3_2[2]
Definition: indonesian.cc:53
static const symbol s_5[]
Definition: indonesian.cc:23
static const symbol s_0[]
Definition: indonesian.cc:18
int out_grouping_U(struct SN_env *z, const unsigned char *s, int min, int max, int repeat)
Definition: utilities.cc:164
int in_grouping_U(struct SN_env *z, const unsigned char *s, int min, int max, int repeat)
Definition: utilities.cc:140
SNOWBALL_ERR slice_from_s(struct SN_env *z, int s_size, const symbol *s)
Definition: utilities.cc:439
int eq_s(struct SN_env *z, int s_size, const symbol *s)
Definition: utilities.cc:238
SNOWBALL_ERR slice_del(struct SN_env *z)
Definition: utilities.cc:450
int find_among_b(struct SN_env *z, const struct among *v, int v_size, int(*)(struct SN_env *))
Definition: utilities.cc:322
int find_among(struct SN_env *z, const struct among *v, int v_size, int(*)(struct SN_env *))
Definition: utilities.cc:256
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
Definition: header.h:256