| 1 | |
|
| 2 | |
|
| 3 | |
package org.tartarus.snowball.ext; |
| 4 | |
|
| 5 | |
import org.tartarus.snowball.Among; |
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | 0 | public class norwegianStemmer extends org.tartarus.snowball.SnowballStemmer { |
| 13 | |
|
| 14 | |
private static final long serialVersionUID = 1L; |
| 15 | |
|
| 16 | 0 | private final static norwegianStemmer methodObject = new norwegianStemmer (); |
| 17 | |
|
| 18 | 0 | private final static Among a_0[] = { |
| 19 | |
new Among ( "a", -1, 1, "", methodObject ), |
| 20 | |
new Among ( "e", -1, 1, "", methodObject ), |
| 21 | |
new Among ( "ede", 1, 1, "", methodObject ), |
| 22 | |
new Among ( "ande", 1, 1, "", methodObject ), |
| 23 | |
new Among ( "ende", 1, 1, "", methodObject ), |
| 24 | |
new Among ( "ane", 1, 1, "", methodObject ), |
| 25 | |
new Among ( "ene", 1, 1, "", methodObject ), |
| 26 | |
new Among ( "hetene", 6, 1, "", methodObject ), |
| 27 | |
new Among ( "erte", 1, 3, "", methodObject ), |
| 28 | |
new Among ( "en", -1, 1, "", methodObject ), |
| 29 | |
new Among ( "heten", 9, 1, "", methodObject ), |
| 30 | |
new Among ( "ar", -1, 1, "", methodObject ), |
| 31 | |
new Among ( "er", -1, 1, "", methodObject ), |
| 32 | |
new Among ( "heter", 12, 1, "", methodObject ), |
| 33 | |
new Among ( "s", -1, 2, "", methodObject ), |
| 34 | |
new Among ( "as", 14, 1, "", methodObject ), |
| 35 | |
new Among ( "es", 14, 1, "", methodObject ), |
| 36 | |
new Among ( "edes", 16, 1, "", methodObject ), |
| 37 | |
new Among ( "endes", 16, 1, "", methodObject ), |
| 38 | |
new Among ( "enes", 16, 1, "", methodObject ), |
| 39 | |
new Among ( "hetenes", 19, 1, "", methodObject ), |
| 40 | |
new Among ( "ens", 14, 1, "", methodObject ), |
| 41 | |
new Among ( "hetens", 21, 1, "", methodObject ), |
| 42 | |
new Among ( "ers", 14, 1, "", methodObject ), |
| 43 | |
new Among ( "ets", 14, 1, "", methodObject ), |
| 44 | |
new Among ( "et", -1, 1, "", methodObject ), |
| 45 | |
new Among ( "het", 25, 1, "", methodObject ), |
| 46 | |
new Among ( "ert", -1, 3, "", methodObject ), |
| 47 | |
new Among ( "ast", -1, 1, "", methodObject ) |
| 48 | |
}; |
| 49 | |
|
| 50 | 0 | private final static Among a_1[] = { |
| 51 | |
new Among ( "dt", -1, -1, "", methodObject ), |
| 52 | |
new Among ( "vt", -1, -1, "", methodObject ) |
| 53 | |
}; |
| 54 | |
|
| 55 | 0 | private final static Among a_2[] = { |
| 56 | |
new Among ( "leg", -1, 1, "", methodObject ), |
| 57 | |
new Among ( "eleg", 0, 1, "", methodObject ), |
| 58 | |
new Among ( "ig", -1, 1, "", methodObject ), |
| 59 | |
new Among ( "eig", 2, 1, "", methodObject ), |
| 60 | |
new Among ( "lig", 2, 1, "", methodObject ), |
| 61 | |
new Among ( "elig", 4, 1, "", methodObject ), |
| 62 | |
new Among ( "els", -1, 1, "", methodObject ), |
| 63 | |
new Among ( "lov", -1, 1, "", methodObject ), |
| 64 | |
new Among ( "elov", 7, 1, "", methodObject ), |
| 65 | |
new Among ( "slov", 7, 1, "", methodObject ), |
| 66 | |
new Among ( "hetslov", 9, 1, "", methodObject ) |
| 67 | |
}; |
| 68 | |
|
| 69 | 0 | private static final char g_v[] = {17, 65, 16, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 48, 0, 128 }; |
| 70 | |
|
| 71 | 0 | private static final char g_s_ending[] = {119, 125, 149, 1 }; |
| 72 | |
|
| 73 | |
private int I_x; |
| 74 | |
private int I_p1; |
| 75 | |
|
| 76 | |
private void copy_from(norwegianStemmer other) { |
| 77 | 0 | I_x = other.I_x; |
| 78 | 0 | I_p1 = other.I_p1; |
| 79 | 0 | super.copy_from(other); |
| 80 | 0 | } |
| 81 | |
|
| 82 | |
private boolean r_mark_regions() { |
| 83 | |
int v_1; |
| 84 | |
int v_2; |
| 85 | |
|
| 86 | 0 | I_p1 = limit; |
| 87 | |
|
| 88 | 0 | v_1 = cursor; |
| 89 | |
|
| 90 | |
|
| 91 | |
{ |
| 92 | 0 | int c = cursor + 3; |
| 93 | 0 | if (0 > c || c > limit) |
| 94 | |
{ |
| 95 | 0 | return false; |
| 96 | |
} |
| 97 | 0 | cursor = c; |
| 98 | |
} |
| 99 | |
|
| 100 | 0 | I_x = cursor; |
| 101 | 0 | cursor = v_1; |
| 102 | |
|
| 103 | |
golab0: while(true) |
| 104 | |
{ |
| 105 | 0 | v_2 = cursor; |
| 106 | |
lab1: do { |
| 107 | 0 | if (!(in_grouping(g_v, 97, 248))) |
| 108 | |
{ |
| 109 | 0 | break lab1; |
| 110 | |
} |
| 111 | 0 | cursor = v_2; |
| 112 | 0 | break golab0; |
| 113 | |
} while (false); |
| 114 | 0 | cursor = v_2; |
| 115 | 0 | if (cursor >= limit) |
| 116 | |
{ |
| 117 | 0 | return false; |
| 118 | |
} |
| 119 | 0 | cursor++; |
| 120 | |
} |
| 121 | |
|
| 122 | |
golab2: while(true) |
| 123 | |
{ |
| 124 | |
lab3: do { |
| 125 | 0 | if (!(out_grouping(g_v, 97, 248))) |
| 126 | |
{ |
| 127 | |
break lab3; |
| 128 | |
} |
| 129 | |
break golab2; |
| 130 | |
} while (false); |
| 131 | 0 | if (cursor >= limit) |
| 132 | |
{ |
| 133 | 0 | return false; |
| 134 | |
} |
| 135 | 0 | cursor++; |
| 136 | |
} |
| 137 | |
|
| 138 | 0 | I_p1 = cursor; |
| 139 | |
|
| 140 | |
lab4: do { |
| 141 | |
|
| 142 | 0 | if (!(I_p1 < I_x)) |
| 143 | |
{ |
| 144 | 0 | break lab4; |
| 145 | |
} |
| 146 | 0 | I_p1 = I_x; |
| 147 | |
} while (false); |
| 148 | 0 | return true; |
| 149 | |
} |
| 150 | |
|
| 151 | |
private boolean r_main_suffix() { |
| 152 | |
int among_var; |
| 153 | |
int v_1; |
| 154 | |
int v_2; |
| 155 | |
int v_3; |
| 156 | |
|
| 157 | |
|
| 158 | 0 | v_1 = limit - cursor; |
| 159 | |
|
| 160 | 0 | if (cursor < I_p1) |
| 161 | |
{ |
| 162 | 0 | return false; |
| 163 | |
} |
| 164 | 0 | cursor = I_p1; |
| 165 | 0 | v_2 = limit_backward; |
| 166 | 0 | limit_backward = cursor; |
| 167 | 0 | cursor = limit - v_1; |
| 168 | |
|
| 169 | |
|
| 170 | 0 | ket = cursor; |
| 171 | |
|
| 172 | 0 | among_var = find_among_b(a_0, 29); |
| 173 | 0 | if (among_var == 0) |
| 174 | |
{ |
| 175 | 0 | limit_backward = v_2; |
| 176 | 0 | return false; |
| 177 | |
} |
| 178 | |
|
| 179 | 0 | bra = cursor; |
| 180 | 0 | limit_backward = v_2; |
| 181 | 0 | switch(among_var) { |
| 182 | |
case 0: |
| 183 | 0 | return false; |
| 184 | |
case 1: |
| 185 | |
|
| 186 | |
|
| 187 | 0 | slice_del(); |
| 188 | 0 | break; |
| 189 | |
case 2: |
| 190 | |
|
| 191 | |
|
| 192 | |
lab0: do { |
| 193 | 0 | v_3 = limit - cursor; |
| 194 | |
lab1: do { |
| 195 | 0 | if (!(in_grouping_b(g_s_ending, 98, 122))) |
| 196 | |
{ |
| 197 | |
break lab1; |
| 198 | |
} |
| 199 | |
break lab0; |
| 200 | |
} while (false); |
| 201 | 0 | cursor = limit - v_3; |
| 202 | |
|
| 203 | |
|
| 204 | 0 | if (!(eq_s_b(1, "k"))) |
| 205 | |
{ |
| 206 | 0 | return false; |
| 207 | |
} |
| 208 | 0 | if (!(out_grouping_b(g_v, 97, 248))) |
| 209 | |
{ |
| 210 | 0 | return false; |
| 211 | |
} |
| 212 | |
} while (false); |
| 213 | |
|
| 214 | 0 | slice_del(); |
| 215 | 0 | break; |
| 216 | |
case 3: |
| 217 | |
|
| 218 | |
|
| 219 | 0 | slice_from("er"); |
| 220 | |
break; |
| 221 | |
} |
| 222 | 0 | return true; |
| 223 | |
} |
| 224 | |
|
| 225 | |
private boolean r_consonant_pair() { |
| 226 | |
int v_1; |
| 227 | |
int v_2; |
| 228 | |
int v_3; |
| 229 | |
|
| 230 | |
|
| 231 | 0 | v_1 = limit - cursor; |
| 232 | |
|
| 233 | |
|
| 234 | 0 | v_2 = limit - cursor; |
| 235 | |
|
| 236 | 0 | if (cursor < I_p1) |
| 237 | |
{ |
| 238 | 0 | return false; |
| 239 | |
} |
| 240 | 0 | cursor = I_p1; |
| 241 | 0 | v_3 = limit_backward; |
| 242 | 0 | limit_backward = cursor; |
| 243 | 0 | cursor = limit - v_2; |
| 244 | |
|
| 245 | |
|
| 246 | 0 | ket = cursor; |
| 247 | |
|
| 248 | 0 | if (find_among_b(a_1, 2) == 0) |
| 249 | |
{ |
| 250 | 0 | limit_backward = v_3; |
| 251 | 0 | return false; |
| 252 | |
} |
| 253 | |
|
| 254 | 0 | bra = cursor; |
| 255 | 0 | limit_backward = v_3; |
| 256 | 0 | cursor = limit - v_1; |
| 257 | |
|
| 258 | 0 | if (cursor <= limit_backward) |
| 259 | |
{ |
| 260 | 0 | return false; |
| 261 | |
} |
| 262 | 0 | cursor--; |
| 263 | |
|
| 264 | 0 | bra = cursor; |
| 265 | |
|
| 266 | 0 | slice_del(); |
| 267 | 0 | return true; |
| 268 | |
} |
| 269 | |
|
| 270 | |
private boolean r_other_suffix() { |
| 271 | |
int among_var; |
| 272 | |
int v_1; |
| 273 | |
int v_2; |
| 274 | |
|
| 275 | |
|
| 276 | 0 | v_1 = limit - cursor; |
| 277 | |
|
| 278 | 0 | if (cursor < I_p1) |
| 279 | |
{ |
| 280 | 0 | return false; |
| 281 | |
} |
| 282 | 0 | cursor = I_p1; |
| 283 | 0 | v_2 = limit_backward; |
| 284 | 0 | limit_backward = cursor; |
| 285 | 0 | cursor = limit - v_1; |
| 286 | |
|
| 287 | |
|
| 288 | 0 | ket = cursor; |
| 289 | |
|
| 290 | 0 | among_var = find_among_b(a_2, 11); |
| 291 | 0 | if (among_var == 0) |
| 292 | |
{ |
| 293 | 0 | limit_backward = v_2; |
| 294 | 0 | return false; |
| 295 | |
} |
| 296 | |
|
| 297 | 0 | bra = cursor; |
| 298 | 0 | limit_backward = v_2; |
| 299 | 0 | switch(among_var) { |
| 300 | |
case 0: |
| 301 | 0 | return false; |
| 302 | |
case 1: |
| 303 | |
|
| 304 | |
|
| 305 | 0 | slice_del(); |
| 306 | |
break; |
| 307 | |
} |
| 308 | 0 | return true; |
| 309 | |
} |
| 310 | |
|
| 311 | |
public boolean stem() { |
| 312 | |
int v_1; |
| 313 | |
int v_2; |
| 314 | |
int v_3; |
| 315 | |
int v_4; |
| 316 | |
|
| 317 | |
|
| 318 | 0 | v_1 = cursor; |
| 319 | |
lab0: do { |
| 320 | |
|
| 321 | 0 | if (!r_mark_regions()) |
| 322 | |
{ |
| 323 | |
break lab0; |
| 324 | |
} |
| 325 | |
} while (false); |
| 326 | 0 | cursor = v_1; |
| 327 | |
|
| 328 | 0 | limit_backward = cursor; cursor = limit; |
| 329 | |
|
| 330 | |
|
| 331 | 0 | v_2 = limit - cursor; |
| 332 | |
lab1: do { |
| 333 | |
|
| 334 | 0 | if (!r_main_suffix()) |
| 335 | |
{ |
| 336 | |
break lab1; |
| 337 | |
} |
| 338 | |
} while (false); |
| 339 | 0 | cursor = limit - v_2; |
| 340 | |
|
| 341 | 0 | v_3 = limit - cursor; |
| 342 | |
lab2: do { |
| 343 | |
|
| 344 | 0 | if (!r_consonant_pair()) |
| 345 | |
{ |
| 346 | |
break lab2; |
| 347 | |
} |
| 348 | |
} while (false); |
| 349 | 0 | cursor = limit - v_3; |
| 350 | |
|
| 351 | 0 | v_4 = limit - cursor; |
| 352 | |
lab3: do { |
| 353 | |
|
| 354 | 0 | if (!r_other_suffix()) |
| 355 | |
{ |
| 356 | |
break lab3; |
| 357 | |
} |
| 358 | |
} while (false); |
| 359 | 0 | cursor = limit - v_4; |
| 360 | 0 | cursor = limit_backward; return true; |
| 361 | |
} |
| 362 | |
|
| 363 | |
public boolean equals( Object o ) { |
| 364 | 0 | return o instanceof norwegianStemmer; |
| 365 | |
} |
| 366 | |
|
| 367 | |
public int hashCode() { |
| 368 | 0 | return norwegianStemmer.class.getName().hashCode(); |
| 369 | |
} |
| 370 | |
|
| 371 | |
|
| 372 | |
|
| 373 | |
} |
| 374 | |
|