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