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,559 @@
1
+ /*!
2
+ * Lunr languages, `Portuguese` 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.pt = function() {
57
+ this.pipeline.reset();
58
+ this.pipeline.add(
59
+ lunr.pt.stopWordFilter,
60
+ lunr.pt.stemmer
61
+ );
62
+ };
63
+
64
+ /* lunr stemmer function */
65
+ lunr.pt.stemmer = (function() {
66
+ /* create the wrapped stemmer object */
67
+ var Among = lunr.stemmerSupport.Among,
68
+ SnowballProgram = lunr.stemmerSupport.SnowballProgram,
69
+ st = new function PortugueseStemmer() {
70
+ var a_0 = [new Among("", -1, 3), new Among("\u00E3", 0, 1),
71
+ new Among("\u00F5", 0, 2)
72
+ ],
73
+ a_1 = [new Among("", -1, 3),
74
+ new Among("a~", 0, 1), new Among("o~", 0, 2)
75
+ ],
76
+ a_2 = [
77
+ new Among("ic", -1, -1), new Among("ad", -1, -1),
78
+ new Among("os", -1, -1), new Among("iv", -1, 1)
79
+ ],
80
+ a_3 = [
81
+ new Among("ante", -1, 1), new Among("avel", -1, 1),
82
+ new Among("\u00EDvel", -1, 1)
83
+ ],
84
+ a_4 = [new Among("ic", -1, 1),
85
+ new Among("abil", -1, 1), new Among("iv", -1, 1)
86
+ ],
87
+ a_5 = [
88
+ new Among("ica", -1, 1), new Among("\u00E2ncia", -1, 1),
89
+ new Among("\u00EAncia", -1, 4), new Among("ira", -1, 9),
90
+ new Among("adora", -1, 1), new Among("osa", -1, 1),
91
+ new Among("ista", -1, 1), new Among("iva", -1, 8),
92
+ new Among("eza", -1, 1), new Among("log\u00EDa", -1, 2),
93
+ new Among("idade", -1, 7), new Among("ante", -1, 1),
94
+ new Among("mente", -1, 6), new Among("amente", 12, 5),
95
+ new Among("\u00E1vel", -1, 1), new Among("\u00EDvel", -1, 1),
96
+ new Among("uci\u00F3n", -1, 3), new Among("ico", -1, 1),
97
+ new Among("ismo", -1, 1), new Among("oso", -1, 1),
98
+ new Among("amento", -1, 1), new Among("imento", -1, 1),
99
+ new Among("ivo", -1, 8), new Among("a\u00E7a~o", -1, 1),
100
+ new Among("ador", -1, 1), new Among("icas", -1, 1),
101
+ new Among("\u00EAncias", -1, 4), new Among("iras", -1, 9),
102
+ new Among("adoras", -1, 1), new Among("osas", -1, 1),
103
+ new Among("istas", -1, 1), new Among("ivas", -1, 8),
104
+ new Among("ezas", -1, 1), new Among("log\u00EDas", -1, 2),
105
+ new Among("idades", -1, 7), new Among("uciones", -1, 3),
106
+ new Among("adores", -1, 1), new Among("antes", -1, 1),
107
+ new Among("a\u00E7o~es", -1, 1), new Among("icos", -1, 1),
108
+ new Among("ismos", -1, 1), new Among("osos", -1, 1),
109
+ new Among("amentos", -1, 1), new Among("imentos", -1, 1),
110
+ new Among("ivos", -1, 8)
111
+ ],
112
+ a_6 = [new Among("ada", -1, 1),
113
+ new Among("ida", -1, 1), new Among("ia", -1, 1),
114
+ new Among("aria", 2, 1), new Among("eria", 2, 1),
115
+ new Among("iria", 2, 1), new Among("ara", -1, 1),
116
+ new Among("era", -1, 1), new Among("ira", -1, 1),
117
+ new Among("ava", -1, 1), new Among("asse", -1, 1),
118
+ new Among("esse", -1, 1), new Among("isse", -1, 1),
119
+ new Among("aste", -1, 1), new Among("este", -1, 1),
120
+ new Among("iste", -1, 1), new Among("ei", -1, 1),
121
+ new Among("arei", 16, 1), new Among("erei", 16, 1),
122
+ new Among("irei", 16, 1), new Among("am", -1, 1),
123
+ new Among("iam", 20, 1), new Among("ariam", 21, 1),
124
+ new Among("eriam", 21, 1), new Among("iriam", 21, 1),
125
+ new Among("aram", 20, 1), new Among("eram", 20, 1),
126
+ new Among("iram", 20, 1), new Among("avam", 20, 1),
127
+ new Among("em", -1, 1), new Among("arem", 29, 1),
128
+ new Among("erem", 29, 1), new Among("irem", 29, 1),
129
+ new Among("assem", 29, 1), new Among("essem", 29, 1),
130
+ new Among("issem", 29, 1), new Among("ado", -1, 1),
131
+ new Among("ido", -1, 1), new Among("ando", -1, 1),
132
+ new Among("endo", -1, 1), new Among("indo", -1, 1),
133
+ new Among("ara~o", -1, 1), new Among("era~o", -1, 1),
134
+ new Among("ira~o", -1, 1), new Among("ar", -1, 1),
135
+ new Among("er", -1, 1), new Among("ir", -1, 1),
136
+ new Among("as", -1, 1), new Among("adas", 47, 1),
137
+ new Among("idas", 47, 1), new Among("ias", 47, 1),
138
+ new Among("arias", 50, 1), new Among("erias", 50, 1),
139
+ new Among("irias", 50, 1), new Among("aras", 47, 1),
140
+ new Among("eras", 47, 1), new Among("iras", 47, 1),
141
+ new Among("avas", 47, 1), new Among("es", -1, 1),
142
+ new Among("ardes", 58, 1), new Among("erdes", 58, 1),
143
+ new Among("irdes", 58, 1), new Among("ares", 58, 1),
144
+ new Among("eres", 58, 1), new Among("ires", 58, 1),
145
+ new Among("asses", 58, 1), new Among("esses", 58, 1),
146
+ new Among("isses", 58, 1), new Among("astes", 58, 1),
147
+ new Among("estes", 58, 1), new Among("istes", 58, 1),
148
+ new Among("is", -1, 1), new Among("ais", 71, 1),
149
+ new Among("eis", 71, 1), new Among("areis", 73, 1),
150
+ new Among("ereis", 73, 1), new Among("ireis", 73, 1),
151
+ new Among("\u00E1reis", 73, 1), new Among("\u00E9reis", 73, 1),
152
+ new Among("\u00EDreis", 73, 1), new Among("\u00E1sseis", 73, 1),
153
+ new Among("\u00E9sseis", 73, 1), new Among("\u00EDsseis", 73, 1),
154
+ new Among("\u00E1veis", 73, 1), new Among("\u00EDeis", 73, 1),
155
+ new Among("ar\u00EDeis", 84, 1), new Among("er\u00EDeis", 84, 1),
156
+ new Among("ir\u00EDeis", 84, 1), new Among("ados", -1, 1),
157
+ new Among("idos", -1, 1), new Among("amos", -1, 1),
158
+ new Among("\u00E1ramos", 90, 1), new Among("\u00E9ramos", 90, 1),
159
+ new Among("\u00EDramos", 90, 1), new Among("\u00E1vamos", 90, 1),
160
+ new Among("\u00EDamos", 90, 1), new Among("ar\u00EDamos", 95, 1),
161
+ new Among("er\u00EDamos", 95, 1), new Among("ir\u00EDamos", 95, 1),
162
+ new Among("emos", -1, 1), new Among("aremos", 99, 1),
163
+ new Among("eremos", 99, 1), new Among("iremos", 99, 1),
164
+ new Among("\u00E1ssemos", 99, 1), new Among("\u00EAssemos", 99, 1),
165
+ new Among("\u00EDssemos", 99, 1), new Among("imos", -1, 1),
166
+ new Among("armos", -1, 1), new Among("ermos", -1, 1),
167
+ new Among("irmos", -1, 1), new Among("\u00E1mos", -1, 1),
168
+ new Among("ar\u00E1s", -1, 1), new Among("er\u00E1s", -1, 1),
169
+ new Among("ir\u00E1s", -1, 1), new Among("eu", -1, 1),
170
+ new Among("iu", -1, 1), new Among("ou", -1, 1),
171
+ new Among("ar\u00E1", -1, 1), new Among("er\u00E1", -1, 1),
172
+ new Among("ir\u00E1", -1, 1)
173
+ ],
174
+ a_7 = [new Among("a", -1, 1),
175
+ new Among("i", -1, 1), new Among("o", -1, 1),
176
+ new Among("os", -1, 1), new Among("\u00E1", -1, 1),
177
+ new Among("\u00ED", -1, 1), new Among("\u00F3", -1, 1)
178
+ ],
179
+ a_8 = [
180
+ new Among("e", -1, 1), new Among("\u00E7", -1, 2),
181
+ new Among("\u00E9", -1, 1), new Among("\u00EA", -1, 1)
182
+ ],
183
+ g_v = [17,
184
+ 65, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 19, 12, 2
185
+ ],
186
+ I_p2, I_p1, I_pV, sbp = new SnowballProgram();
187
+ this.setCurrent = function(word) {
188
+ sbp.setCurrent(word);
189
+ };
190
+ this.getCurrent = function() {
191
+ return sbp.getCurrent();
192
+ };
193
+
194
+ function r_prelude() {
195
+ var among_var;
196
+ while (true) {
197
+ sbp.bra = sbp.cursor;
198
+ among_var = sbp.find_among(a_0, 3);
199
+ if (among_var) {
200
+ sbp.ket = sbp.cursor;
201
+ switch (among_var) {
202
+ case 1:
203
+ sbp.slice_from("a~");
204
+ continue;
205
+ case 2:
206
+ sbp.slice_from("o~");
207
+ continue;
208
+ case 3:
209
+ if (sbp.cursor >= sbp.limit)
210
+ break;
211
+ sbp.cursor++;
212
+ continue;
213
+ }
214
+ }
215
+ break;
216
+ }
217
+ }
218
+
219
+ function habr2() {
220
+ if (sbp.out_grouping(g_v, 97, 250)) {
221
+ while (!sbp.in_grouping(g_v, 97, 250)) {
222
+ if (sbp.cursor >= sbp.limit)
223
+ return true;
224
+ sbp.cursor++;
225
+ }
226
+ return false;
227
+ }
228
+ return true;
229
+ }
230
+
231
+ function habr3() {
232
+ if (sbp.in_grouping(g_v, 97, 250)) {
233
+ while (!sbp.out_grouping(g_v, 97, 250)) {
234
+ if (sbp.cursor >= sbp.limit)
235
+ return false;
236
+ sbp.cursor++;
237
+ }
238
+ }
239
+ I_pV = sbp.cursor;
240
+ return true;
241
+ }
242
+
243
+ function habr4() {
244
+ var v_1 = sbp.cursor,
245
+ v_2, v_3;
246
+ if (sbp.in_grouping(g_v, 97, 250)) {
247
+ v_2 = sbp.cursor;
248
+ if (habr2()) {
249
+ sbp.cursor = v_2;
250
+ if (habr3())
251
+ return;
252
+ } else
253
+ I_pV = sbp.cursor;
254
+ }
255
+ sbp.cursor = v_1;
256
+ if (sbp.out_grouping(g_v, 97, 250)) {
257
+ v_3 = sbp.cursor;
258
+ if (habr2()) {
259
+ sbp.cursor = v_3;
260
+ if (!sbp.in_grouping(g_v, 97, 250) || sbp.cursor >= sbp.limit)
261
+ return;
262
+ sbp.cursor++;
263
+ }
264
+ I_pV = sbp.cursor;
265
+ }
266
+ }
267
+
268
+ function habr5() {
269
+ while (!sbp.in_grouping(g_v, 97, 250)) {
270
+ if (sbp.cursor >= sbp.limit)
271
+ return false;
272
+ sbp.cursor++;
273
+ }
274
+ while (!sbp.out_grouping(g_v, 97, 250)) {
275
+ if (sbp.cursor >= sbp.limit)
276
+ return false;
277
+ sbp.cursor++;
278
+ }
279
+ return true;
280
+ }
281
+
282
+ function r_mark_regions() {
283
+ var v_1 = sbp.cursor;
284
+ I_pV = sbp.limit;
285
+ I_p1 = I_pV;
286
+ I_p2 = I_pV;
287
+ habr4();
288
+ sbp.cursor = v_1;
289
+ if (habr5()) {
290
+ I_p1 = sbp.cursor;
291
+ if (habr5())
292
+ I_p2 = sbp.cursor;
293
+ }
294
+ }
295
+
296
+ function r_postlude() {
297
+ var among_var;
298
+ while (true) {
299
+ sbp.bra = sbp.cursor;
300
+ among_var = sbp.find_among(a_1, 3);
301
+ if (among_var) {
302
+ sbp.ket = sbp.cursor;
303
+ switch (among_var) {
304
+ case 1:
305
+ sbp.slice_from("\u00E3");
306
+ continue;
307
+ case 2:
308
+ sbp.slice_from("\u00F5");
309
+ continue;
310
+ case 3:
311
+ if (sbp.cursor >= sbp.limit)
312
+ break;
313
+ sbp.cursor++;
314
+ continue;
315
+ }
316
+ }
317
+ break;
318
+ }
319
+ }
320
+
321
+ function r_RV() {
322
+ return I_pV <= sbp.cursor;
323
+ }
324
+
325
+ function r_R1() {
326
+ return I_p1 <= sbp.cursor;
327
+ }
328
+
329
+ function r_R2() {
330
+ return I_p2 <= sbp.cursor;
331
+ }
332
+
333
+ function r_standard_suffix() {
334
+ var among_var;
335
+ sbp.ket = sbp.cursor;
336
+ among_var = sbp.find_among_b(a_5, 45);
337
+ if (!among_var)
338
+ return false;
339
+ sbp.bra = sbp.cursor;
340
+ switch (among_var) {
341
+ case 1:
342
+ if (!r_R2())
343
+ return false;
344
+ sbp.slice_del();
345
+ break;
346
+ case 2:
347
+ if (!r_R2())
348
+ return false;
349
+ sbp.slice_from("log");
350
+ break;
351
+ case 3:
352
+ if (!r_R2())
353
+ return false;
354
+ sbp.slice_from("u");
355
+ break;
356
+ case 4:
357
+ if (!r_R2())
358
+ return false;
359
+ sbp.slice_from("ente");
360
+ break;
361
+ case 5:
362
+ if (!r_R1())
363
+ return false;
364
+ sbp.slice_del();
365
+ sbp.ket = sbp.cursor;
366
+ among_var = sbp.find_among_b(a_2, 4);
367
+ if (among_var) {
368
+ sbp.bra = sbp.cursor;
369
+ if (r_R2()) {
370
+ sbp.slice_del();
371
+ if (among_var == 1) {
372
+ sbp.ket = sbp.cursor;
373
+ if (sbp.eq_s_b(2, "at")) {
374
+ sbp.bra = sbp.cursor;
375
+ if (r_R2())
376
+ sbp.slice_del();
377
+ }
378
+ }
379
+ }
380
+ }
381
+ break;
382
+ case 6:
383
+ if (!r_R2())
384
+ return false;
385
+ sbp.slice_del();
386
+ sbp.ket = sbp.cursor;
387
+ among_var = sbp.find_among_b(a_3, 3);
388
+ if (among_var) {
389
+ sbp.bra = sbp.cursor;
390
+ if (among_var == 1)
391
+ if (r_R2())
392
+ sbp.slice_del();
393
+ }
394
+ break;
395
+ case 7:
396
+ if (!r_R2())
397
+ return false;
398
+ sbp.slice_del();
399
+ sbp.ket = sbp.cursor;
400
+ among_var = sbp.find_among_b(a_4, 3);
401
+ if (among_var) {
402
+ sbp.bra = sbp.cursor;
403
+ if (among_var == 1)
404
+ if (r_R2())
405
+ sbp.slice_del();
406
+ }
407
+ break;
408
+ case 8:
409
+ if (!r_R2())
410
+ return false;
411
+ sbp.slice_del();
412
+ sbp.ket = sbp.cursor;
413
+ if (sbp.eq_s_b(2, "at")) {
414
+ sbp.bra = sbp.cursor;
415
+ if (r_R2())
416
+ sbp.slice_del();
417
+ }
418
+ break;
419
+ case 9:
420
+ if (!r_RV() || !sbp.eq_s_b(1, "e"))
421
+ return false;
422
+ sbp.slice_from("ir");
423
+ break;
424
+ }
425
+ return true;
426
+ }
427
+
428
+ function r_verb_suffix() {
429
+ var among_var, v_1;
430
+ if (sbp.cursor >= I_pV) {
431
+ v_1 = sbp.limit_backward;
432
+ sbp.limit_backward = I_pV;
433
+ sbp.ket = sbp.cursor;
434
+ among_var = sbp.find_among_b(a_6, 120);
435
+ if (among_var) {
436
+ sbp.bra = sbp.cursor;
437
+ if (among_var == 1)
438
+ sbp.slice_del();
439
+ sbp.limit_backward = v_1;
440
+ return true;
441
+ }
442
+ sbp.limit_backward = v_1;
443
+ }
444
+ return false;
445
+ }
446
+
447
+ function r_residual_suffix() {
448
+ var among_var;
449
+ sbp.ket = sbp.cursor;
450
+ among_var = sbp.find_among_b(a_7, 7);
451
+ if (among_var) {
452
+ sbp.bra = sbp.cursor;
453
+ if (among_var == 1)
454
+ if (r_RV())
455
+ sbp.slice_del();
456
+ }
457
+ }
458
+
459
+ function habr6(c1, c2) {
460
+ if (sbp.eq_s_b(1, c1)) {
461
+ sbp.bra = sbp.cursor;
462
+ var v_1 = sbp.limit - sbp.cursor;
463
+ if (sbp.eq_s_b(1, c2)) {
464
+ sbp.cursor = sbp.limit - v_1;
465
+ if (r_RV())
466
+ sbp.slice_del();
467
+ return false;
468
+ }
469
+ }
470
+ return true;
471
+ }
472
+
473
+ function r_residual_form() {
474
+ var among_var, v_1, v_2, v_3;
475
+ sbp.ket = sbp.cursor;
476
+ among_var = sbp.find_among_b(a_8, 4);
477
+ if (among_var) {
478
+ sbp.bra = sbp.cursor;
479
+ switch (among_var) {
480
+ case 1:
481
+ if (r_RV()) {
482
+ sbp.slice_del();
483
+ sbp.ket = sbp.cursor;
484
+ v_1 = sbp.limit - sbp.cursor;
485
+ if (habr6("u", "g"))
486
+ habr6("i", "c")
487
+ }
488
+ break;
489
+ case 2:
490
+ sbp.slice_from("c");
491
+ break;
492
+ }
493
+ }
494
+ }
495
+
496
+ function habr1() {
497
+ if (!r_standard_suffix()) {
498
+ sbp.cursor = sbp.limit;
499
+ if (!r_verb_suffix()) {
500
+ sbp.cursor = sbp.limit;
501
+ r_residual_suffix();
502
+ return;
503
+ }
504
+ }
505
+ sbp.cursor = sbp.limit;
506
+ sbp.ket = sbp.cursor;
507
+ if (sbp.eq_s_b(1, "i")) {
508
+ sbp.bra = sbp.cursor;
509
+ if (sbp.eq_s_b(1, "c")) {
510
+ sbp.cursor = sbp.limit;
511
+ if (r_RV())
512
+ sbp.slice_del();
513
+ }
514
+ }
515
+ }
516
+ this.stem = function() {
517
+ var v_1 = sbp.cursor;
518
+ r_prelude();
519
+ sbp.cursor = v_1;
520
+ r_mark_regions();
521
+ sbp.limit_backward = v_1;
522
+ sbp.cursor = sbp.limit;
523
+ habr1();
524
+ sbp.cursor = sbp.limit;
525
+ r_residual_form();
526
+ sbp.cursor = sbp.limit_backward;
527
+ r_postlude();
528
+ return true;
529
+ }
530
+ };
531
+
532
+ /* and return a function that stems a word for the current locale */
533
+ return function(word) {
534
+ st.setCurrent(word);
535
+ st.stem();
536
+ return st.getCurrent();
537
+ }
538
+ })();
539
+
540
+ lunr.Pipeline.registerFunction(lunr.pt.stemmer, 'stemmer-pt');
541
+
542
+ /* stop word filter function */
543
+ lunr.pt.stopWordFilter = function(token) {
544
+ if (lunr.pt.stopWordFilter.stopWords.indexOf(token) === -1) {
545
+ return token;
546
+ }
547
+ };
548
+
549
+ lunr.pt.stopWordFilter.stopWords = new lunr.SortedSet();
550
+ lunr.pt.stopWordFilter.stopWords.length = 204;
551
+
552
+ // The space at the beginning is crucial: It marks the empty string
553
+ // as a stop word. lunr.js crashes during search when documents
554
+ // processed by the pipeline still contain the empty string.
555
+ lunr.pt.stopWordFilter.stopWords.elements = ' a ao aos aquela aquelas aquele aqueles aquilo as até com como da das de dela delas dele deles depois do dos e ela elas ele eles em entre era eram essa essas esse esses esta estamos estas estava estavam este esteja estejam estejamos estes esteve estive estivemos estiver estivera estiveram estiverem estivermos estivesse estivessem estivéramos estivéssemos estou está estávamos estão eu foi fomos for fora foram forem formos fosse fossem fui fôramos fôssemos haja hajam hajamos havemos hei houve houvemos houver houvera houveram houverei houverem houveremos houveria houveriam houvermos houverá houverão houveríamos houvesse houvessem houvéramos houvéssemos há hão isso isto já lhe lhes mais mas me mesmo meu meus minha minhas muito na nas nem no nos nossa nossas nosso nossos num numa não nós o os ou para pela pelas pelo pelos por qual quando que quem se seja sejam sejamos sem serei seremos seria seriam será serão seríamos seu seus somos sou sua suas são só também te tem temos tenha tenham tenhamos tenho terei teremos teria teriam terá terão teríamos teu teus teve tinha tinham tive tivemos tiver tivera tiveram tiverem tivermos tivesse tivessem tivéramos tivéssemos tu tua tuas tém tínhamos um uma você vocês vos à às éramos'.split(' ');
556
+
557
+ lunr.Pipeline.registerFunction(lunr.pt.stopWordFilter, 'stopWordFilter-pt');
558
+ };
559
+ }))