Debian Codegraph @

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

raw
1 /*!
2 * Lunr languages, `Dutch` 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 console.warn("[Lunr Languages] Please use the \"nl\" instead of the \"du\". The \"nl\" code is the standard code for Dutch language, and \"du\" will be removed in the next major versions.");
56
57 /* register specific locale function */
58 lunr.du = function() {
59 this.pipeline.reset();
60 this.pipeline.add(
61 lunr.du.trimmer,
62 lunr.du.stopWordFilter,
63 lunr.du.stemmer
64 );
65
66 // for lunr version 2
67 // this is necessary so that every searched word is also stemmed before
68 // in lunr <= 1 this is not needed, as it is done using the normal pipeline
69 if (this.searchPipeline) {
70 this.searchPipeline.reset();
71 this.searchPipeline.add(lunr.du.stemmer)
72 }
73 };
74
75 /* lunr trimmer function */
76 lunr.du.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";
77 lunr.du.trimmer = lunr.trimmerSupport.generateTrimmer(lunr.du.wordCharacters);
78
79 lunr.Pipeline.registerFunction(lunr.du.trimmer, 'trimmer-du');
80
81 /* lunr stemmer function */
82 lunr.du.stemmer = (function() {
83 /* create the wrapped stemmer object */
84 var Among = lunr.stemmerSupport.Among,
85 SnowballProgram = lunr.stemmerSupport.SnowballProgram,
86 st = new function DutchStemmer() {
87 var a_0 = [new Among("", -1, 6), new Among("\u00E1", 0, 1),
88 new Among("\u00E4", 0, 1), new Among("\u00E9", 0, 2),
89 new Among("\u00EB", 0, 2), new Among("\u00ED", 0, 3),
90 new Among("\u00EF", 0, 3), new Among("\u00F3", 0, 4),
91 new Among("\u00F6", 0, 4), new Among("\u00FA", 0, 5),
92 new Among("\u00FC", 0, 5)
93 ],
94 a_1 = [new Among("", -1, 3),
95 new Among("I", 0, 2), new Among("Y", 0, 1)
96 ],
97 a_2 = [
98 new Among("dd", -1, -1), new Among("kk", -1, -1),
99 new Among("tt", -1, -1)
100 ],
101 a_3 = [new Among("ene", -1, 2),
102 new Among("se", -1, 3), new Among("en", -1, 2),
103 new Among("heden", 2, 1), new Among("s", -1, 3)
104 ],
105 a_4 = [
106 new Among("end", -1, 1), new Among("ig", -1, 2),
107 new Among("ing", -1, 1), new Among("lijk", -1, 3),
108 new Among("baar", -1, 4), new Among("bar", -1, 5)
109 ],
110 a_5 = [
111 new Among("aa", -1, -1), new Among("ee", -1, -1),
112 new Among("oo", -1, -1), new Among("uu", -1, -1)
113 ],
114 g_v = [17, 65,
115 16, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128
116 ],
117 g_v_I = [1, 0, 0,
118 17, 65, 16, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128
119 ],
120 g_v_j = [
121 17, 67, 16, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128
122 ],
123 I_p2, I_p1, B_e_found, sbp = new SnowballProgram();
124 this.setCurrent = function(word) {
125 sbp.setCurrent(word);
126 };
127 this.getCurrent = function() {
128 return sbp.getCurrent();
129 };
130
131 function r_prelude() {
132 var among_var, v_1 = sbp.cursor,
133 v_2, v_3;
134 while (true) {
135 sbp.bra = sbp.cursor;
136 among_var = sbp.find_among(a_0, 11);
137 if (among_var) {
138 sbp.ket = sbp.cursor;
139 switch (among_var) {
140 case 1:
141 sbp.slice_from("a");
142 continue;
143 case 2:
144 sbp.slice_from("e");
145 continue;
146 case 3:
147 sbp.slice_from("i");
148 continue;
149 case 4:
150 sbp.slice_from("o");
151 continue;
152 case 5:
153 sbp.slice_from("u");
154 continue;
155 case 6:
156 if (sbp.cursor >= sbp.limit)
157 break;
158 sbp.cursor++;
159 continue;
160 }
161 }
162 break;
163 }
164 sbp.cursor = v_1;
165 sbp.bra = v_1;
166 if (sbp.eq_s(1, "y")) {
167 sbp.ket = sbp.cursor;
168 sbp.slice_from("Y");
169 } else
170 sbp.cursor = v_1;
171 while (true) {
172 v_2 = sbp.cursor;
173 if (sbp.in_grouping(g_v, 97, 232)) {
174 v_3 = sbp.cursor;
175 sbp.bra = v_3;
176 if (sbp.eq_s(1, "i")) {
177 sbp.ket = sbp.cursor;
178 if (sbp.in_grouping(g_v, 97, 232)) {
179 sbp.slice_from("I");
180 sbp.cursor = v_2;
181 }
182 } else {
183 sbp.cursor = v_3;
184 if (sbp.eq_s(1, "y")) {
185 sbp.ket = sbp.cursor;
186 sbp.slice_from("Y");
187 sbp.cursor = v_2;
188 } else if (habr1(v_2))
189 break;
190 }
191 } else if (habr1(v_2))
192 break;
193 }
194 }
195
196 function habr1(v_1) {
197 sbp.cursor = v_1;
198 if (v_1 >= sbp.limit)
199 return true;
200 sbp.cursor++;
201 return false;
202 }
203
204 function r_mark_regions() {
205 I_p1 = sbp.limit;
206 I_p2 = I_p1;
207 if (!habr2()) {
208 I_p1 = sbp.cursor;
209 if (I_p1 < 3)
210 I_p1 = 3;
211 if (!habr2())
212 I_p2 = sbp.cursor;
213 }
214 }
215
216 function habr2() {
217 while (!sbp.in_grouping(g_v, 97, 232)) {
218 if (sbp.cursor >= sbp.limit)
219 return true;
220 sbp.cursor++;
221 }
222 while (!sbp.out_grouping(g_v, 97, 232)) {
223 if (sbp.cursor >= sbp.limit)
224 return true;
225 sbp.cursor++;
226 }
227 return false;
228 }
229
230 function r_postlude() {
231 var among_var;
232 while (true) {
233 sbp.bra = sbp.cursor;
234 among_var = sbp.find_among(a_1, 3);
235 if (among_var) {
236 sbp.ket = sbp.cursor;
237 switch (among_var) {
238 case 1:
239 sbp.slice_from("y");
240 break;
241 case 2:
242 sbp.slice_from("i");
243 break;
244 case 3:
245 if (sbp.cursor >= sbp.limit)
246 return;
247 sbp.cursor++;
248 break;
249 }
250 }
251 }
252 }
253
254 function r_R1() {
255 return I_p1 <= sbp.cursor;
256 }
257
258 function r_R2() {
259 return I_p2 <= sbp.cursor;
260 }
261
262 function r_undouble() {
263 var v_1 = sbp.limit - sbp.cursor;
264 if (sbp.find_among_b(a_2, 3)) {
265 sbp.cursor = sbp.limit - v_1;
266 sbp.ket = sbp.cursor;
267 if (sbp.cursor > sbp.limit_backward) {
268 sbp.cursor--;
269 sbp.bra = sbp.cursor;
270 sbp.slice_del();
271 }
272 }
273 }
274
275 function r_e_ending() {
276 var v_1;
277 B_e_found = false;
278 sbp.ket = sbp.cursor;
279 if (sbp.eq_s_b(1, "e")) {
280 sbp.bra = sbp.cursor;
281 if (r_R1()) {
282 v_1 = sbp.limit - sbp.cursor;
283 if (sbp.out_grouping_b(g_v, 97, 232)) {
284 sbp.cursor = sbp.limit - v_1;
285 sbp.slice_del();
286 B_e_found = true;
287 r_undouble();
288 }
289 }
290 }
291 }
292
293 function r_en_ending() {
294 var v_1;
295 if (r_R1()) {
296 v_1 = sbp.limit - sbp.cursor;
297 if (sbp.out_grouping_b(g_v, 97, 232)) {
298 sbp.cursor = sbp.limit - v_1;
299 if (!sbp.eq_s_b(3, "gem")) {
300 sbp.cursor = sbp.limit - v_1;
301 sbp.slice_del();
302 r_undouble();
303 }
304 }
305 }
306 }
307
308 function r_standard_suffix() {
309 var among_var, v_1 = sbp.limit - sbp.cursor,
310 v_2, v_3, v_4, v_5, v_6;
311 sbp.ket = sbp.cursor;
312 among_var = sbp.find_among_b(a_3, 5);
313 if (among_var) {
314 sbp.bra = sbp.cursor;
315 switch (among_var) {
316 case 1:
317 if (r_R1())
318 sbp.slice_from("heid");
319 break;
320 case 2:
321 r_en_ending();
322 break;
323 case 3:
324 if (r_R1() && sbp.out_grouping_b(g_v_j, 97, 232))
325 sbp.slice_del();
326 break;
327 }
328 }
329 sbp.cursor = sbp.limit - v_1;
330 r_e_ending();
331 sbp.cursor = sbp.limit - v_1;
332 sbp.ket = sbp.cursor;
333 if (sbp.eq_s_b(4, "heid")) {
334 sbp.bra = sbp.cursor;
335 if (r_R2()) {
336 v_2 = sbp.limit - sbp.cursor;
337 if (!sbp.eq_s_b(1, "c")) {
338 sbp.cursor = sbp.limit - v_2;
339 sbp.slice_del();
340 sbp.ket = sbp.cursor;
341 if (sbp.eq_s_b(2, "en")) {
342 sbp.bra = sbp.cursor;
343 r_en_ending();
344 }
345 }
346 }
347 }
348 sbp.cursor = sbp.limit - v_1;
349 sbp.ket = sbp.cursor;
350 among_var = sbp.find_among_b(a_4, 6);
351 if (among_var) {
352 sbp.bra = sbp.cursor;
353 switch (among_var) {
354 case 1:
355 if (r_R2()) {
356 sbp.slice_del();
357 v_3 = sbp.limit - sbp.cursor;
358 sbp.ket = sbp.cursor;
359 if (sbp.eq_s_b(2, "ig")) {
360 sbp.bra = sbp.cursor;
361 if (r_R2()) {
362 v_4 = sbp.limit - sbp.cursor;
363 if (!sbp.eq_s_b(1, "e")) {
364 sbp.cursor = sbp.limit - v_4;
365 sbp.slice_del();
366 break;
367 }
368 }
369 }
370 sbp.cursor = sbp.limit - v_3;
371 r_undouble();
372 }
373 break;
374 case 2:
375 if (r_R2()) {
376 v_5 = sbp.limit - sbp.cursor;
377 if (!sbp.eq_s_b(1, "e")) {
378 sbp.cursor = sbp.limit - v_5;
379 sbp.slice_del();
380 }
381 }
382 break;
383 case 3:
384 if (r_R2()) {
385 sbp.slice_del();
386 r_e_ending();
387 }
388 break;
389 case 4:
390 if (r_R2())
391 sbp.slice_del();
392 break;
393 case 5:
394 if (r_R2() && B_e_found)
395 sbp.slice_del();
396 break;
397 }
398 }
399 sbp.cursor = sbp.limit - v_1;
400 if (sbp.out_grouping_b(g_v_I, 73, 232)) {
401 v_6 = sbp.limit - sbp.cursor;
402 if (sbp.find_among_b(a_5, 4) && sbp.out_grouping_b(g_v, 97, 232)) {
403 sbp.cursor = sbp.limit - v_6;
404 sbp.ket = sbp.cursor;
405 if (sbp.cursor > sbp.limit_backward) {
406 sbp.cursor--;
407 sbp.bra = sbp.cursor;
408 sbp.slice_del();
409 }
410 }
411 }
412 }
413 this.stem = function() {
414 var v_1 = sbp.cursor;
415 r_prelude();
416 sbp.cursor = v_1;
417 r_mark_regions();
418 sbp.limit_backward = v_1;
419 sbp.cursor = sbp.limit;
420 r_standard_suffix();
421 sbp.cursor = sbp.limit_backward;
422 r_postlude();
423 return true;
424 }
425 };
426
427 /* and return a function that stems a word for the current locale */
428 return function(token) {
429 // for lunr version 2
430 if (typeof token.update === "function") {
431 return token.update(function(word) {
432 st.setCurrent(word);
433 st.stem();
434 return st.getCurrent();
435 })
436 } else { // for lunr version <= 1
437 st.setCurrent(token);
438 st.stem();
439 return st.getCurrent();
440 }
441 }
442 })();
443
444 lunr.Pipeline.registerFunction(lunr.du.stemmer, 'stemmer-du');
445
446 lunr.du.stopWordFilter = lunr.generateStopWordFilter(' aan al alles als altijd andere ben bij daar dan dat de der deze die dit doch doen door dus een eens en er ge geen geweest haar had heb hebben heeft hem het hier hij hoe hun iemand iets ik in is ja je kan kon kunnen maar me meer men met mij mijn moet na naar niet niets nog nu of om omdat onder ons ook op over reeds te tegen toch toen tot u uit uw van veel voor want waren was wat werd wezen wie wil worden wordt zal ze zelf zich zij zijn zo zonder zou'.split(' '));
447
448 lunr.Pipeline.registerFunction(lunr.du.stopWordFilter, 'stopWordFilter-du');
449 };
450 }))