xref: /Lucene/lucene/analysis/common/src/java/org/tartarus/snowball/ext/GermanStemmer.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 GermanStemmer 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("", -1, 5),
21     new Among("U", 0, 2),
22     new Among("Y", 0, 1),
23     new Among("\u00E4", 0, 3),
24     new Among("\u00F6", 0, 4),
25     new Among("\u00FC", 0, 2)
26   };
27 
28   private static final Among a_1[] = {
29     new Among("e", -1, 2),
30     new Among("em", -1, 1),
31     new Among("en", -1, 2),
32     new Among("ern", -1, 1),
33     new Among("er", -1, 1),
34     new Among("s", -1, 3),
35     new Among("es", 5, 2)
36   };
37 
38   private static final Among a_2[] = {
39     new Among("en", -1, 1), new Among("er", -1, 1), new Among("st", -1, 2), new Among("est", 2, 1)
40   };
41 
42   private static final Among a_3[] = {new Among("ig", -1, 1), new Among("lich", -1, 1)};
43 
44   private static final Among a_4[] = {
45     new Among("end", -1, 1),
46     new Among("ig", -1, 2),
47     new Among("ung", -1, 1),
48     new Among("lich", -1, 3),
49     new Among("isch", -1, 2),
50     new Among("ik", -1, 2),
51     new Among("heit", -1, 3),
52     new Among("keit", -1, 4)
53   };
54 
55   private static final char g_v[] = {
56     17, 65, 16, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 32, 8
57   };
58 
59   private static final char g_s_ending[] = {117, 30, 5};
60 
61   private static final char g_st_ending[] = {117, 30, 4};
62 
63   private int I_x;
64   private int I_p2;
65   private int I_p1;
66 
r_prelude()67   private boolean r_prelude() {
68     int v_1 = cursor;
69     while (true) {
70       int v_2 = cursor;
71       lab0:
72       {
73         lab1:
74         {
75           int v_3 = cursor;
76           lab2:
77           {
78             bra = cursor;
79             if (!(eq_s("\u00DF"))) {
80               break lab2;
81             }
82             ket = cursor;
83             slice_from("ss");
84             break lab1;
85           }
86           cursor = v_3;
87           if (cursor >= limit) {
88             break lab0;
89           }
90           cursor++;
91         }
92         continue;
93       }
94       cursor = v_2;
95       break;
96     }
97     cursor = v_1;
98     while (true) {
99       int v_4 = cursor;
100       lab3:
101       {
102         golab4:
103         while (true) {
104           int v_5 = cursor;
105           lab5:
106           {
107             if (!(in_grouping(g_v, 97, 252))) {
108               break lab5;
109             }
110             bra = cursor;
111             lab6:
112             {
113               int v_6 = cursor;
114               lab7:
115               {
116                 if (!(eq_s("u"))) {
117                   break lab7;
118                 }
119                 ket = cursor;
120                 if (!(in_grouping(g_v, 97, 252))) {
121                   break lab7;
122                 }
123                 slice_from("U");
124                 break lab6;
125               }
126               cursor = v_6;
127               if (!(eq_s("y"))) {
128                 break lab5;
129               }
130               ket = cursor;
131               if (!(in_grouping(g_v, 97, 252))) {
132                 break lab5;
133               }
134               slice_from("Y");
135             }
136             cursor = v_5;
137             break golab4;
138           }
139           cursor = v_5;
140           if (cursor >= limit) {
141             break lab3;
142           }
143           cursor++;
144         }
145         continue;
146       }
147       cursor = v_4;
148       break;
149     }
150     return true;
151   }
152 
r_mark_regions()153   private boolean r_mark_regions() {
154     I_p1 = limit;
155     I_p2 = limit;
156     int v_1 = cursor;
157     {
158       int c = cursor + 3;
159       if (0 > c || c > limit) {
160         return false;
161       }
162       cursor = c;
163     }
164     I_x = cursor;
165     cursor = v_1;
166     golab0:
167     while (true) {
168       lab1:
169       {
170         if (!(in_grouping(g_v, 97, 252))) {
171           break lab1;
172         }
173         break golab0;
174       }
175       if (cursor >= limit) {
176         return false;
177       }
178       cursor++;
179     }
180     golab2:
181     while (true) {
182       lab3:
183       {
184         if (!(out_grouping(g_v, 97, 252))) {
185           break lab3;
186         }
187         break golab2;
188       }
189       if (cursor >= limit) {
190         return false;
191       }
192       cursor++;
193     }
194     I_p1 = cursor;
195     lab4:
196     {
197       if (!(I_p1 < I_x)) {
198         break lab4;
199       }
200       I_p1 = I_x;
201     }
202     golab5:
203     while (true) {
204       lab6:
205       {
206         if (!(in_grouping(g_v, 97, 252))) {
207           break lab6;
208         }
209         break golab5;
210       }
211       if (cursor >= limit) {
212         return false;
213       }
214       cursor++;
215     }
216     golab7:
217     while (true) {
218       lab8:
219       {
220         if (!(out_grouping(g_v, 97, 252))) {
221           break lab8;
222         }
223         break golab7;
224       }
225       if (cursor >= limit) {
226         return false;
227       }
228       cursor++;
229     }
230     I_p2 = cursor;
231     return true;
232   }
233 
r_postlude()234   private boolean r_postlude() {
235     int among_var;
236     while (true) {
237       int v_1 = cursor;
238       lab0:
239       {
240         bra = cursor;
241         among_var = find_among(a_0);
242         if (among_var == 0) {
243           break lab0;
244         }
245         ket = cursor;
246         switch (among_var) {
247           case 1:
248             slice_from("y");
249             break;
250           case 2:
251             slice_from("u");
252             break;
253           case 3:
254             slice_from("a");
255             break;
256           case 4:
257             slice_from("o");
258             break;
259           case 5:
260             if (cursor >= limit) {
261               break lab0;
262             }
263             cursor++;
264             break;
265         }
266         continue;
267       }
268       cursor = v_1;
269       break;
270     }
271     return true;
272   }
273 
r_R1()274   private boolean r_R1() {
275     if (!(I_p1 <= cursor)) {
276       return false;
277     }
278     return true;
279   }
280 
r_R2()281   private boolean r_R2() {
282     if (!(I_p2 <= cursor)) {
283       return false;
284     }
285     return true;
286   }
287 
r_standard_suffix()288   private boolean r_standard_suffix() {
289     int among_var;
290     int v_1 = limit - cursor;
291     lab0:
292     {
293       ket = cursor;
294       among_var = find_among_b(a_1);
295       if (among_var == 0) {
296         break lab0;
297       }
298       bra = cursor;
299       if (!r_R1()) {
300         break lab0;
301       }
302       switch (among_var) {
303         case 1:
304           slice_del();
305           break;
306         case 2:
307           slice_del();
308           int v_2 = limit - cursor;
309           lab1:
310           {
311             ket = cursor;
312             if (!(eq_s_b("s"))) {
313               cursor = limit - v_2;
314               break lab1;
315             }
316             bra = cursor;
317             if (!(eq_s_b("nis"))) {
318               cursor = limit - v_2;
319               break lab1;
320             }
321             slice_del();
322           }
323           break;
324         case 3:
325           if (!(in_grouping_b(g_s_ending, 98, 116))) {
326             break lab0;
327           }
328           slice_del();
329           break;
330       }
331     }
332     cursor = limit - v_1;
333     int v_3 = limit - cursor;
334     lab2:
335     {
336       ket = cursor;
337       among_var = find_among_b(a_2);
338       if (among_var == 0) {
339         break lab2;
340       }
341       bra = cursor;
342       if (!r_R1()) {
343         break lab2;
344       }
345       switch (among_var) {
346         case 1:
347           slice_del();
348           break;
349         case 2:
350           if (!(in_grouping_b(g_st_ending, 98, 116))) {
351             break lab2;
352           }
353           {
354             int c = cursor - 3;
355             if (limit_backward > c || c > limit) {
356               break lab2;
357             }
358             cursor = c;
359           }
360           slice_del();
361           break;
362       }
363     }
364     cursor = limit - v_3;
365     int v_4 = limit - cursor;
366     lab3:
367     {
368       ket = cursor;
369       among_var = find_among_b(a_4);
370       if (among_var == 0) {
371         break lab3;
372       }
373       bra = cursor;
374       if (!r_R2()) {
375         break lab3;
376       }
377       switch (among_var) {
378         case 1:
379           slice_del();
380           int v_5 = limit - cursor;
381           lab4:
382           {
383             ket = cursor;
384             if (!(eq_s_b("ig"))) {
385               cursor = limit - v_5;
386               break lab4;
387             }
388             bra = cursor;
389             {
390               int v_6 = limit - cursor;
391               lab5:
392               {
393                 if (!(eq_s_b("e"))) {
394                   break lab5;
395                 }
396                 cursor = limit - v_5;
397                 break lab4;
398               }
399               cursor = limit - v_6;
400             }
401             if (!r_R2()) {
402               cursor = limit - v_5;
403               break lab4;
404             }
405             slice_del();
406           }
407           break;
408         case 2:
409           {
410             int v_7 = limit - cursor;
411             lab6:
412             {
413               if (!(eq_s_b("e"))) {
414                 break lab6;
415               }
416               break lab3;
417             }
418             cursor = limit - v_7;
419           }
420           slice_del();
421           break;
422         case 3:
423           slice_del();
424           int v_8 = limit - cursor;
425           lab7:
426           {
427             ket = cursor;
428             lab8:
429             {
430               int v_9 = limit - cursor;
431               lab9:
432               {
433                 if (!(eq_s_b("er"))) {
434                   break lab9;
435                 }
436                 break lab8;
437               }
438               cursor = limit - v_9;
439               if (!(eq_s_b("en"))) {
440                 cursor = limit - v_8;
441                 break lab7;
442               }
443             }
444             bra = cursor;
445             if (!r_R1()) {
446               cursor = limit - v_8;
447               break lab7;
448             }
449             slice_del();
450           }
451           break;
452         case 4:
453           slice_del();
454           int v_10 = limit - cursor;
455           lab10:
456           {
457             ket = cursor;
458             if (find_among_b(a_3) == 0) {
459               cursor = limit - v_10;
460               break lab10;
461             }
462             bra = cursor;
463             if (!r_R2()) {
464               cursor = limit - v_10;
465               break lab10;
466             }
467             slice_del();
468           }
469           break;
470       }
471     }
472     cursor = limit - v_4;
473     return true;
474   }
475 
476   @Override
stem()477   public boolean stem() {
478     int v_1 = cursor;
479     r_prelude();
480     cursor = v_1;
481     int v_2 = cursor;
482     r_mark_regions();
483     cursor = v_2;
484     limit_backward = cursor;
485     cursor = limit;
486     r_standard_suffix();
487     cursor = limit_backward;
488     int v_4 = cursor;
489     r_postlude();
490     cursor = v_4;
491     return true;
492   }
493 
494   @Override
equals(Object o)495   public boolean equals(Object o) {
496     return o instanceof GermanStemmer;
497   }
498 
499   @Override
hashCode()500   public int hashCode() {
501     return GermanStemmer.class.getName().hashCode();
502   }
503 }
504