middleman-search 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,529 @@
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.stopWordFilter,
60
+ lunr.fi.stemmer
61
+ );
62
+ };
63
+
64
+ /* lunr stemmer function */
65
+ lunr.fi.stemmer = (function() {
66
+ /* create the wrapped stemmer object */
67
+ var Among = lunr.stemmerSupport.Among,
68
+ SnowballProgram = lunr.stemmerSupport.SnowballProgram,
69
+ st = new function FinnishStemmer() {
70
+ var a_0 = [new Among("pa", -1, 1), new Among("sti", -1, 2),
71
+ new Among("kaan", -1, 1), new Among("han", -1, 1),
72
+ new Among("kin", -1, 1), new Among("h\u00E4n", -1, 1),
73
+ new Among("k\u00E4\u00E4n", -1, 1), new Among("ko", -1, 1),
74
+ new Among("p\u00E4", -1, 1), new Among("k\u00F6", -1, 1)
75
+ ],
76
+ a_1 = [
77
+ new Among("lla", -1, -1), new Among("na", -1, -1),
78
+ new Among("ssa", -1, -1), new Among("ta", -1, -1),
79
+ new Among("lta", 3, -1), new Among("sta", 3, -1)
80
+ ],
81
+ a_2 = [
82
+ new Among("ll\u00E4", -1, -1), new Among("n\u00E4", -1, -1),
83
+ new Among("ss\u00E4", -1, -1), new Among("t\u00E4", -1, -1),
84
+ new Among("lt\u00E4", 3, -1), new Among("st\u00E4", 3, -1)
85
+ ],
86
+ a_3 = [
87
+ new Among("lle", -1, -1), new Among("ine", -1, -1)
88
+ ],
89
+ a_4 = [
90
+ new Among("nsa", -1, 3), new Among("mme", -1, 3),
91
+ new Among("nne", -1, 3), new Among("ni", -1, 2),
92
+ new Among("si", -1, 1), new Among("an", -1, 4),
93
+ new Among("en", -1, 6), new Among("\u00E4n", -1, 5),
94
+ new Among("ns\u00E4", -1, 3)
95
+ ],
96
+ a_5 = [new Among("aa", -1, -1),
97
+ new Among("ee", -1, -1), new Among("ii", -1, -1),
98
+ new Among("oo", -1, -1), new Among("uu", -1, -1),
99
+ new Among("\u00E4\u00E4", -1, -1),
100
+ new Among("\u00F6\u00F6", -1, -1)
101
+ ],
102
+ a_6 = [new Among("a", -1, 8),
103
+ new Among("lla", 0, -1), new Among("na", 0, -1),
104
+ new Among("ssa", 0, -1), new Among("ta", 0, -1),
105
+ new Among("lta", 4, -1), new Among("sta", 4, -1),
106
+ new Among("tta", 4, 9), new Among("lle", -1, -1),
107
+ new Among("ine", -1, -1), new Among("ksi", -1, -1),
108
+ new Among("n", -1, 7), new Among("han", 11, 1),
109
+ new Among("den", 11, -1, r_VI), new Among("seen", 11, -1, r_LONG),
110
+ new Among("hen", 11, 2), new Among("tten", 11, -1, r_VI),
111
+ new Among("hin", 11, 3), new Among("siin", 11, -1, r_VI),
112
+ new Among("hon", 11, 4), new Among("h\u00E4n", 11, 5),
113
+ new Among("h\u00F6n", 11, 6), new Among("\u00E4", -1, 8),
114
+ new Among("ll\u00E4", 22, -1), new Among("n\u00E4", 22, -1),
115
+ new Among("ss\u00E4", 22, -1), new Among("t\u00E4", 22, -1),
116
+ new Among("lt\u00E4", 26, -1), new Among("st\u00E4", 26, -1),
117
+ new Among("tt\u00E4", 26, 9)
118
+ ],
119
+ a_7 = [new Among("eja", -1, -1),
120
+ new Among("mma", -1, 1), new Among("imma", 1, -1),
121
+ new Among("mpa", -1, 1), new Among("impa", 3, -1),
122
+ new Among("mmi", -1, 1), new Among("immi", 5, -1),
123
+ new Among("mpi", -1, 1), new Among("impi", 7, -1),
124
+ new Among("ej\u00E4", -1, -1), new Among("mm\u00E4", -1, 1),
125
+ new Among("imm\u00E4", 10, -1), new Among("mp\u00E4", -1, 1),
126
+ new Among("imp\u00E4", 12, -1)
127
+ ],
128
+ a_8 = [new Among("i", -1, -1),
129
+ new Among("j", -1, -1)
130
+ ],
131
+ a_9 = [new Among("mma", -1, 1),
132
+ new Among("imma", 0, -1)
133
+ ],
134
+ g_AEI = [17, 1, 0, 0, 0, 0, 0, 0, 0, 0,
135
+ 0, 0, 0, 0, 0, 0, 8
136
+ ],
137
+ g_V1 = [17, 65, 16, 1, 0, 0, 0, 0, 0, 0, 0,
138
+ 0, 0, 0, 0, 0, 8, 0, 32
139
+ ],
140
+ g_V2 = [17, 65, 16, 0, 0, 0, 0, 0, 0, 0,
141
+ 0, 0, 0, 0, 0, 0, 8, 0, 32
142
+ ],
143
+ g_particle_end = [17, 97, 24, 1, 0, 0,
144
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 32
145
+ ],
146
+ B_ending_removed, S_x, I_p2, I_p1, sbp = new SnowballProgram();
147
+ this.setCurrent = function(word) {
148
+ sbp.setCurrent(word);
149
+ };
150
+ this.getCurrent = function() {
151
+ return sbp.getCurrent();
152
+ };
153
+
154
+ function r_mark_regions() {
155
+ I_p1 = sbp.limit;
156
+ I_p2 = I_p1;
157
+ if (!habr1()) {
158
+ I_p1 = sbp.cursor;
159
+ if (!habr1())
160
+ I_p2 = sbp.cursor;
161
+ }
162
+ }
163
+
164
+ function habr1() {
165
+ var v_1;
166
+ while (true) {
167
+ v_1 = sbp.cursor;
168
+ if (sbp.in_grouping(g_V1, 97, 246))
169
+ break;
170
+ sbp.cursor = v_1;
171
+ if (v_1 >= sbp.limit)
172
+ return true;
173
+ sbp.cursor++;
174
+ }
175
+ sbp.cursor = v_1;
176
+ while (!sbp.out_grouping(g_V1, 97, 246)) {
177
+ if (sbp.cursor >= sbp.limit)
178
+ return true;
179
+ sbp.cursor++;
180
+ }
181
+ return false;
182
+ }
183
+
184
+ function r_R2() {
185
+ return I_p2 <= sbp.cursor;
186
+ }
187
+
188
+ function r_particle_etc() {
189
+ var among_var, v_1;
190
+ if (sbp.cursor >= I_p1) {
191
+ v_1 = sbp.limit_backward;
192
+ sbp.limit_backward = I_p1;
193
+ sbp.ket = sbp.cursor;
194
+ among_var = sbp.find_among_b(a_0, 10);
195
+ if (among_var) {
196
+ sbp.bra = sbp.cursor;
197
+ sbp.limit_backward = v_1;
198
+ switch (among_var) {
199
+ case 1:
200
+ if (!sbp.in_grouping_b(g_particle_end, 97, 246))
201
+ return;
202
+ break;
203
+ case 2:
204
+ if (!r_R2())
205
+ return;
206
+ break;
207
+ }
208
+ sbp.slice_del();
209
+ } else
210
+ sbp.limit_backward = v_1;
211
+ }
212
+ }
213
+
214
+ function r_possessive() {
215
+ var among_var, v_1, v_2;
216
+ if (sbp.cursor >= I_p1) {
217
+ v_1 = sbp.limit_backward;
218
+ sbp.limit_backward = I_p1;
219
+ sbp.ket = sbp.cursor;
220
+ among_var = sbp.find_among_b(a_4, 9);
221
+ if (among_var) {
222
+ sbp.bra = sbp.cursor;
223
+ sbp.limit_backward = v_1;
224
+ switch (among_var) {
225
+ case 1:
226
+ v_2 = sbp.limit - sbp.cursor;
227
+ if (!sbp.eq_s_b(1, "k")) {
228
+ sbp.cursor = sbp.limit - v_2;
229
+ sbp.slice_del();
230
+ }
231
+ break;
232
+ case 2:
233
+ sbp.slice_del();
234
+ sbp.ket = sbp.cursor;
235
+ if (sbp.eq_s_b(3, "kse")) {
236
+ sbp.bra = sbp.cursor;
237
+ sbp.slice_from("ksi");
238
+ }
239
+ break;
240
+ case 3:
241
+ sbp.slice_del();
242
+ break;
243
+ case 4:
244
+ if (sbp.find_among_b(a_1, 6))
245
+ sbp.slice_del();
246
+ break;
247
+ case 5:
248
+ if (sbp.find_among_b(a_2, 6))
249
+ sbp.slice_del();
250
+ break;
251
+ case 6:
252
+ if (sbp.find_among_b(a_3, 2))
253
+ sbp.slice_del();
254
+ break;
255
+ }
256
+ } else
257
+ sbp.limit_backward = v_1;
258
+ }
259
+ }
260
+
261
+ function r_LONG() {
262
+ return sbp.find_among_b(a_5, 7);
263
+ }
264
+
265
+ function r_VI() {
266
+ return sbp.eq_s_b(1, "i") && sbp.in_grouping_b(g_V2, 97, 246);
267
+ }
268
+
269
+ function r_case_ending() {
270
+ var among_var, v_1, v_2;
271
+ if (sbp.cursor >= I_p1) {
272
+ v_1 = sbp.limit_backward;
273
+ sbp.limit_backward = I_p1;
274
+ sbp.ket = sbp.cursor;
275
+ among_var = sbp.find_among_b(a_6, 30);
276
+ if (among_var) {
277
+ sbp.bra = sbp.cursor;
278
+ sbp.limit_backward = v_1;
279
+ switch (among_var) {
280
+ case 1:
281
+ if (!sbp.eq_s_b(1, "a"))
282
+ return;
283
+ break;
284
+ case 2:
285
+ case 9:
286
+ if (!sbp.eq_s_b(1, "e"))
287
+ return;
288
+ break;
289
+ case 3:
290
+ if (!sbp.eq_s_b(1, "i"))
291
+ return;
292
+ break;
293
+ case 4:
294
+ if (!sbp.eq_s_b(1, "o"))
295
+ return;
296
+ break;
297
+ case 5:
298
+ if (!sbp.eq_s_b(1, "\u00E4"))
299
+ return;
300
+ break;
301
+ case 6:
302
+ if (!sbp.eq_s_b(1, "\u00F6"))
303
+ return;
304
+ break;
305
+ case 7:
306
+ v_2 = sbp.limit - sbp.cursor;
307
+ if (!r_LONG()) {
308
+ sbp.cursor = sbp.limit - v_2;
309
+ if (!sbp.eq_s_b(2, "ie")) {
310
+ sbp.cursor = sbp.limit - v_2;
311
+ break;
312
+ }
313
+ }
314
+ sbp.cursor = sbp.limit - v_2;
315
+ if (sbp.cursor <= sbp.limit_backward) {
316
+ sbp.cursor = sbp.limit - v_2;
317
+ break;
318
+ }
319
+ sbp.cursor--;
320
+ sbp.bra = sbp.cursor;
321
+ break;
322
+ case 8:
323
+ if (!sbp.in_grouping_b(g_V1, 97, 246) || !sbp.out_grouping_b(g_V1, 97, 246))
324
+ return;
325
+ break;
326
+ }
327
+ sbp.slice_del();
328
+ B_ending_removed = true;
329
+ } else
330
+ sbp.limit_backward = v_1;
331
+ }
332
+ }
333
+
334
+ function r_other_endings() {
335
+ var among_var, v_1, v_2;
336
+ if (sbp.cursor >= I_p2) {
337
+ v_1 = sbp.limit_backward;
338
+ sbp.limit_backward = I_p2;
339
+ sbp.ket = sbp.cursor;
340
+ among_var = sbp.find_among_b(a_7, 14);
341
+ if (among_var) {
342
+ sbp.bra = sbp.cursor;
343
+ sbp.limit_backward = v_1;
344
+ if (among_var == 1) {
345
+ v_2 = sbp.limit - sbp.cursor;
346
+ if (sbp.eq_s_b(2, "po"))
347
+ return;
348
+ sbp.cursor = sbp.limit - v_2;
349
+ }
350
+ sbp.slice_del();
351
+ } else
352
+ sbp.limit_backward = v_1;
353
+ }
354
+ }
355
+
356
+ function r_i_plural() {
357
+ var v_1;
358
+ if (sbp.cursor >= I_p1) {
359
+ v_1 = sbp.limit_backward;
360
+ sbp.limit_backward = I_p1;
361
+ sbp.ket = sbp.cursor;
362
+ if (sbp.find_among_b(a_8, 2)) {
363
+ sbp.bra = sbp.cursor;
364
+ sbp.limit_backward = v_1;
365
+ sbp.slice_del();
366
+ } else
367
+ sbp.limit_backward = v_1;
368
+ }
369
+ }
370
+
371
+ function r_t_plural() {
372
+ var among_var, v_1, v_2, v_3, v_4, v_5;
373
+ if (sbp.cursor >= I_p1) {
374
+ v_1 = sbp.limit_backward;
375
+ sbp.limit_backward = I_p1;
376
+ sbp.ket = sbp.cursor;
377
+ if (sbp.eq_s_b(1, "t")) {
378
+ sbp.bra = sbp.cursor;
379
+ v_2 = sbp.limit - sbp.cursor;
380
+ if (sbp.in_grouping_b(g_V1, 97, 246)) {
381
+ sbp.cursor = sbp.limit - v_2;
382
+ sbp.slice_del();
383
+ sbp.limit_backward = v_1;
384
+ v_3 = sbp.limit - sbp.cursor;
385
+ if (sbp.cursor >= I_p2) {
386
+ sbp.cursor = I_p2;
387
+ v_4 = sbp.limit_backward;
388
+ sbp.limit_backward = sbp.cursor;
389
+ sbp.cursor = sbp.limit - v_3;
390
+ sbp.ket = sbp.cursor;
391
+ among_var = sbp.find_among_b(a_9, 2);
392
+ if (among_var) {
393
+ sbp.bra = sbp.cursor;
394
+ sbp.limit_backward = v_4;
395
+ if (among_var == 1) {
396
+ v_5 = sbp.limit - sbp.cursor;
397
+ if (sbp.eq_s_b(2, "po"))
398
+ return;
399
+ sbp.cursor = sbp.limit - v_5;
400
+ }
401
+ sbp.slice_del();
402
+ return;
403
+ }
404
+ }
405
+ }
406
+ }
407
+ sbp.limit_backward = v_1;
408
+ }
409
+ }
410
+
411
+ function r_tidy() {
412
+ var v_1, v_2, v_3, v_4;
413
+ if (sbp.cursor >= I_p1) {
414
+ v_1 = sbp.limit_backward;
415
+ sbp.limit_backward = I_p1;
416
+ v_2 = sbp.limit - sbp.cursor;
417
+ if (r_LONG()) {
418
+ sbp.cursor = sbp.limit - v_2;
419
+ sbp.ket = sbp.cursor;
420
+ if (sbp.cursor > sbp.limit_backward) {
421
+ sbp.cursor--;
422
+ sbp.bra = sbp.cursor;
423
+ sbp.slice_del();
424
+ }
425
+ }
426
+ sbp.cursor = sbp.limit - v_2;
427
+ sbp.ket = sbp.cursor;
428
+ if (sbp.in_grouping_b(g_AEI, 97, 228)) {
429
+ sbp.bra = sbp.cursor;
430
+ if (sbp.out_grouping_b(g_V1, 97, 246))
431
+ sbp.slice_del();
432
+ }
433
+ sbp.cursor = sbp.limit - v_2;
434
+ sbp.ket = sbp.cursor;
435
+ if (sbp.eq_s_b(1, "j")) {
436
+ sbp.bra = sbp.cursor;
437
+ v_3 = sbp.limit - sbp.cursor;
438
+ if (!sbp.eq_s_b(1, "o")) {
439
+ sbp.cursor = sbp.limit - v_3;
440
+ if (sbp.eq_s_b(1, "u"))
441
+ sbp.slice_del();
442
+ } else
443
+ sbp.slice_del();
444
+ }
445
+ sbp.cursor = sbp.limit - v_2;
446
+ sbp.ket = sbp.cursor;
447
+ if (sbp.eq_s_b(1, "o")) {
448
+ sbp.bra = sbp.cursor;
449
+ if (sbp.eq_s_b(1, "j"))
450
+ sbp.slice_del();
451
+ }
452
+ sbp.cursor = sbp.limit - v_2;
453
+ sbp.limit_backward = v_1;
454
+ while (true) {
455
+ v_4 = sbp.limit - sbp.cursor;
456
+ if (sbp.out_grouping_b(g_V1, 97, 246)) {
457
+ sbp.cursor = sbp.limit - v_4;
458
+ break;
459
+ }
460
+ sbp.cursor = sbp.limit - v_4;
461
+ if (sbp.cursor <= sbp.limit_backward)
462
+ return;
463
+ sbp.cursor--;
464
+ }
465
+ sbp.ket = sbp.cursor;
466
+ if (sbp.cursor > sbp.limit_backward) {
467
+ sbp.cursor--;
468
+ sbp.bra = sbp.cursor;
469
+ S_x = sbp.slice_to();
470
+ if (sbp.eq_v_b(S_x))
471
+ sbp.slice_del();
472
+ }
473
+ }
474
+ }
475
+ this.stem = function() {
476
+ var v_1 = sbp.cursor;
477
+ r_mark_regions();
478
+ B_ending_removed = false;
479
+ sbp.limit_backward = v_1;
480
+ sbp.cursor = sbp.limit;
481
+ r_particle_etc();
482
+ sbp.cursor = sbp.limit;
483
+ r_possessive();
484
+ sbp.cursor = sbp.limit;
485
+ r_case_ending();
486
+ sbp.cursor = sbp.limit;
487
+ r_other_endings();
488
+ sbp.cursor = sbp.limit;
489
+ if (B_ending_removed) {
490
+ r_i_plural();
491
+ sbp.cursor = sbp.limit;
492
+ } else {
493
+ sbp.cursor = sbp.limit;
494
+ r_t_plural();
495
+ sbp.cursor = sbp.limit;
496
+ }
497
+ r_tidy();
498
+ return true;
499
+ }
500
+ };
501
+
502
+ /* and return a function that stems a word for the current locale */
503
+ return function(word) {
504
+ st.setCurrent(word);
505
+ st.stem();
506
+ return st.getCurrent();
507
+ }
508
+ })();
509
+
510
+ lunr.Pipeline.registerFunction(lunr.fi.stemmer, 'stemmer-fi');
511
+
512
+ /* stop word filter function */
513
+ lunr.fi.stopWordFilter = function(token) {
514
+ if (lunr.fi.stopWordFilter.stopWords.indexOf(token) === -1) {
515
+ return token;
516
+ }
517
+ };
518
+
519
+ lunr.fi.stopWordFilter.stopWords = new lunr.SortedSet();
520
+ lunr.fi.stopWordFilter.stopWords.length = 236;
521
+
522
+ // The space at the beginning is crucial: It marks the empty string
523
+ // as a stop word. lunr.js crashes during search when documents
524
+ // processed by the pipeline still contain the empty string.
525
+ lunr.fi.stopWordFilter.stopWords.elements = ' 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(' ');
526
+
527
+ lunr.Pipeline.registerFunction(lunr.fi.stopWordFilter, 'stopWordFilter-fi');
528
+ };
529
+ }))