001: // This file was generated automatically by the Snowball to Java compiler
002:
003: package it.unimi.dsi.mg4j.index.snowball;
004:
005: import it.unimi.dsi.mg4j.index.snowball.Among;
006:
007: /**
008: * This class was automatically generated by a Snowball to Java compiler
009: * It implements the stemming algorithm defined by a snowball script.
010: */
011:
012: public class NorwegianStemmer extends
013: it.unimi.dsi.mg4j.index.snowball.AbstractSnowballTermProcessor {
014:
015: private static final long serialVersionUID = 1L;
016:
017: private final static NorwegianStemmer methodObject = new NorwegianStemmer();
018:
019: private final static Among a_0[] = {
020: new Among("a", -1, 1, "", methodObject),
021: new Among("e", -1, 1, "", methodObject),
022: new Among("ede", 1, 1, "", methodObject),
023: new Among("ande", 1, 1, "", methodObject),
024: new Among("ende", 1, 1, "", methodObject),
025: new Among("ane", 1, 1, "", methodObject),
026: new Among("ene", 1, 1, "", methodObject),
027: new Among("hetene", 6, 1, "", methodObject),
028: new Among("erte", 1, 3, "", methodObject),
029: new Among("en", -1, 1, "", methodObject),
030: new Among("heten", 9, 1, "", methodObject),
031: new Among("ar", -1, 1, "", methodObject),
032: new Among("er", -1, 1, "", methodObject),
033: new Among("heter", 12, 1, "", methodObject),
034: new Among("s", -1, 2, "", methodObject),
035: new Among("as", 14, 1, "", methodObject),
036: new Among("es", 14, 1, "", methodObject),
037: new Among("edes", 16, 1, "", methodObject),
038: new Among("endes", 16, 1, "", methodObject),
039: new Among("enes", 16, 1, "", methodObject),
040: new Among("hetenes", 19, 1, "", methodObject),
041: new Among("ens", 14, 1, "", methodObject),
042: new Among("hetens", 21, 1, "", methodObject),
043: new Among("ers", 14, 1, "", methodObject),
044: new Among("ets", 14, 1, "", methodObject),
045: new Among("et", -1, 1, "", methodObject),
046: new Among("het", 25, 1, "", methodObject),
047: new Among("ert", -1, 3, "", methodObject),
048: new Among("ast", -1, 1, "", methodObject) };
049:
050: private final static Among a_1[] = {
051: new Among("dt", -1, -1, "", methodObject),
052: new Among("vt", -1, -1, "", methodObject) };
053:
054: private final static Among a_2[] = {
055: new Among("leg", -1, 1, "", methodObject),
056: new Among("eleg", 0, 1, "", methodObject),
057: new Among("ig", -1, 1, "", methodObject),
058: new Among("eig", 2, 1, "", methodObject),
059: new Among("lig", 2, 1, "", methodObject),
060: new Among("elig", 4, 1, "", methodObject),
061: new Among("els", -1, 1, "", methodObject),
062: new Among("lov", -1, 1, "", methodObject),
063: new Among("elov", 7, 1, "", methodObject),
064: new Among("slov", 7, 1, "", methodObject),
065: new Among("hetslov", 9, 1, "", methodObject) };
066:
067: private static final char g_v[] = { 17, 65, 16, 1, 0, 0, 0, 0, 0,
068: 0, 0, 0, 0, 0, 0, 0, 48, 0, 128 };
069:
070: private static final char g_s_ending[] = { 119, 125, 149, 1 };
071:
072: private int I_x;
073: private int I_p1;
074:
075: private boolean r_mark_regions() {
076: int v_1;
077: int v_2;
078: // (, line 26
079: I_p1 = limit;
080: // test, line 30
081: v_1 = cursor;
082: // (, line 30
083: // hop, line 30
084: {
085: int c = cursor + 3;
086: if (0 > c || c > limit) {
087: return false;
088: }
089: cursor = c;
090: }
091: // setmark x, line 30
092: I_x = cursor;
093: cursor = v_1;
094: // goto, line 31
095: golab0: while (true) {
096: v_2 = cursor;
097: lab1: do {
098: if (!(in_grouping(g_v, 97, 248))) {
099: break lab1;
100: }
101: cursor = v_2;
102: break golab0;
103: } while (false);
104: cursor = v_2;
105: if (cursor >= limit) {
106: return false;
107: }
108: cursor++;
109: }
110: // gopast, line 31
111: golab2: while (true) {
112: lab3: do {
113: if (!(out_grouping(g_v, 97, 248))) {
114: break lab3;
115: }
116: break golab2;
117: } while (false);
118: if (cursor >= limit) {
119: return false;
120: }
121: cursor++;
122: }
123: // setmark p1, line 31
124: I_p1 = cursor;
125: // try, line 32
126: lab4: do {
127: // (, line 32
128: if (!(I_p1 < I_x)) {
129: break lab4;
130: }
131: I_p1 = I_x;
132: } while (false);
133: return true;
134: }
135:
136: private boolean r_main_suffix() {
137: int among_var;
138: int v_1;
139: int v_2;
140: int v_3;
141: // (, line 37
142: // setlimit, line 38
143: v_1 = limit - cursor;
144: // tomark, line 38
145: if (cursor < I_p1) {
146: return false;
147: }
148: cursor = I_p1;
149: v_2 = limit_backward;
150: limit_backward = cursor;
151: cursor = limit - v_1;
152: // (, line 38
153: // [, line 38
154: ket = cursor;
155: // substring, line 38
156: among_var = find_among_b(a_0, 29);
157: if (among_var == 0) {
158: limit_backward = v_2;
159: return false;
160: }
161: // ], line 38
162: bra = cursor;
163: limit_backward = v_2;
164: switch (among_var) {
165: case 0:
166: return false;
167: case 1:
168: // (, line 44
169: // delete, line 44
170: slice_del();
171: break;
172: case 2:
173: // (, line 46
174: // or, line 46
175: lab0: do {
176: v_3 = limit - cursor;
177: lab1: do {
178: if (!(in_grouping_b(g_s_ending, 98, 122))) {
179: break lab1;
180: }
181: break lab0;
182: } while (false);
183: cursor = limit - v_3;
184: // (, line 46
185: // literal, line 46
186: if (!(eq_s_b(1, "k"))) {
187: return false;
188: }
189: if (!(out_grouping_b(g_v, 97, 248))) {
190: return false;
191: }
192: } while (false);
193: // delete, line 46
194: slice_del();
195: break;
196: case 3:
197: // (, line 48
198: // <-, line 48
199: slice_from("er");
200: break;
201: }
202: return true;
203: }
204:
205: private boolean r_consonant_pair() {
206: int v_1;
207: int v_2;
208: int v_3;
209: // (, line 52
210: // test, line 53
211: v_1 = limit - cursor;
212: // (, line 53
213: // setlimit, line 54
214: v_2 = limit - cursor;
215: // tomark, line 54
216: if (cursor < I_p1) {
217: return false;
218: }
219: cursor = I_p1;
220: v_3 = limit_backward;
221: limit_backward = cursor;
222: cursor = limit - v_2;
223: // (, line 54
224: // [, line 54
225: ket = cursor;
226: // substring, line 54
227: if (find_among_b(a_1, 2) == 0) {
228: limit_backward = v_3;
229: return false;
230: }
231: // ], line 54
232: bra = cursor;
233: limit_backward = v_3;
234: cursor = limit - v_1;
235: // next, line 59
236: if (cursor <= limit_backward) {
237: return false;
238: }
239: cursor--;
240: // ], line 59
241: bra = cursor;
242: // delete, line 59
243: slice_del();
244: return true;
245: }
246:
247: private boolean r_other_suffix() {
248: int among_var;
249: int v_1;
250: int v_2;
251: // (, line 62
252: // setlimit, line 63
253: v_1 = limit - cursor;
254: // tomark, line 63
255: if (cursor < I_p1) {
256: return false;
257: }
258: cursor = I_p1;
259: v_2 = limit_backward;
260: limit_backward = cursor;
261: cursor = limit - v_1;
262: // (, line 63
263: // [, line 63
264: ket = cursor;
265: // substring, line 63
266: among_var = find_among_b(a_2, 11);
267: if (among_var == 0) {
268: limit_backward = v_2;
269: return false;
270: }
271: // ], line 63
272: bra = cursor;
273: limit_backward = v_2;
274: switch (among_var) {
275: case 0:
276: return false;
277: case 1:
278: // (, line 67
279: // delete, line 67
280: slice_del();
281: break;
282: }
283: return true;
284: }
285:
286: public boolean stem() {
287: int v_1;
288: int v_2;
289: int v_3;
290: int v_4;
291: // (, line 72
292: // do, line 74
293: v_1 = cursor;
294: lab0: do {
295: // call mark_regions, line 74
296: if (!r_mark_regions()) {
297: break lab0;
298: }
299: } while (false);
300: cursor = v_1;
301: // backwards, line 75
302: limit_backward = cursor;
303: cursor = limit;
304: // (, line 75
305: // do, line 76
306: v_2 = limit - cursor;
307: lab1: do {
308: // call main_suffix, line 76
309: if (!r_main_suffix()) {
310: break lab1;
311: }
312: } while (false);
313: cursor = limit - v_2;
314: // do, line 77
315: v_3 = limit - cursor;
316: lab2: do {
317: // call consonant_pair, line 77
318: if (!r_consonant_pair()) {
319: break lab2;
320: }
321: } while (false);
322: cursor = limit - v_3;
323: // do, line 78
324: v_4 = limit - cursor;
325: lab3: do {
326: // call other_suffix, line 78
327: if (!r_other_suffix()) {
328: break lab3;
329: }
330: } while (false);
331: cursor = limit - v_4;
332: cursor = limit_backward;
333: return true;
334: }
335:
336: public boolean equals(Object o) {
337: return o instanceof NorwegianStemmer;
338: }
339:
340: public int hashCode() {
341: return NorwegianStemmer.class.getName().hashCode();
342: }
343:
344: }
|