Debian Codegraph @

mkdocs/contrib/search/lunr-language/lunr.fi.js

raw
1 /*!
2 * Lunr languages, `Finnish` language
3 * https://github.com/MihaiValentin/lunr-languages
4 *
5 * Copyright 2014, Mihai Valentin
6 * http://www.mozilla.org/MPL/
7 */
8 /*!
9 * based on
10 * Snowball JavaScript Library v0.3
11 * http://code.google.com/p/urim/
12 * http://snowball.tartarus.org/
13 *
14 * Copyright 2010, Oleg Mazko
15 * http://www.mozilla.org/MPL/
16 */
17
18 /**
19 * export the module via AMD, CommonJS or as a browser global
20 * Export code from https://github.com/umdjs/umd/blob/master/returnExports.js
21 */
22 ;
23 (function(root, factory) {
24 if (typeof define === 'function' && define.amd) {
25 // AMD. Register as an anonymous module.
26 define(factory)
27 } else if (typeof exports === 'object') {
28 /**
29 * Node. Does not work with strict CommonJS, but
30 * only CommonJS-like environments that support module.exports,
31 * like Node.
32 */
33 module.exports = factory()
34 } else {
35 // Browser globals (root is window)
36 factory()(root.lunr);
37 }
38 }(this, function() {
39 /**
40 * Just return a value to define the module export.
41 * This example returns an object, but the module
42 * can return a function as the exported value.
43 */
44 return function(lunr) {
45 /* throw error if lunr is not yet included */
46 if ('undefined' === typeof lunr) {
47 throw new Error('Lunr is not present. Please include / require Lunr before this script.');
48 }
49
50 /* throw error if lunr stemmer support is not yet included */
51 if ('undefined' === typeof lunr.stemmerSupport) {
52 throw new Error('Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.');
53 }
54
55 /* register specific locale function */
56 lunr.fi = function() {
57 this.pipeline.reset();
58 this.pipeline.add(
59 lunr.fi.trimmer,
60 lunr.fi.stopWordFilter,
61 lunr.fi.stemmer
62 );
63
64 // for lunr version 2
65 // this is necessary so that every searched word is also stemmed before
66 // in lunr <= 1 this is not needed, as it is done using the normal pipeline
67 if (this.searchPipeline) {
68 this.searchPipeline.reset();
69 this.searchPipeline.add(lunr.fi.stemmer)
70 }
71 };
72
73 /* lunr trimmer function */
74 lunr.fi.wordCharacters = "A-Za-z\xAA\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02B8\u02E0-\u02E4\u1D00-\u1D25\u1D2C-\u1D5C\u1D62-\u1D65\u1D6B-\u1D77\u1D79-\u1DBE\u1E00-\u1EFF\u2071\u207F\u2090-\u209C\u212A\u212B\u2132\u214E\u2160-\u2188\u2C60-\u2C7F\uA722-\uA787\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA7FF\uAB30-\uAB5A\uAB5C-\uAB64\uFB00-\uFB06\uFF21-\uFF3A\uFF41-\uFF5A";
75 lunr.fi.trimmer = lunr.trimmerSupport.generateTrimmer(lunr.fi.wordCharacters);
76
77 lunr.Pipeline.registerFunction(lunr.fi.trimmer, 'trimmer-fi');
78
79 /* lunr stemmer function */
80 lunr.fi.stemmer = (function() {
81 /* create the wrapped stemmer object */
82 var Among = lunr.stemmerSupport.Among,
83 SnowballProgram = lunr.stemmerSupport.SnowballProgram,
84 st = new function FinnishStemmer() {
85 var a_0 = [new Among("pa", -1, 1), new Among("sti", -1, 2),
86 new Among("kaan", -1, 1), new Among("han", -1, 1),
87 new Among("kin", -1, 1), new Among("h\u00E4n", -1, 1),
88 new Among("k\u00E4\u00E4n", -1, 1), new Among("ko", -1, 1),
89 new Among("p\u00E4", -1, 1), new Among("k\u00F6", -1, 1)
90 ],
91 a_1 = [
92 new Among("lla", -1, -1), new Among("na", -1, -1),
93 new Among("ssa", -1, -1), new Among("ta", -1, -1),
94 new Among("lta", 3, -1), new Among("sta", 3, -1)
95 ],
96 a_2 = [
97 new Among("ll\u00E4", -1, -1), new Among("n\u00E4", -1, -1),
98 new Among("ss\u00E4", -1, -1), new Among("t\u00E4", -1, -1),
99 new Among("lt\u00E4", 3, -1), new Among("st\u00E4", 3, -1)
100 ],
101 a_3 = [
102 new Among("lle", -1, -1), new Among("ine", -1, -1)
103 ],
104 a_4 = [
105 new Among("nsa", -1, 3), new Among("mme", -1, 3),
106 new Among("nne", -1, 3), new Among("ni", -1, 2),
107 new Among("si", -1, 1), new Among("an", -1, 4),
108 new Among("en", -1, 6), new Among("\u00E4n", -1, 5),
109 new Among("ns\u00E4", -1, 3)
110 ],
111 a_5 = [new Among("aa", -1, -1),
112 new Among("ee", -1, -1), new Among("ii", -1, -1),
113 new Among("oo", -1, -1), new Among("uu", -1, -1),
114 new Among("\u00E4\u00E4", -1, -1),
115 new Among("\u00F6\u00F6", -1, -1)
116 ],
117 a_6 = [new Among("a", -1, 8),
118 new Among("lla", 0, -1), new Among("na", 0, -1),
119 new Among("ssa", 0, -1), new Among("ta", 0, -1),
120 new Among("lta", 4, -1), new Among("sta", 4, -1),
121 new Among("tta", 4, 9), new Among("lle", -1, -1),
122 new Among("ine", -1, -1), new Among("ksi", -1, -1),
123 new Among("n", -1, 7), new Among("han", 11, 1),
124 new Among("den", 11, -1, r_VI), new Among("seen", 11, -1, r_LONG),
125 new Among("hen", 11, 2), new Among("tten", 11, -1, r_VI),
126 new Among("hin", 11, 3), new Among("siin", 11, -1, r_VI),
127 new Among("hon", 11, 4), new Among("h\u00E4n", 11, 5),
128 new Among("h\u00F6n", 11, 6), new Among("\u00E4", -1, 8),
129 new Among("ll\u00E4", 22, -1), new Among("n\u00E4", 22, -1),
130 new Among("ss\u00E4", 22, -1), new Among("t\u00E4", 22, -1),
131 new Among("lt\u00E4", 26, -1), new Among("st\u00E4", 26, -1),
132 new Among("tt\u00E4", 26, 9)
133 ],
134 a_7 = [new Among("eja", -1, -1),
135 new Among("mma", -1, 1), new Among("imma", 1, -1),
136 new Among("mpa", -1, 1), new Among("impa", 3, -1),
137 new Among("mmi", -1, 1), new Among("immi", 5, -1),
138 new Among("mpi", -1, 1), new Among("impi", 7, -1),
139 new Among("ej\u00E4", -1, -1), new Among("mm\u00E4", -1, 1),
140 new Among("imm\u00E4", 10, -1), new Among("mp\u00E4", -1, 1),
141 new Among("imp\u00E4", 12, -1)
142 ],
143 a_8 = [new Among("i", -1, -1),
144 new Among("j", -1, -1)
145 ],
146 a_9 = [new Among("mma", -1, 1),
147 new Among("imma", 0, -1)
148 ],
149 g_AEI = [17, 1, 0, 0, 0, 0, 0, 0, 0, 0,
150 0, 0, 0, 0, 0, 0, 8
151 ],
152 g_V1 = [17, 65, 16, 1, 0, 0, 0, 0, 0, 0, 0,
153 0, 0, 0, 0, 0, 8, 0, 32
154 ],
155 g_V2 = [17, 65, 16, 0, 0, 0, 0, 0, 0, 0,
156 0, 0, 0, 0, 0, 0, 8, 0, 32
157 ],
158 g_particle_end = [17, 97, 24, 1, 0, 0,
159 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 32
160 ],
161 B_ending_removed, S_x, I_p2, I_p1, sbp = new SnowballProgram();
162 this.setCurrent = function(word) {
163 sbp.setCurrent(word);
164 };
165 this.getCurrent = function() {
166 return sbp.getCurrent();
167 };
168
169 function r_mark_regions() {
170 I_p1 = sbp.limit;
171 I_p2 = I_p1;
172 if (!habr1()) {
173 I_p1 = sbp.cursor;
174 if (!habr1())
175 I_p2 = sbp.cursor;
176 }
177 }
178
179 function habr1() {
180 var v_1;
181 while (true) {
182 v_1 = sbp.cursor;
183 if (sbp.in_grouping(g_V1, 97, 246))
184 break;
185 sbp.cursor = v_1;
186 if (v_1 >= sbp.limit)
187 return true;
188 sbp.cursor++;
189 }
190 sbp.cursor = v_1;
191 while (!sbp.out_grouping(g_V1, 97, 246)) {
192 if (sbp.cursor >= sbp.limit)
193 return true;
194 sbp.cursor++;
195 }
196 return false;
197 }
198
199 function r_R2() {
200 return I_p2 <= sbp.cursor;
201 }
202
203 function r_particle_etc() {
204 var among_var, v_1;
205 if (sbp.cursor >= I_p1) {
206 v_1 = sbp.limit_backward;
207 sbp.limit_backward = I_p1;
208 sbp.ket = sbp.cursor;
209 among_var = sbp.find_among_b(a_0, 10);
210 if (among_var) {
211 sbp.bra = sbp.cursor;
212 sbp.limit_backward = v_1;
213 switch (among_var) {
214 case 1:
215 if (!sbp.in_grouping_b(g_particle_end, 97, 246))
216 return;
217 break;
218 case 2:
219 if (!r_R2())
220 return;
221 break;
222 }
223 sbp.slice_del();
224 } else
225 sbp.limit_backward = v_1;
226 }
227 }
228
229 function r_possessive() {
230 var among_var, v_1, v_2;
231 if (sbp.cursor >= I_p1) {
232 v_1 = sbp.limit_backward;
233 sbp.limit_backward = I_p1;
234 sbp.ket = sbp.cursor;
235 among_var = sbp.find_among_b(a_4, 9);
236 if (among_var) {
237 sbp.bra = sbp.cursor;
238 sbp.limit_backward = v_1;
239 switch (among_var) {
240 case 1:
241 v_2 = sbp.limit - sbp.cursor;
242 if (!sbp.eq_s_b(1, "k")) {
243 sbp.cursor = sbp.limit - v_2;
244 sbp.slice_del();
245 }
246 break;
247 case 2:
248 sbp.slice_del();
249 sbp.ket = sbp.cursor;
250 if (sbp.eq_s_b(3, "kse")) {
251 sbp.bra = sbp.cursor;
252 sbp.slice_from("ksi");
253 }
254 break;
255 case 3:
256 sbp.slice_del();
257 break;
258 case 4:
259 if (sbp.find_among_b(a_1, 6))
260 sbp.slice_del();
261 break;
262 case 5:
263 if (sbp.find_among_b(a_2, 6))
264 sbp.slice_del();
265 break;
266 case 6:
267 if (sbp.find_among_b(a_3, 2))
268 sbp.slice_del();
269 break;
270 }
271 } else
272 sbp.limit_backward = v_1;
273 }
274 }
275
276 function r_LONG() {
277 return sbp.find_among_b(a_5, 7);
278 }
279
280 function r_VI() {
281 return sbp.eq_s_b(1, "i") && sbp.in_grouping_b(g_V2, 97, 246);
282 }
283
284 function r_case_ending() {
285 var among_var, v_1, v_2;
286 if (sbp.cursor >= I_p1) {
287 v_1 = sbp.limit_backward;
288 sbp.limit_backward = I_p1;
289 sbp.ket = sbp.cursor;
290 among_var = sbp.find_among_b(a_6, 30);
291 if (among_var) {
292 sbp.bra = sbp.cursor;
293 sbp.limit_backward = v_1;
294 switch (among_var) {
295 case 1:
296 if (!sbp.eq_s_b(1, "a"))
297 return;
298 break;
299 case 2:
300 case 9:
301 if (!sbp.eq_s_b(1, "e"))
302 return;
303 break;
304 case 3:
305 if (!sbp.eq_s_b(1, "i"))
306 return;
307 break;
308 case 4:
309 if (!sbp.eq_s_b(1, "o"))
310 return;
311 break;
312 case 5:
313 if (!sbp.eq_s_b(1, "\u00E4"))
314 return;
315 break;
316 case 6:
317 if (!sbp.eq_s_b(1, "\u00F6"))
318 return;
319 break;
320 case 7:
321 v_2 = sbp.limit - sbp.cursor;
322 if (!r_LONG()) {
323 sbp.cursor = sbp.limit - v_2;
324 if (!sbp.eq_s_b(2, "ie")) {
325 sbp.cursor = sbp.limit - v_2;
326 break;
327 }
328 }
329 sbp.cursor = sbp.limit - v_2;
330 if (sbp.cursor <= sbp.limit_backward) {
331 sbp.cursor = sbp.limit - v_2;
332 break;
333 }
334 sbp.cursor--;
335 sbp.bra = sbp.cursor;
336 break;
337 case 8:
338 if (!sbp.in_grouping_b(g_V1, 97, 246) ||
339 !sbp.out_grouping_b(g_V1, 97, 246))
340 return;
341 break;
342 }
343 sbp.slice_del();
344 B_ending_removed = true;
345 } else
346 sbp.limit_backward = v_1;
347 }
348 }
349
350 function r_other_endings() {
351 var among_var, v_1, v_2;
352 if (sbp.cursor >= I_p2) {
353 v_1 = sbp.limit_backward;
354 sbp.limit_backward = I_p2;
355 sbp.ket = sbp.cursor;
356 among_var = sbp.find_among_b(a_7, 14);
357 if (among_var) {
358 sbp.bra = sbp.cursor;
359 sbp.limit_backward = v_1;
360 if (among_var == 1) {
361 v_2 = sbp.limit - sbp.cursor;
362 if (sbp.eq_s_b(2, "po"))
363 return;
364 sbp.cursor = sbp.limit - v_2;
365 }
366 sbp.slice_del();
367 } else
368 sbp.limit_backward = v_1;
369 }
370 }
371
372 function r_i_plural() {
373 var v_1;
374 if (sbp.cursor >= I_p1) {
375 v_1 = sbp.limit_backward;
376 sbp.limit_backward = I_p1;
377 sbp.ket = sbp.cursor;
378 if (sbp.find_among_b(a_8, 2)) {
379 sbp.bra = sbp.cursor;
380 sbp.limit_backward = v_1;
381 sbp.slice_del();
382 } else
383 sbp.limit_backward = v_1;
384 }
385 }
386
387 function r_t_plural() {
388 var among_var, v_1, v_2, v_3, v_4, v_5;
389 if (sbp.cursor >= I_p1) {
390 v_1 = sbp.limit_backward;
391 sbp.limit_backward = I_p1;
392 sbp.ket = sbp.cursor;
393 if (sbp.eq_s_b(1, "t")) {
394 sbp.bra = sbp.cursor;
395 v_2 = sbp.limit - sbp.cursor;
396 if (sbp.in_grouping_b(g_V1, 97, 246)) {
397 sbp.cursor = sbp.limit - v_2;
398 sbp.slice_del();
399 sbp.limit_backward = v_1;
400 v_3 = sbp.limit - sbp.cursor;
401 if (sbp.cursor >= I_p2) {
402 sbp.cursor = I_p2;
403 v_4 = sbp.limit_backward;
404 sbp.limit_backward = sbp.cursor;
405 sbp.cursor = sbp.limit - v_3;
406 sbp.ket = sbp.cursor;
407 among_var = sbp.find_among_b(a_9, 2);
408 if (among_var) {
409 sbp.bra = sbp.cursor;
410 sbp.limit_backward = v_4;
411 if (among_var == 1) {
412 v_5 = sbp.limit - sbp.cursor;
413 if (sbp.eq_s_b(2, "po"))
414 return;
415 sbp.cursor = sbp.limit - v_5;
416 }
417 sbp.slice_del();
418 return;
419 }
420 }
421 }
422 }
423 sbp.limit_backward = v_1;
424 }
425 }
426
427 function r_tidy() {
428 var v_1, v_2, v_3, v_4;
429 if (sbp.cursor >= I_p1) {
430 v_1 = sbp.limit_backward;
431 sbp.limit_backward = I_p1;
432 v_2 = sbp.limit - sbp.cursor;
433 if (r_LONG()) {
434 sbp.cursor = sbp.limit - v_2;
435 sbp.ket = sbp.cursor;
436 if (sbp.cursor > sbp.limit_backward) {
437 sbp.cursor--;
438 sbp.bra = sbp.cursor;
439 sbp.slice_del();
440 }
441 }
442 sbp.cursor = sbp.limit - v_2;
443 sbp.ket = sbp.cursor;
444 if (sbp.in_grouping_b(g_AEI, 97, 228)) {
445 sbp.bra = sbp.cursor;
446 if (sbp.out_grouping_b(g_V1, 97, 246))
447 sbp.slice_del();
448 }
449 sbp.cursor = sbp.limit - v_2;
450 sbp.ket = sbp.cursor;
451 if (sbp.eq_s_b(1, "j")) {
452 sbp.bra = sbp.cursor;
453 v_3 = sbp.limit - sbp.cursor;
454 if (!sbp.eq_s_b(1, "o")) {
455 sbp.cursor = sbp.limit - v_3;
456 if (sbp.eq_s_b(1, "u"))
457 sbp.slice_del();
458 } else
459 sbp.slice_del();
460 }
461 sbp.cursor = sbp.limit - v_2;
462 sbp.ket = sbp.cursor;
463 if (sbp.eq_s_b(1, "o")) {
464 sbp.bra = sbp.cursor;
465 if (sbp.eq_s_b(1, "j"))
466 sbp.slice_del();
467 }
468 sbp.cursor = sbp.limit - v_2;
469 sbp.limit_backward = v_1;
470 while (true) {
471 v_4 = sbp.limit - sbp.cursor;
472 if (sbp.out_grouping_b(g_V1, 97, 246)) {
473 sbp.cursor = sbp.limit - v_4;
474 break;
475 }
476 sbp.cursor = sbp.limit - v_4;
477 if (sbp.cursor <= sbp.limit_backward)
478 return;
479 sbp.cursor--;
480 }
481 sbp.ket = sbp.cursor;
482 if (sbp.cursor > sbp.limit_backward) {
483 sbp.cursor--;
484 sbp.bra = sbp.cursor;
485 S_x = sbp.slice_to();
486 if (sbp.eq_v_b(S_x))
487 sbp.slice_del();
488 }
489 }
490 }
491 this.stem = function() {
492 var v_1 = sbp.cursor;
493 r_mark_regions();
494 B_ending_removed = false;
495 sbp.limit_backward = v_1;
496 sbp.cursor = sbp.limit;
497 r_particle_etc();
498 sbp.cursor = sbp.limit;
499 r_possessive();
500 sbp.cursor = sbp.limit;
501 r_case_ending();
502 sbp.cursor = sbp.limit;
503 r_other_endings();
504 sbp.cursor = sbp.limit;
505 if (B_ending_removed) {
506 r_i_plural();
507 sbp.cursor = sbp.limit;
508 } else {
509 sbp.cursor = sbp.limit;
510 r_t_plural();
511 sbp.cursor = sbp.limit;
512 }
513 r_tidy();
514 return true;
515 }
516 };
517
518 /* and return a function that stems a word for the current locale */
519 return function(token) {
520 // for lunr version 2
521 if (typeof token.update === "function") {
522 return token.update(function(word) {
523 st.setCurrent(word);
524 st.stem();
525 return st.getCurrent();
526 })
527 } else { // for lunr version <= 1
528 st.setCurrent(token);
529 st.stem();
530 return st.getCurrent();
531 }
532 }
533 })();
534
535 lunr.Pipeline.registerFunction(lunr.fi.stemmer, 'stemmer-fi');
536
537 lunr.fi.stopWordFilter = lunr.generateStopWordFilter('ei eivät emme en et ette että he heidän heidät heihin heille heillä heiltä heissä heistä heitä hän häneen hänelle hänellä häneltä hänen hänessä hänestä hänet häntä itse ja johon joiden joihin joiksi joilla joille joilta joina joissa joista joita joka joksi jolla jolle jolta jona jonka jos jossa josta jota jotka kanssa keiden keihin keiksi keille keillä keiltä keinä keissä keistä keitä keneen keneksi kenelle kenellä keneltä kenen kenenä kenessä kenestä kenet ketkä ketkä ketä koska kuin kuka kun me meidän meidät meihin meille meillä meiltä meissä meistä meitä mihin miksi mikä mille millä miltä minkä minkä minua minulla minulle minulta minun minussa minusta minut minuun minä minä missä mistä mitkä mitä mukaan mutta ne niiden niihin niiksi niille niillä niiltä niin niin niinä niissä niistä niitä noiden noihin noiksi noilla noille noilta noin noina noissa noista noita nuo nyt näiden näihin näiksi näille näillä näiltä näinä näissä näistä näitä nämä ole olemme olen olet olette oli olimme olin olisi olisimme olisin olisit olisitte olisivat olit olitte olivat olla olleet ollut on ovat poikki se sekä sen siihen siinä siitä siksi sille sillä sillä siltä sinua sinulla sinulle sinulta sinun sinussa sinusta sinut sinuun sinä sinä sitä tai te teidän teidät teihin teille teillä teiltä teissä teistä teitä tuo tuohon tuoksi tuolla tuolle tuolta tuon tuona tuossa tuosta tuota tähän täksi tälle tällä tältä tämä tämän tänä tässä tästä tätä vaan vai vaikka yli'.split(' '));
538
539 lunr.Pipeline.registerFunction(lunr.fi.stopWordFilter, 'stopWordFilter-fi');
540 };
541 }))