Lucene.Net  3.0.3
Lucene.Net is a .NET port of the Java Lucene Indexing Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties
DanishStemmer.cs
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 // This file was generated automatically by the Snowball to Java compiler
19 using System;
20 using Among = SF.Snowball.Among;
21 using SnowballProgram = SF.Snowball.SnowballProgram;
22 namespace SF.Snowball.Ext
23 {
24 #pragma warning disable 162,164
25 
28  {
29  public DanishStemmer()
30  {
31  InitBlock();
32  }
33  private void InitBlock()
34  {
35  a_0 = new Among[] { new Among("hed", -1, 1, "", this), new Among("ethed", 0, 1, "", this), new Among("ered", -1, 1, "", this), new Among("e", -1, 1, "", this), new Among("erede", 3, 1, "", this), new Among("ende", 3, 1, "", this), new Among("erende", 5, 1, "", this), new Among("ene", 3, 1, "", this), new Among("erne", 3, 1, "", this), new Among("ere", 3, 1, "", this), new Among("en", -1, 1, "", this), new Among("heden", 10, 1, "", this), new Among("eren", 10, 1, "", this), new Among("er", -1, 1, "", this), new Among("heder", 13, 1, "", this), new Among("erer", 13, 1, "", this), new Among("s", -1, 2, "", this), new Among("heds", 16, 1, "", this), new Among("es", 16, 1, "", this), new Among("endes", 18, 1, "", this), new Among("erendes", 19, 1, "", this), new Among("enes", 18, 1, "", this), new Among("ernes", 18, 1, "", this), new Among("eres", 18, 1, "", this), new Among("ens", 16, 1, "", this), new Among("hedens", 24, 1, "", this), new Among("erens", 24, 1, "", this), new Among("ers", 16, 1, "", this), new Among("ets", 16, 1, "", this), new Among("erets", 28, 1, "", this), new Among("et", -1, 1, "", this), new Among("eret", 30, 1, "", this) };
36  a_1 = new Among[]{new Among("gd", - 1, - 1, "", this), new Among("dt", - 1, - 1, "", this), new Among("gt", - 1, - 1, "", this), new Among("kt", - 1, - 1, "", this)};
37  a_2 = new Among[]{new Among("ig", - 1, 1, "", this), new Among("lig", 0, 1, "", this), new Among("elig", 1, 1, "", this), new Among("els", - 1, 1, "", this), new Among("l\u00F8st", - 1, 2, "", this)};
38  }
39 
40  private Among[] a_0;
41 
42  private Among[] a_1;
43  private Among[] a_2;
44  private static readonly char[] g_v = new char[]{(char) (17), (char) (65), (char) (16), (char) (1), (char) (0), (char) (0), (char) (0), (char) (0), (char) (0), (char) (0), (char) (0), (char) (0), (char) (0), (char) (0), (char) (0), (char) (0), (char) (48), (char) (0), (char) (128)};
45  private static readonly char[] g_s_ending = new char[]{(char) (239), (char) (254), (char) (42), (char) (3), (char) (0), (char) (0), (char) (0), (char) (0), (char) (0), (char) (0), (char) (0), (char) (0), (char) (0), (char) (0), (char) (0), (char) (0), (char) (16)};
46 
47  private int I_p1;
48  private System.Text.StringBuilder S_ch = new System.Text.StringBuilder();
49 
50  protected internal virtual void copy_from(DanishStemmer other)
51  {
52  I_p1 = other.I_p1;
53  S_ch = other.S_ch;
54  base.copy_from(other);
55  }
56 
57  private bool r_mark_regions()
58  {
59  int v_1;
60  // (, line 29
61  I_p1 = limit;
62  // goto, line 33
63  while (true)
64  {
65  v_1 = cursor;
66  do
67  {
68  if (!(in_grouping(g_v, 97, 248)))
69  {
70  goto lab1_brk;
71  }
72  cursor = v_1;
73  goto golab0_brk;
74  }
75  while (false);
76 
77 lab1_brk: ;
78 
79  cursor = v_1;
80  if (cursor >= limit)
81  {
82  return false;
83  }
84  cursor++;
85  }
86 
87 golab0_brk: ;
88 
89  // gopast, line 33
90  while (true)
91  {
92  do
93  {
94  if (!(out_grouping(g_v, 97, 248)))
95  {
96  goto lab3_brk;
97  }
98  goto golab2_brk;
99  }
100  while (false);
101 
102 lab3_brk: ;
103 
104  if (cursor >= limit)
105  {
106  return false;
107  }
108  cursor++;
109  }
110 
111 golab2_brk: ;
112 
113  // setmark p1, line 33
114  I_p1 = cursor;
115  // try, line 34
116  do
117  {
118  // (, line 34
119  if (!(I_p1 < 3))
120  {
121  goto lab4_brk;
122  }
123  I_p1 = 3;
124  }
125  while (false);
126 
127 lab4_brk: ;
128 
129  return true;
130  }
131 
132  private bool r_main_suffix()
133  {
134  int among_var;
135  int v_1;
136  int v_2;
137  // (, line 39
138  // setlimit, line 40
139  v_1 = limit - cursor;
140  // tomark, line 40
141  if (cursor < I_p1)
142  {
143  return false;
144  }
145  cursor = I_p1;
146  v_2 = limit_backward;
147  limit_backward = cursor;
148  cursor = limit - v_1;
149  // (, line 40
150  // [, line 40
151  ket = cursor;
152  // substring, line 40
153  among_var = find_among_b(a_0, 32);
154  if (among_var == 0)
155  {
156  limit_backward = v_2;
157  return false;
158  }
159  // ], line 40
160  bra = cursor;
161  limit_backward = v_2;
162  switch (among_var)
163  {
164 
165  case 0:
166  return false;
167 
168  case 1:
169  // (, line 47
170  // delete, line 47
171  slice_del();
172  break;
173 
174  case 2:
175  // (, line 49
176  if (!(in_grouping_b(g_s_ending, 97, 229)))
177  {
178  return false;
179  }
180  // delete, line 49
181  slice_del();
182  break;
183  }
184  return true;
185  }
186 
187  private bool r_consonant_pair()
188  {
189  int v_1;
190  int v_2;
191  int v_3;
192  // (, line 53
193  // test, line 54
194  v_1 = limit - cursor;
195  // (, line 54
196  // setlimit, line 55
197  v_2 = limit - cursor;
198  // tomark, line 55
199  if (cursor < I_p1)
200  {
201  return false;
202  }
203  cursor = I_p1;
204  v_3 = limit_backward;
205  limit_backward = cursor;
206  cursor = limit - v_2;
207  // (, line 55
208  // [, line 55
209  ket = cursor;
210  // substring, line 55
211  if (find_among_b(a_1, 4) == 0)
212  {
213  limit_backward = v_3;
214  return false;
215  }
216  // ], line 55
217  bra = cursor;
218  limit_backward = v_3;
219  cursor = limit - v_1;
220  // next, line 61
221  if (cursor <= limit_backward)
222  {
223  return false;
224  }
225  cursor--;
226  // ], line 61
227  bra = cursor;
228  // delete, line 61
229  slice_del();
230  return true;
231  }
232 
233  private bool r_other_suffix()
234  {
235  int among_var;
236  int v_1;
237  int v_2;
238  int v_3;
239  int v_4;
240  // (, line 64
241  // do, line 65
242  v_1 = limit - cursor;
243  do
244  {
245  // (, line 65
246  // [, line 65
247  ket = cursor;
248  // literal, line 65
249  if (!(eq_s_b(2, "st")))
250  {
251  goto lab0_brk;
252  }
253  // ], line 65
254  bra = cursor;
255  // literal, line 65
256  if (!(eq_s_b(2, "ig")))
257  {
258  goto lab0_brk;
259  }
260  // delete, line 65
261  slice_del();
262  }
263  while (false);
264 
265 lab0_brk: ;
266 
267  cursor = limit - v_1;
268  // setlimit, line 66
269  v_2 = limit - cursor;
270  // tomark, line 66
271  if (cursor < I_p1)
272  {
273  return false;
274  }
275  cursor = I_p1;
276  v_3 = limit_backward;
277  limit_backward = cursor;
278  cursor = limit - v_2;
279  // (, line 66
280  // [, line 66
281  ket = cursor;
282  // substring, line 66
283  among_var = find_among_b(a_2, 5);
284  if (among_var == 0)
285  {
286  limit_backward = v_3;
287  return false;
288  }
289  // ], line 66
290  bra = cursor;
291  limit_backward = v_3;
292  switch (among_var)
293  {
294 
295  case 0:
296  return false;
297 
298  case 1:
299  // (, line 69
300  // delete, line 69
301  slice_del();
302  // do, line 69
303  v_4 = limit - cursor;
304  do
305  {
306  // call consonant_pair, line 69
307  if (!r_consonant_pair())
308  {
309  goto lab1_brk;
310  }
311  }
312  while (false);
313 
314 lab1_brk: ;
315 
316  cursor = limit - v_4;
317  break;
318 
319  case 2:
320  // (, line 71
321  // <-, line 71
322  slice_from("l\u00F8s");
323  break;
324  }
325  return true;
326  }
327 
328  private bool r_undouble()
329  {
330  int v_1;
331  int v_2;
332  // (, line 74
333  // setlimit, line 75
334  v_1 = limit - cursor;
335  // tomark, line 75
336  if (cursor < I_p1)
337  {
338  return false;
339  }
340  cursor = I_p1;
341  v_2 = limit_backward;
342  limit_backward = cursor;
343  cursor = limit - v_1;
344  // (, line 75
345  // [, line 75
346  ket = cursor;
347  if (!(out_grouping_b(g_v, 97, 248)))
348  {
349  limit_backward = v_2;
350  return false;
351  }
352  // ], line 75
353  bra = cursor;
354  // -> ch, line 75
355  S_ch = slice_to(S_ch);
356  limit_backward = v_2;
357  // name ch, line 76
358  if (!(eq_v_b(S_ch)))
359  {
360  return false;
361  }
362  // delete, line 77
363  slice_del();
364  return true;
365  }
366 
367  public override bool Stem()
368  {
369  int v_1;
370  int v_2;
371  int v_3;
372  int v_4;
373  int v_5;
374  // (, line 81
375  // do, line 83
376  v_1 = cursor;
377  do
378  {
379  // call mark_regions, line 83
380  if (!r_mark_regions())
381  {
382  goto lab0_brk;
383  }
384  }
385  while (false);
386 
387 lab0_brk: ;
388 
389  cursor = v_1;
390  // backwards, line 84
391  limit_backward = cursor; cursor = limit;
392  // (, line 84
393  // do, line 85
394  v_2 = limit - cursor;
395  do
396  {
397  // call main_suffix, line 85
398  if (!r_main_suffix())
399  {
400  goto lab1_brk;
401  }
402  }
403  while (false);
404 
405 lab1_brk: ;
406 
407  cursor = limit - v_2;
408  // do, line 86
409  v_3 = limit - cursor;
410  do
411  {
412  // call consonant_pair, line 86
413  if (!r_consonant_pair())
414  {
415  goto lab2_brk;
416  }
417  }
418  while (false);
419 
420 lab2_brk: ;
421 
422  cursor = limit - v_3;
423  // do, line 87
424  v_4 = limit - cursor;
425  do
426  {
427  // call other_suffix, line 87
428  if (!r_other_suffix())
429  {
430  goto lab3_brk;
431  }
432  }
433  while (false);
434 
435 lab3_brk: ;
436 
437  cursor = limit - v_4;
438  // do, line 88
439  v_5 = limit - cursor;
440  do
441  {
442  // call undouble, line 88
443  if (!r_undouble())
444  {
445  goto lab4_brk;
446  }
447  }
448  while (false);
449 
450 lab4_brk: ;
451 
452  cursor = limit - v_5;
453  cursor = limit_backward; return true;
454  }
455  }
456 }