Debian Codegraph @

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

raw
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.trimmer,
60 lunr.pt.stopWordFilter,
61 lunr.pt.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.pt.stemmer)
70 }
71 };
72
73 /* lunr trimmer function */
74 lunr.pt.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.pt.trimmer = lunr.trimmerSupport.generateTrimmer(lunr.pt.wordCharacters);
76
77 lunr.Pipeline.registerFunction(lunr.pt.trimmer, 'trimmer-pt');
78
79 /* lunr stemmer function */
80 lunr.pt.stemmer = (function() {
81 /* create the wrapped stemmer object */
82 var Among = lunr.stemmerSupport.Among,
83 SnowballProgram = lunr.stemmerSupport.SnowballProgram,
84 st = new function PortugueseStemmer() {
85 var a_0 = [new Among("", -1, 3), new Among("\u00E3", 0, 1),
86 new Among("\u00F5", 0, 2)
87 ],
88 a_1 = [new Among("", -1, 3),
89 new Among("a~", 0, 1), new Among("o~", 0, 2)
90 ],
91 a_2 = [
92 new Among("ic", -1, -1), new Among("ad", -1, -1),
93 new Among("os", -1, -1), new Among("iv", -1, 1)
94 ],
95 a_3 = [
96 new Among("ante", -1, 1), new Among("avel", -1, 1),
97 new Among("\u00EDvel", -1, 1)
98 ],
99 a_4 = [new Among("ic", -1, 1),
100 new Among("abil", -1, 1), new Among("iv", -1, 1)
101 ],
102 a_5 = [
103 new Among("ica", -1, 1), new Among("\u00E2ncia", -1, 1),
104 new Among("\u00EAncia", -1, 4), new Among("ira", -1, 9),
105 new Among("adora", -1, 1), new Among("osa", -1, 1),
106 new Among("ista", -1, 1), new Among("iva", -1, 8),
107 new Among("eza", -1, 1), new Among("log\u00EDa", -1, 2),
108 new Among("idade", -1, 7), new Among("ante", -1, 1),
109 new Among("mente", -1, 6), new Among("amente", 12, 5),
110 new Among("\u00E1vel", -1, 1), new Among("\u00EDvel", -1, 1),
111 new Among("uci\u00F3n", -1, 3), new Among("ico", -1, 1),
112 new Among("ismo", -1, 1), new Among("oso", -1, 1),
113 new Among("amento", -1, 1), new Among("imento", -1, 1),
114 new Among("ivo", -1, 8), new Among("a\u00E7a~o", -1, 1),
115 new Among("ador", -1, 1), new Among("icas", -1, 1),
116 new Among("\u00EAncias", -1, 4), new Among("iras", -1, 9),
117 new Among("adoras", -1, 1), new Among("osas", -1, 1),
118 new Among("istas", -1, 1), new Among("ivas", -1, 8),
119 new Among("ezas", -1, 1), new Among("log\u00EDas", -1, 2),
120 new Among("idades", -1, 7), new Among("uciones", -1, 3),
121 new Among("adores", -1, 1), new Among("antes", -1, 1),
122 new Among("a\u00E7o~es", -1, 1), new Among("icos", -1, 1),
123 new Among("ismos", -1, 1), new Among("osos", -1, 1),
124 new Among("amentos", -1, 1), new Among("imentos", -1, 1),
125 new Among("ivos", -1, 8)
126 ],
127 a_6 = [new Among("ada", -1, 1),
128 new Among("ida", -1, 1), new Among("ia", -1, 1),
129 new Among("aria", 2, 1), new Among("eria", 2, 1),
130 new Among("iria", 2, 1), new Among("ara", -1, 1),
131 new Among("era", -1, 1), new Among("ira", -1, 1),
132 new Among("ava", -1, 1), new Among("asse", -1, 1),
133 new Among("esse", -1, 1), new Among("isse", -1, 1),
134 new Among("aste", -1, 1), new Among("este", -1, 1),
135 new Among("iste", -1, 1), new Among("ei", -1, 1),
136 new Among("arei", 16, 1), new Among("erei", 16, 1),
137 new Among("irei", 16, 1), new Among("am", -1, 1),
138 new Among("iam", 20, 1), new Among("ariam", 21, 1),
139 new Among("eriam", 21, 1), new Among("iriam", 21, 1),
140 new Among("aram", 20, 1), new Among("eram", 20, 1),
141 new Among("iram", 20, 1), new Among("avam", 20, 1),
142 new Among("em", -1, 1), new Among("arem", 29, 1),
143 new Among("erem", 29, 1), new Among("irem", 29, 1),
144 new Among("assem", 29, 1), new Among("essem", 29, 1),
145 new Among("issem", 29, 1), new Among("ado", -1, 1),
146 new Among("ido", -1, 1), new Among("ando", -1, 1),
147 new Among("endo", -1, 1), new Among("indo", -1, 1),
148 new Among("ara~o", -1, 1), new Among("era~o", -1, 1),
149 new Among("ira~o", -1, 1), new Among("ar", -1, 1),
150 new Among("er", -1, 1), new Among("ir", -1, 1),
151 new Among("as", -1, 1), new Among("adas", 47, 1),
152 new Among("idas", 47, 1), new Among("ias", 47, 1),
153 new Among("arias", 50, 1), new Among("erias", 50, 1),
154 new Among("irias", 50, 1), new Among("aras", 47, 1),
155 new Among("eras", 47, 1), new Among("iras", 47, 1),
156 new Among("avas", 47, 1), new Among("es", -1, 1),
157 new Among("ardes", 58, 1), new Among("erdes", 58, 1),
158 new Among("irdes", 58, 1), new Among("ares", 58, 1),
159 new Among("eres", 58, 1), new Among("ires", 58, 1),
160 new Among("asses", 58, 1), new Among("esses", 58, 1),
161 new Among("isses", 58, 1), new Among("astes", 58, 1),
162 new Among("estes", 58, 1), new Among("istes", 58, 1),
163 new Among("is", -1, 1), new Among("ais", 71, 1),
164 new Among("eis", 71, 1), new Among("areis", 73, 1),
165 new Among("ereis", 73, 1), new Among("ireis", 73, 1),
166 new Among("\u00E1reis", 73, 1), new Among("\u00E9reis", 73, 1),
167 new Among("\u00EDreis", 73, 1), new Among("\u00E1sseis", 73, 1),
168 new Among("\u00E9sseis", 73, 1), new Among("\u00EDsseis", 73, 1),
169 new Among("\u00E1veis", 73, 1), new Among("\u00EDeis", 73, 1),
170 new Among("ar\u00EDeis", 84, 1), new Among("er\u00EDeis", 84, 1),
171 new Among("ir\u00EDeis", 84, 1), new Among("ados", -1, 1),
172 new Among("idos", -1, 1), new Among("amos", -1, 1),
173 new Among("\u00E1ramos", 90, 1), new Among("\u00E9ramos", 90, 1),
174 new Among("\u00EDramos", 90, 1), new Among("\u00E1vamos", 90, 1),
175 new Among("\u00EDamos", 90, 1), new Among("ar\u00EDamos", 95, 1),
176 new Among("er\u00EDamos", 95, 1), new Among("ir\u00EDamos", 95, 1),
177 new Among("emos", -1, 1), new Among("aremos", 99, 1),
178 new Among("eremos", 99, 1), new Among("iremos", 99, 1),
179 new Among("\u00E1ssemos", 99, 1), new Among("\u00EAssemos", 99, 1),
180 new Among("\u00EDssemos", 99, 1), new Among("imos", -1, 1),
181 new Among("armos", -1, 1), new Among("ermos", -1, 1),
182 new Among("irmos", -1, 1), new Among("\u00E1mos", -1, 1),
183 new Among("ar\u00E1s", -1, 1), new Among("er\u00E1s", -1, 1),
184 new Among("ir\u00E1s", -1, 1), new Among("eu", -1, 1),
185 new Among("iu", -1, 1), new Among("ou", -1, 1),
186 new Among("ar\u00E1", -1, 1), new Among("er\u00E1", -1, 1),
187 new Among("ir\u00E1", -1, 1)
188 ],
189 a_7 = [new Among("a", -1, 1),
190 new Among("i", -1, 1), new Among("o", -1, 1),
191 new Among("os", -1, 1), new Among("\u00E1", -1, 1),
192 new Among("\u00ED", -1, 1), new Among("\u00F3", -1, 1)
193 ],
194 a_8 = [
195 new Among("e", -1, 1), new Among("\u00E7", -1, 2),
196 new Among("\u00E9", -1, 1), new Among("\u00EA", -1, 1)
197 ],
198 g_v = [17,
199 65, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 19, 12, 2
200 ],
201 I_p2, I_p1, I_pV, sbp = new SnowballProgram();
202 this.setCurrent = function(word) {
203 sbp.setCurrent(word);
204 };
205 this.getCurrent = function() {
206 return sbp.getCurrent();
207 };
208
209 function r_prelude() {
210 var among_var;
211 while (true) {
212 sbp.bra = sbp.cursor;
213 among_var = sbp.find_among(a_0, 3);
214 if (among_var) {
215 sbp.ket = sbp.cursor;
216 switch (among_var) {
217 case 1:
218 sbp.slice_from("a~");
219 continue;
220 case 2:
221 sbp.slice_from("o~");
222 continue;
223 case 3:
224 if (sbp.cursor >= sbp.limit)
225 break;
226 sbp.cursor++;
227 continue;
228 }
229 }
230 break;
231 }
232 }
233
234 function habr2() {
235 if (sbp.out_grouping(g_v, 97, 250)) {
236 while (!sbp.in_grouping(g_v, 97, 250)) {
237 if (sbp.cursor >= sbp.limit)
238 return true;
239 sbp.cursor++;
240 }
241 return false;
242 }
243 return true;
244 }
245
246 function habr3() {
247 if (sbp.in_grouping(g_v, 97, 250)) {
248 while (!sbp.out_grouping(g_v, 97, 250)) {
249 if (sbp.cursor >= sbp.limit)
250 return false;
251 sbp.cursor++;
252 }
253 }
254 I_pV = sbp.cursor;
255 return true;
256 }
257
258 function habr4() {
259 var v_1 = sbp.cursor,
260 v_2, v_3;
261 if (sbp.in_grouping(g_v, 97, 250)) {
262 v_2 = sbp.cursor;
263 if (habr2()) {
264 sbp.cursor = v_2;
265 if (habr3())
266 return;
267 } else
268 I_pV = sbp.cursor;
269 }
270 sbp.cursor = v_1;
271 if (sbp.out_grouping(g_v, 97, 250)) {
272 v_3 = sbp.cursor;
273 if (habr2()) {
274 sbp.cursor = v_3;
275 if (!sbp.in_grouping(g_v, 97, 250) || sbp.cursor >= sbp.limit)
276 return;
277 sbp.cursor++;
278 }
279 I_pV = sbp.cursor;
280 }
281 }
282
283 function habr5() {
284 while (!sbp.in_grouping(g_v, 97, 250)) {
285 if (sbp.cursor >= sbp.limit)
286 return false;
287 sbp.cursor++;
288 }
289 while (!sbp.out_grouping(g_v, 97, 250)) {
290 if (sbp.cursor >= sbp.limit)
291 return false;
292 sbp.cursor++;
293 }
294 return true;
295 }
296
297 function r_mark_regions() {
298 var v_1 = sbp.cursor;
299 I_pV = sbp.limit;
300 I_p1 = I_pV;
301 I_p2 = I_pV;
302 habr4();
303 sbp.cursor = v_1;
304 if (habr5()) {
305 I_p1 = sbp.cursor;
306 if (habr5())
307 I_p2 = sbp.cursor;
308 }
309 }
310
311 function r_postlude() {
312 var among_var;
313 while (true) {
314 sbp.bra = sbp.cursor;
315 among_var = sbp.find_among(a_1, 3);
316 if (among_var) {
317 sbp.ket = sbp.cursor;
318 switch (among_var) {
319 case 1:
320 sbp.slice_from("\u00E3");
321 continue;
322 case 2:
323 sbp.slice_from("\u00F5");
324 continue;
325 case 3:
326 if (sbp.cursor >= sbp.limit)
327 break;
328 sbp.cursor++;
329 continue;
330 }
331 }
332 break;
333 }
334 }
335
336 function r_RV() {
337 return I_pV <= sbp.cursor;
338 }
339
340 function r_R1() {
341 return I_p1 <= sbp.cursor;
342 }
343
344 function r_R2() {
345 return I_p2 <= sbp.cursor;
346 }
347
348 function r_standard_suffix() {
349 var among_var;
350 sbp.ket = sbp.cursor;
351 among_var = sbp.find_among_b(a_5, 45);
352 if (!among_var)
353 return false;
354 sbp.bra = sbp.cursor;
355 switch (among_var) {
356 case 1:
357 if (!r_R2())
358 return false;
359 sbp.slice_del();
360 break;
361 case 2:
362 if (!r_R2())
363 return false;
364 sbp.slice_from("log");
365 break;
366 case 3:
367 if (!r_R2())
368 return false;
369 sbp.slice_from("u");
370 break;
371 case 4:
372 if (!r_R2())
373 return false;
374 sbp.slice_from("ente");
375 break;
376 case 5:
377 if (!r_R1())
378 return false;
379 sbp.slice_del();
380 sbp.ket = sbp.cursor;
381 among_var = sbp.find_among_b(a_2, 4);
382 if (among_var) {
383 sbp.bra = sbp.cursor;
384 if (r_R2()) {
385 sbp.slice_del();
386 if (among_var == 1) {
387 sbp.ket = sbp.cursor;
388 if (sbp.eq_s_b(2, "at")) {
389 sbp.bra = sbp.cursor;
390 if (r_R2())
391 sbp.slice_del();
392 }
393 }
394 }
395 }
396 break;
397 case 6:
398 if (!r_R2())
399 return false;
400 sbp.slice_del();
401 sbp.ket = sbp.cursor;
402 among_var = sbp.find_among_b(a_3, 3);
403 if (among_var) {
404 sbp.bra = sbp.cursor;
405 if (among_var == 1)
406 if (r_R2())
407 sbp.slice_del();
408 }
409 break;
410 case 7:
411 if (!r_R2())
412 return false;
413 sbp.slice_del();
414 sbp.ket = sbp.cursor;
415 among_var = sbp.find_among_b(a_4, 3);
416 if (among_var) {
417 sbp.bra = sbp.cursor;
418 if (among_var == 1)
419 if (r_R2())
420 sbp.slice_del();
421 }
422 break;
423 case 8:
424 if (!r_R2())
425 return false;
426 sbp.slice_del();
427 sbp.ket = sbp.cursor;
428 if (sbp.eq_s_b(2, "at")) {
429 sbp.bra = sbp.cursor;
430 if (r_R2())
431 sbp.slice_del();
432 }
433 break;
434 case 9:
435 if (!r_RV() || !sbp.eq_s_b(1, "e"))
436 return false;
437 sbp.slice_from("ir");
438 break;
439 }
440 return true;
441 }
442
443 function r_verb_suffix() {
444 var among_var, v_1;
445 if (sbp.cursor >= I_pV) {
446 v_1 = sbp.limit_backward;
447 sbp.limit_backward = I_pV;
448 sbp.ket = sbp.cursor;
449 among_var = sbp.find_among_b(a_6, 120);
450 if (among_var) {
451 sbp.bra = sbp.cursor;
452 if (among_var == 1)
453 sbp.slice_del();
454 sbp.limit_backward = v_1;
455 return true;
456 }
457 sbp.limit_backward = v_1;
458 }
459 return false;
460 }
461
462 function r_residual_suffix() {
463 var among_var;
464 sbp.ket = sbp.cursor;
465 among_var = sbp.find_among_b(a_7, 7);
466 if (among_var) {
467 sbp.bra = sbp.cursor;
468 if (among_var == 1)
469 if (r_RV())
470 sbp.slice_del();
471 }
472 }
473
474 function habr6(c1, c2) {
475 if (sbp.eq_s_b(1, c1)) {
476 sbp.bra = sbp.cursor;
477 var v_1 = sbp.limit - sbp.cursor;
478 if (sbp.eq_s_b(1, c2)) {
479 sbp.cursor = sbp.limit - v_1;
480 if (r_RV())
481 sbp.slice_del();
482 return false;
483 }
484 }
485 return true;
486 }
487
488 function r_residual_form() {
489 var among_var, v_1, v_2, v_3;
490 sbp.ket = sbp.cursor;
491 among_var = sbp.find_among_b(a_8, 4);
492 if (among_var) {
493 sbp.bra = sbp.cursor;
494 switch (among_var) {
495 case 1:
496 if (r_RV()) {
497 sbp.slice_del();
498 sbp.ket = sbp.cursor;
499 v_1 = sbp.limit - sbp.cursor;
500 if (habr6("u", "g"))
501 habr6("i", "c")
502 }
503 break;
504 case 2:
505 sbp.slice_from("c");
506 break;
507 }
508 }
509 }
510
511 function habr1() {
512 if (!r_standard_suffix()) {
513 sbp.cursor = sbp.limit;
514 if (!r_verb_suffix()) {
515 sbp.cursor = sbp.limit;
516 r_residual_suffix();
517 return;
518 }
519 }
520 sbp.cursor = sbp.limit;
521 sbp.ket = sbp.cursor;
522 if (sbp.eq_s_b(1, "i")) {
523 sbp.bra = sbp.cursor;
524 if (sbp.eq_s_b(1, "c")) {
525 sbp.cursor = sbp.limit;
526 if (r_RV())
527 sbp.slice_del();
528 }
529 }
530 }
531 this.stem = function() {
532 var v_1 = sbp.cursor;
533 r_prelude();
534 sbp.cursor = v_1;
535 r_mark_regions();
536 sbp.limit_backward = v_1;
537 sbp.cursor = sbp.limit;
538 habr1();
539 sbp.cursor = sbp.limit;
540 r_residual_form();
541 sbp.cursor = sbp.limit_backward;
542 r_postlude();
543 return true;
544 }
545 };
546
547 /* and return a function that stems a word for the current locale */
548 return function(token) {
549 // for lunr version 2
550 if (typeof token.update === "function") {
551 return token.update(function(word) {
552 st.setCurrent(word);
553 st.stem();
554 return st.getCurrent();
555 })
556 } else { // for lunr version <= 1
557 st.setCurrent(token);
558 st.stem();
559 return st.getCurrent();
560 }
561 }
562 })();
563
564 lunr.Pipeline.registerFunction(lunr.pt.stemmer, 'stemmer-pt');
565
566 lunr.pt.stopWordFilter = lunr.generateStopWordFilter('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(' '));
567
568 lunr.Pipeline.registerFunction(lunr.pt.stopWordFilter, 'stopWordFilter-pt');
569 };
570 }))