Lucene.Net  3.0.3
Lucene.Net is a port of the Lucene search engine library, written in C# and targeted at .NET runtime users.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Pages
NorwegianStemmer.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 
26  /// <summary> Generated class implementing code defined by a snowball script.</summary>
28  {
30  {
31  InitBlock();
32  }
33  private void InitBlock()
34  {
35  a_0 = new Among[]{new Among("a", - 1, 1, "", this), new Among("e", - 1, 1, "", this), new Among("ede", 1, 1, "", this), new Among("ande", 1, 1, "", this), new Among("ende", 1, 1, "", this), new Among("ane", 1, 1, "", this), new Among("ene", 1, 1, "", this), new Among("hetene", 6, 1, "", this), new Among("erte", 1, 3, "", this), new Among("en", - 1, 1, "", this), new Among("heten", 9, 1, "", this), new Among("ar", - 1, 1, "", this), new Among("er", - 1, 1, "", this), new Among("heter", 12, 1, "", this), new Among("s", - 1, 2, "", this), new Among("as", 14, 1, "", this), new Among("es", 14, 1, "", this), new Among("edes", 16, 1, "", this), new Among("endes", 16, 1, "", this), new Among("enes", 16, 1, "", this), new Among("hetenes", 19, 1, "", this), new Among("ens", 14, 1, "", this), new Among("hetens", 21, 1, "", this), new Among("ers", 14, 1, "", this), new Among("ets", 14, 1, "", this), new Among("et", - 1, 1, "", this), new Among("het", 25, 1, "", this), new Among("ert", - 1, 3, "", this), new Among("ast", - 1, 1, "", this)};
36  a_1 = new Among[]{new Among("dt", - 1, - 1, "", this), new Among("vt", - 1, - 1, "", this)};
37  a_2 = new Among[]{new Among("leg", - 1, 1, "", this), new Among("eleg", 0, 1, "", this), new Among("ig", - 1, 1, "", this), new Among("eig", 2, 1, "", this), new Among("lig", 2, 1, "", this), new Among("elig", 4, 1, "", this), new Among("els", - 1, 1, "", this), new Among("lov", - 1, 1, "", this), new Among("elov", 7, 1, "", this), new Among("slov", 7, 1, "", this), new Among("hetslov", 9, 1, "", this)};
38  }
39 
40  private Among[] a_0;
41  private Among[] a_1;
42  private Among[] a_2;
43  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)};
44  private static readonly char[] g_s_ending = new char[]{(char) (119), (char) (127), (char) (149), (char) (1)};
45 
46  private int I_p1;
47 
48  protected internal virtual void copy_from(NorwegianStemmer other)
49  {
50  I_p1 = other.I_p1;
51  base.copy_from(other);
52  }
53 
54  private bool r_mark_regions()
55  {
56  int v_1;
57  // (, line 26
58  I_p1 = limit;
59  // goto, line 30
60  while (true)
61  {
62  v_1 = cursor;
63  do
64  {
65  if (!(in_grouping(g_v, 97, 248)))
66  {
67  goto lab1_brk;
68  }
69  cursor = v_1;
70  goto golab0_brk;
71  }
72  while (false);
73 
74 lab1_brk: ;
75 
76  cursor = v_1;
77  if (cursor >= limit)
78  {
79  return false;
80  }
81  cursor++;
82  }
83 
84 golab0_brk: ;
85 
86  // gopast, line 30
87  while (true)
88  {
89  do
90  {
91  if (!(out_grouping(g_v, 97, 248)))
92  {
93  goto lab3_brk;
94  }
95  goto golab2_brk;
96  }
97  while (false);
98 
99 lab3_brk: ;
100 
101  if (cursor >= limit)
102  {
103  return false;
104  }
105  cursor++;
106  }
107 
108 golab2_brk: ;
109 
110  // setmark p1, line 30
111  I_p1 = cursor;
112  // try, line 31
113  do
114  {
115  // (, line 31
116  if (!(I_p1 < 3))
117  {
118  goto lab4_brk;
119  }
120  I_p1 = 3;
121  }
122  while (false);
123 
124 lab4_brk: ;
125 
126  return true;
127  }
128 
129  private bool r_main_suffix()
130  {
131  int among_var;
132  int v_1;
133  int v_2;
134  // (, line 36
135  // setlimit, line 37
136  v_1 = limit - cursor;
137  // tomark, line 37
138  if (cursor < I_p1)
139  {
140  return false;
141  }
142  cursor = I_p1;
143  v_2 = limit_backward;
144  limit_backward = cursor;
145  cursor = limit - v_1;
146  // (, line 37
147  // [, line 37
148  ket = cursor;
149  // substring, line 37
150  among_var = find_among_b(a_0, 29);
151  if (among_var == 0)
152  {
153  limit_backward = v_2;
154  return false;
155  }
156  // ], line 37
157  bra = cursor;
158  limit_backward = v_2;
159  switch (among_var)
160  {
161 
162  case 0:
163  return false;
164 
165  case 1:
166  // (, line 43
167  // delete, line 43
168  slice_del();
169  break;
170 
171  case 2:
172  // (, line 45
173  if (!(in_grouping_b(g_s_ending, 98, 122)))
174  {
175  return false;
176  }
177  // delete, line 45
178  slice_del();
179  break;
180 
181  case 3:
182  // (, line 47
183  // <-, line 47
184  slice_from("er");
185  break;
186  }
187  return true;
188  }
189 
190  private bool r_consonant_pair()
191  {
192  int v_1;
193  int v_2;
194  int v_3;
195  // (, line 51
196  // test, line 52
197  v_1 = limit - cursor;
198  // (, line 52
199  // setlimit, line 53
200  v_2 = limit - cursor;
201  // tomark, line 53
202  if (cursor < I_p1)
203  {
204  return false;
205  }
206  cursor = I_p1;
207  v_3 = limit_backward;
208  limit_backward = cursor;
209  cursor = limit - v_2;
210  // (, line 53
211  // [, line 53
212  ket = cursor;
213  // substring, line 53
214  if (find_among_b(a_1, 2) == 0)
215  {
216  limit_backward = v_3;
217  return false;
218  }
219  // ], line 53
220  bra = cursor;
221  limit_backward = v_3;
222  cursor = limit - v_1;
223  // next, line 58
224  if (cursor <= limit_backward)
225  {
226  return false;
227  }
228  cursor--;
229  // ], line 58
230  bra = cursor;
231  // delete, line 58
232  slice_del();
233  return true;
234  }
235 
236  private bool r_other_suffix()
237  {
238  int among_var;
239  int v_1;
240  int v_2;
241  // (, line 61
242  // setlimit, line 62
243  v_1 = limit - cursor;
244  // tomark, line 62
245  if (cursor < I_p1)
246  {
247  return false;
248  }
249  cursor = I_p1;
250  v_2 = limit_backward;
251  limit_backward = cursor;
252  cursor = limit - v_1;
253  // (, line 62
254  // [, line 62
255  ket = cursor;
256  // substring, line 62
257  among_var = find_among_b(a_2, 11);
258  if (among_var == 0)
259  {
260  limit_backward = v_2;
261  return false;
262  }
263  // ], line 62
264  bra = cursor;
265  limit_backward = v_2;
266  switch (among_var)
267  {
268 
269  case 0:
270  return false;
271 
272  case 1:
273  // (, line 66
274  // delete, line 66
275  slice_del();
276  break;
277  }
278  return true;
279  }
280 
281  public override bool Stem()
282  {
283  int v_1;
284  int v_2;
285  int v_3;
286  int v_4;
287  // (, line 71
288  // do, line 73
289  v_1 = cursor;
290  do
291  {
292  // call mark_regions, line 73
293  if (!r_mark_regions())
294  {
295  goto lab0_brk;
296  }
297  }
298  while (false);
299 
300 lab0_brk: ;
301 
302  cursor = v_1;
303  // backwards, line 74
304  limit_backward = cursor; cursor = limit;
305  // (, line 74
306  // do, line 75
307  v_2 = limit - cursor;
308  do
309  {
310  // call main_suffix, line 75
311  if (!r_main_suffix())
312  {
313  goto lab1_brk;
314  }
315  }
316  while (false);
317 
318 lab1_brk: ;
319 
320  cursor = limit - v_2;
321  // do, line 76
322  v_3 = limit - cursor;
323  do
324  {
325  // call consonant_pair, line 76
326  if (!r_consonant_pair())
327  {
328  goto lab2_brk;
329  }
330  }
331  while (false);
332 
333 lab2_brk: ;
334 
335  cursor = limit - v_3;
336  // do, line 77
337  v_4 = limit - cursor;
338  do
339  {
340  // call other_suffix, line 77
341  if (!r_other_suffix())
342  {
343  goto lab3_brk;
344  }
345  }
346  while (false);
347 
348 lab3_brk: ;
349 
350  cursor = limit - v_4;
351  cursor = limit_backward; return true;
352  }
353  }
354 }