xref: /Lucene/lucene/analysis/common/src/java/org/tartarus/snowball/ext/IndonesianStemmer.java (revision 0b1d8ccba6cf394f707a09217813a25ec1504e50)
1 // Generated by Snowball 2.0.0 - https://snowballstem.org/
2 
3 package org.tartarus.snowball.ext;
4 
5 import org.tartarus.snowball.Among;
6 
7 /**
8  * This class implements the stemming algorithm defined by a snowball script.
9  *
10  * <p>Generated by Snowball 2.0.0 - https://snowballstem.org/
11  */
12 @SuppressWarnings("unused")
13 public class IndonesianStemmer extends org.tartarus.snowball.SnowballStemmer {
14 
15   private static final long serialVersionUID = 1L;
16   private static final java.lang.invoke.MethodHandles.Lookup methodObject =
17       java.lang.invoke.MethodHandles.lookup();
18 
19   private static final Among a_0[] = {
20     new Among("kah", -1, 1), new Among("lah", -1, 1), new Among("pun", -1, 1)
21   };
22 
23   private static final Among a_1[] = {
24     new Among("nya", -1, 1), new Among("ku", -1, 1), new Among("mu", -1, 1)
25   };
26 
27   private static final Among a_2[] = {
28     new Among("i", -1, 1, "r_SUFFIX_I_OK", methodObject),
29     new Among("an", -1, 1, "r_SUFFIX_AN_OK", methodObject),
30     new Among("kan", 1, 1, "r_SUFFIX_KAN_OK", methodObject)
31   };
32 
33   private static final Among a_3[] = {
34     new Among("di", -1, 1),
35     new Among("ke", -1, 2),
36     new Among("me", -1, 1),
37     new Among("mem", 2, 5),
38     new Among("men", 2, 1),
39     new Among("meng", 4, 1),
40     new Among("meny", 4, 3, "r_VOWEL", methodObject),
41     new Among("pem", -1, 6),
42     new Among("pen", -1, 2),
43     new Among("peng", 8, 2),
44     new Among("peny", 8, 4, "r_VOWEL", methodObject),
45     new Among("ter", -1, 1)
46   };
47 
48   private static final Among a_4[] = {
49     new Among("be", -1, 3, "r_KER", methodObject),
50     new Among("belajar", 0, 4),
51     new Among("ber", 0, 3),
52     new Among("pe", -1, 1),
53     new Among("pelajar", 3, 2),
54     new Among("per", 3, 1)
55   };
56 
57   private static final char g_vowel[] = {17, 65, 16};
58 
59   private int I_prefix;
60   private int I_measure;
61 
r_remove_particle()62   private boolean r_remove_particle() {
63     ket = cursor;
64     if (find_among_b(a_0) == 0) {
65       return false;
66     }
67     bra = cursor;
68     slice_del();
69     I_measure -= 1;
70     return true;
71   }
72 
r_remove_possessive_pronoun()73   private boolean r_remove_possessive_pronoun() {
74     ket = cursor;
75     if (find_among_b(a_1) == 0) {
76       return false;
77     }
78     bra = cursor;
79     slice_del();
80     I_measure -= 1;
81     return true;
82   }
83 
r_SUFFIX_KAN_OK()84   public boolean r_SUFFIX_KAN_OK() {
85     if (!(I_prefix != 3)) {
86       return false;
87     }
88     if (!(I_prefix != 2)) {
89       return false;
90     }
91     return true;
92   }
93 
r_SUFFIX_AN_OK()94   public boolean r_SUFFIX_AN_OK() {
95     if (!(I_prefix != 1)) {
96       return false;
97     }
98     return true;
99   }
100 
r_SUFFIX_I_OK()101   public boolean r_SUFFIX_I_OK() {
102     if (!(I_prefix <= 2)) {
103       return false;
104     }
105     {
106       int v_1 = limit - cursor;
107       lab0:
108       {
109         if (!(eq_s_b("s"))) {
110           break lab0;
111         }
112         return false;
113       }
114       cursor = limit - v_1;
115     }
116     return true;
117   }
118 
r_remove_suffix()119   private boolean r_remove_suffix() {
120     ket = cursor;
121     if (find_among_b(a_2) == 0) {
122       return false;
123     }
124     bra = cursor;
125     slice_del();
126     I_measure -= 1;
127     return true;
128   }
129 
r_VOWEL()130   public boolean r_VOWEL() {
131     if (!(in_grouping(g_vowel, 97, 117))) {
132       return false;
133     }
134     return true;
135   }
136 
r_KER()137   public boolean r_KER() {
138     if (!(out_grouping(g_vowel, 97, 117))) {
139       return false;
140     }
141     if (!(eq_s("er"))) {
142       return false;
143     }
144     return true;
145   }
146 
r_remove_first_order_prefix()147   private boolean r_remove_first_order_prefix() {
148     int among_var;
149     bra = cursor;
150     among_var = find_among(a_3);
151     if (among_var == 0) {
152       return false;
153     }
154     ket = cursor;
155     switch (among_var) {
156       case 1:
157         slice_del();
158         I_prefix = 1;
159         I_measure -= 1;
160         break;
161       case 2:
162         slice_del();
163         I_prefix = 3;
164         I_measure -= 1;
165         break;
166       case 3:
167         I_prefix = 1;
168         slice_from("s");
169         I_measure -= 1;
170         break;
171       case 4:
172         I_prefix = 3;
173         slice_from("s");
174         I_measure -= 1;
175         break;
176       case 5:
177         I_prefix = 1;
178         I_measure -= 1;
179         lab0:
180         {
181           int v_1 = cursor;
182           lab1:
183           {
184             int v_2 = cursor;
185             if (!(in_grouping(g_vowel, 97, 117))) {
186               break lab1;
187             }
188             cursor = v_2;
189             slice_from("p");
190             break lab0;
191           }
192           cursor = v_1;
193           slice_del();
194         }
195         break;
196       case 6:
197         I_prefix = 3;
198         I_measure -= 1;
199         lab2:
200         {
201           int v_3 = cursor;
202           lab3:
203           {
204             int v_4 = cursor;
205             if (!(in_grouping(g_vowel, 97, 117))) {
206               break lab3;
207             }
208             cursor = v_4;
209             slice_from("p");
210             break lab2;
211           }
212           cursor = v_3;
213           slice_del();
214         }
215         break;
216     }
217     return true;
218   }
219 
r_remove_second_order_prefix()220   private boolean r_remove_second_order_prefix() {
221     int among_var;
222     bra = cursor;
223     among_var = find_among(a_4);
224     if (among_var == 0) {
225       return false;
226     }
227     ket = cursor;
228     switch (among_var) {
229       case 1:
230         slice_del();
231         I_prefix = 2;
232         I_measure -= 1;
233         break;
234       case 2:
235         slice_from("ajar");
236         I_measure -= 1;
237         break;
238       case 3:
239         slice_del();
240         I_prefix = 4;
241         I_measure -= 1;
242         break;
243       case 4:
244         slice_from("ajar");
245         I_prefix = 4;
246         I_measure -= 1;
247         break;
248     }
249     return true;
250   }
251 
252   @Override
stem()253   public boolean stem() {
254     I_measure = 0;
255     int v_1 = cursor;
256     lab0:
257     {
258       while (true) {
259         int v_2 = cursor;
260         lab1:
261         {
262           golab2:
263           while (true) {
264             lab3:
265             {
266               if (!(in_grouping(g_vowel, 97, 117))) {
267                 break lab3;
268               }
269               break golab2;
270             }
271             if (cursor >= limit) {
272               break lab1;
273             }
274             cursor++;
275           }
276           I_measure += 1;
277           continue;
278         }
279         cursor = v_2;
280         break;
281       }
282     }
283     cursor = v_1;
284     if (!(I_measure > 2)) {
285       return false;
286     }
287     I_prefix = 0;
288     limit_backward = cursor;
289     cursor = limit;
290     int v_4 = limit - cursor;
291     r_remove_particle();
292     cursor = limit - v_4;
293     if (!(I_measure > 2)) {
294       return false;
295     }
296     int v_5 = limit - cursor;
297     r_remove_possessive_pronoun();
298     cursor = limit - v_5;
299     cursor = limit_backward;
300     if (!(I_measure > 2)) {
301       return false;
302     }
303     lab4:
304     {
305       int v_6 = cursor;
306       lab5:
307       {
308         int v_7 = cursor;
309         if (!r_remove_first_order_prefix()) {
310           break lab5;
311         }
312         int v_8 = cursor;
313         lab6:
314         {
315           int v_9 = cursor;
316           if (!(I_measure > 2)) {
317             break lab6;
318           }
319           limit_backward = cursor;
320           cursor = limit;
321           if (!r_remove_suffix()) {
322             break lab6;
323           }
324           cursor = limit_backward;
325           cursor = v_9;
326           if (!(I_measure > 2)) {
327             break lab6;
328           }
329           if (!r_remove_second_order_prefix()) {
330             break lab6;
331           }
332         }
333         cursor = v_8;
334         cursor = v_7;
335         break lab4;
336       }
337       cursor = v_6;
338       int v_10 = cursor;
339       r_remove_second_order_prefix();
340       cursor = v_10;
341       int v_11 = cursor;
342       lab7:
343       {
344         if (!(I_measure > 2)) {
345           break lab7;
346         }
347         limit_backward = cursor;
348         cursor = limit;
349         if (!r_remove_suffix()) {
350           break lab7;
351         }
352         cursor = limit_backward;
353       }
354       cursor = v_11;
355     }
356     return true;
357   }
358 
359   @Override
equals(Object o)360   public boolean equals(Object o) {
361     return o instanceof IndonesianStemmer;
362   }
363 
364   @Override
hashCode()365   public int hashCode() {
366     return IndonesianStemmer.class.getName().hashCode();
367   }
368 }
369