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
SwedishStemmer.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  {
29  public SwedishStemmer()
30  {
31  InitBlock();
32  }
33  private void InitBlock()
34  {
35  a_0 = new Among[]{new Among("a", - 1, 1, "", this), new Among("arna", 0, 1, "", this), new Among("erna", 0, 1, "", this), new Among("heterna", 2, 1, "", this), new Among("orna", 0, 1, "", this), new Among("ad", - 1, 1, "", this), new Among("e", - 1, 1, "", this), new Among("ade", 6, 1, "", this), new Among("ande", 6, 1, "", this), new Among("arne", 6, 1, "", this), new Among("are", 6, 1, "", this), new Among("aste", 6, 1, "", this), new Among("en", - 1, 1, "", this), new Among("anden", 12, 1, "", this), new Among("aren", 12, 1, "", this), new Among("heten", 12, 1, "", this), new Among("ern", - 1, 1, "", this), new Among("ar", - 1, 1, "", this), new Among("er", - 1, 1, "", this), new Among("heter", 18, 1, "", this), new Among("or", - 1, 1, "", this), new Among("s", - 1, 2, "", this), new Among("as", 21, 1, "", this), new Among("arnas", 22, 1, "", this), new Among("ernas", 22, 1, "", this), new Among("ornas", 22, 1, "", this), new Among("es", 21, 1, "", this), new Among("ades", 26, 1, "", this), new Among("andes", 26, 1, "", this), new Among("ens", 21, 1, "", this), new Among("arens", 29, 1, "", this), new Among("hetens", 29, 1, "", this), new Among("erns", 21, 1, "", this), new Among("at", - 1, 1, "", this), new Among("andet", - 1, 1, "", this), new Among("het", - 1, 1, "", this), new Among("ast", - 1, 1, "", this)};
36  a_1 = new Among[]{new Among("dd", - 1, - 1, "", this), new Among("gd", - 1, - 1, "", this), new Among("nn", - 1, - 1, "", this), new Among("dt", - 1, - 1, "", this), new Among("gt", - 1, - 1, "", this), new Among("kt", - 1, - 1, "", this), new Among("tt", - 1, - 1, "", this)};
37  a_2 = new Among[]{new Among("ig", - 1, 1, "", this), new Among("lig", 0, 1, "", this), new Among("els", - 1, 1, "", this), new Among("fullt", - 1, 3, "", this), new Among("l\u00F6st", - 1, 2, "", 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) (24), (char) (0), (char) (32)};
44  private static readonly char[] g_s_ending = new char[]{(char) (119), (char) (127), (char) (149)};
45 
46  private int I_p1;
47 
48  protected internal virtual void copy_from(SwedishStemmer 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, 246)))
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, 246)))
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, 37);
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 44
167  // delete, line 44
168  slice_del();
169  break;
170 
171  case 2:
172  // (, line 46
173  if (!(in_grouping_b(g_s_ending, 98, 121)))
174  {
175  return false;
176  }
177  // delete, line 46
178  slice_del();
179  break;
180  }
181  return true;
182  }
183 
184  private bool r_consonant_pair()
185  {
186  int v_1;
187  int v_2;
188  int v_3;
189  // setlimit, line 50
190  v_1 = limit - cursor;
191  // tomark, line 50
192  if (cursor < I_p1)
193  {
194  return false;
195  }
196  cursor = I_p1;
197  v_2 = limit_backward;
198  limit_backward = cursor;
199  cursor = limit - v_1;
200  // (, line 50
201  // and, line 52
202  v_3 = limit - cursor;
203  // among, line 51
204  if (find_among_b(a_1, 7) == 0)
205  {
206  limit_backward = v_2;
207  return false;
208  }
209  cursor = limit - v_3;
210  // (, line 52
211  // [, line 52
212  ket = cursor;
213  // next, line 52
214  if (cursor <= limit_backward)
215  {
216  limit_backward = v_2;
217  return false;
218  }
219  cursor--;
220  // ], line 52
221  bra = cursor;
222  // delete, line 52
223  slice_del();
224  limit_backward = v_2;
225  return true;
226  }
227 
228  private bool r_other_suffix()
229  {
230  int among_var;
231  int v_1;
232  int v_2;
233  // setlimit, line 55
234  v_1 = limit - cursor;
235  // tomark, line 55
236  if (cursor < I_p1)
237  {
238  return false;
239  }
240  cursor = I_p1;
241  v_2 = limit_backward;
242  limit_backward = cursor;
243  cursor = limit - v_1;
244  // (, line 55
245  // [, line 56
246  ket = cursor;
247  // substring, line 56
248  among_var = find_among_b(a_2, 5);
249  if (among_var == 0)
250  {
251  limit_backward = v_2;
252  return false;
253  }
254  // ], line 56
255  bra = cursor;
256  switch (among_var)
257  {
258 
259  case 0:
260  limit_backward = v_2;
261  return false;
262 
263  case 1:
264  // (, line 57
265  // delete, line 57
266  slice_del();
267  break;
268 
269  case 2:
270  // (, line 58
271  // <-, line 58
272  slice_from("l\u00F6s");
273  break;
274 
275  case 3:
276  // (, line 59
277  // <-, line 59
278  slice_from("full");
279  break;
280  }
281  limit_backward = v_2;
282  return true;
283  }
284 
285  public override bool Stem()
286  {
287  int v_1;
288  int v_2;
289  int v_3;
290  int v_4;
291  // (, line 64
292  // do, line 66
293  v_1 = cursor;
294  do
295  {
296  // call mark_regions, line 66
297  if (!r_mark_regions())
298  {
299  goto lab0_brk;
300  }
301  }
302  while (false);
303 
304 lab0_brk: ;
305 
306  cursor = v_1;
307  // backwards, line 67
308  limit_backward = cursor; cursor = limit;
309  // (, line 67
310  // do, line 68
311  v_2 = limit - cursor;
312  do
313  {
314  // call main_suffix, line 68
315  if (!r_main_suffix())
316  {
317  goto lab1_brk;
318  }
319  }
320  while (false);
321 
322 lab1_brk: ;
323 
324  cursor = limit - v_2;
325  // do, line 69
326  v_3 = limit - cursor;
327  do
328  {
329  // call consonant_pair, line 69
330  if (!r_consonant_pair())
331  {
332  goto lab2_brk;
333  }
334  }
335  while (false);
336 
337 lab2_brk: ;
338 
339  cursor = limit - v_3;
340  // do, line 70
341  v_4 = limit - cursor;
342  do
343  {
344  // call other_suffix, line 70
345  if (!r_other_suffix())
346  {
347  goto lab3_brk;
348  }
349  }
350  while (false);
351 
352 lab3_brk: ;
353 
354  cursor = limit - v_4;
355  cursor = limit_backward; return true;
356  }
357  }
358 }