Debian Codegraph @

mkdocs/contrib/search/lunr-language/lunr.nl.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 /* register specific locale function */
56 lunr.nl = function() {
57 this.pipeline.reset();
58 this.pipeline.add(
59 lunr.nl.trimmer,
60 lunr.nl.stopWordFilter,
61 lunr.nl.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.nl.stemmer)
70 }
71 };
72
73 /* lunr trimmer function */
74 lunr.nl.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.nl.trimmer = lunr.trimmerSupport.generateTrimmer(lunr.nl.wordCharacters);
76
77 lunr.Pipeline.registerFunction(lunr.nl.trimmer, 'trimmer-nl');
78
79 /* lunr stemmer function */
80 lunr.nl.stemmer = (function() {
81 /* create the wrapped stemmer object */
82 var Among = lunr.stemmerSupport.Among,
83 SnowballProgram = lunr.stemmerSupport.SnowballProgram,
84 st = new function DutchStemmer() {
85 var a_0 = [new Among("", -1, 6), new Among("\u00E1", 0, 1),
86 new Among("\u00E4", 0, 1), new Among("\u00E9", 0, 2),
87 new Among("\u00EB", 0, 2), new Among("\u00ED", 0, 3),
88 new Among("\u00EF", 0, 3), new Among("\u00F3", 0, 4),
89 new Among("\u00F6", 0, 4), new Among("\u00FA", 0, 5),
90 new Among("\u00FC", 0, 5)
91 ],
92 a_1 = [new Among("", -1, 3),
93 new Among("I", 0, 2), new Among("Y", 0, 1)
94 ],
95 a_2 = [
96 new Among("dd", -1, -1), new Among("kk", -1, -1),
97 new Among("tt", -1, -1)
98 ],
99 a_3 = [new Among("ene", -1, 2),
100 new Among("se", -1, 3), new Among("en", -1, 2),
101 new Among("heden", 2, 1), new Among("s", -1, 3)
102 ],
103 a_4 = [
104 new Among("end", -1, 1), new Among("ig", -1, 2),
105 new Among("ing", -1, 1), new Among("lijk", -1, 3),
106 new Among("baar", -1, 4), new Among("bar", -1, 5)
107 ],
108 a_5 = [
109 new Among("aa", -1, -1), new Among("ee", -1, -1),
110 new Among("oo", -1, -1), new Among("uu", -1, -1)
111 ],
112 g_v = [17, 65,
113 16, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128
114 ],
115 g_v_I = [1, 0, 0,
116 17, 65, 16, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128
117 ],
118 g_v_j = [
119 17, 67, 16, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128
120 ],
121 I_p2, I_p1, B_e_found, sbp = new SnowballProgram();
122 this.setCurrent = function(word) {
123 sbp.setCurrent(word);
124 };
125 this.getCurrent = function() {
126 return sbp.getCurrent();
127 };
128
129 function r_prelude() {
130 var among_var, v_1 = sbp.cursor,
131 v_2, v_3;
132 while (true) {
133 sbp.bra = sbp.cursor;
134 among_var = sbp.find_among(a_0, 11);
135 if (among_var) {
136 sbp.ket = sbp.cursor;
137 switch (among_var) {
138 case 1:
139 sbp.slice_from("a");
140 continue;
141 case 2:
142 sbp.slice_from("e");
143 continue;
144 case 3:
145 sbp.slice_from("i");
146 continue;
147 case 4:
148 sbp.slice_from("o");
149 continue;
150 case 5:
151 sbp.slice_from("u");
152 continue;
153 case 6:
154 if (sbp.cursor >= sbp.limit)
155 break;
156 sbp.cursor++;
157 continue;
158 }
159 }
160 break;
161 }
162 sbp.cursor = v_1;
163 sbp.bra = v_1;
164 if (sbp.eq_s(1, "y")) {
165 sbp.ket = sbp.cursor;
166 sbp.slice_from("Y");
167 } else
168 sbp.cursor = v_1;
169 while (true) {
170 v_2 = sbp.cursor;
171 if (sbp.in_grouping(g_v, 97, 232)) {
172 v_3 = sbp.cursor;
173 sbp.bra = v_3;
174 if (sbp.eq_s(1, "i")) {
175 sbp.ket = sbp.cursor;
176 if (sbp.in_grouping(g_v, 97, 232)) {
177 sbp.slice_from("I");
178 sbp.cursor = v_2;
179 }
180 } else {
181 sbp.cursor = v_3;
182 if (sbp.eq_s(1, "y")) {
183 sbp.ket = sbp.cursor;
184 sbp.slice_from("Y");
185 sbp.cursor = v_2;
186 } else if (habr1(v_2))
187 break;
188 }
189 } else if (habr1(v_2))
190 break;
191 }
192 }
193
194 function habr1(v_1) {
195 sbp.cursor = v_1;
196 if (v_1 >= sbp.limit)
197 return true;
198 sbp.cursor++;
199 return false;
200 }
201
202 function r_mark_regions() {
203 I_p1 = sbp.limit;
204 I_p2 = I_p1;
205 if (!habr2()) {
206 I_p1 = sbp.cursor;
207 if (I_p1 < 3)
208 I_p1 = 3;
209 if (!habr2())
210 I_p2 = sbp.cursor;
211 }
212 }
213
214 function habr2() {
215 while (!sbp.in_grouping(g_v, 97, 232)) {
216 if (sbp.cursor >= sbp.limit)
217 return true;
218 sbp.cursor++;
219 }
220 while (!sbp.out_grouping(g_v, 97, 232)) {
221 if (sbp.cursor >= sbp.limit)
222 return true;
223 sbp.cursor++;
224 }
225 return false;
226 }
227
228 function r_postlude() {
229 var among_var;
230 while (true) {
231 sbp.bra = sbp.cursor;
232 among_var = sbp.find_among(a_1, 3);
233 if (among_var) {
234 sbp.ket = sbp.cursor;
235 switch (among_var) {
236 case 1:
237 sbp.slice_from("y");
238 break;
239 case 2:
240 sbp.slice_from("i");
241 break;
242 case 3:
243 if (sbp.cursor >= sbp.limit)
244 return;
245 sbp.cursor++;
246 break;
247 }
248 }
249 }
250 }
251
252 function r_R1() {
253 return I_p1 <= sbp.cursor;
254 }
255
256 function r_R2() {
257 return I_p2 <= sbp.cursor;
258 }
259
260 function r_undouble() {
261 var v_1 = sbp.limit - sbp.cursor;
262 if (sbp.find_among_b(a_2, 3)) {
263 sbp.cursor = sbp.limit - v_1;
264 sbp.ket = sbp.cursor;
265 if (sbp.cursor > sbp.limit_backward) {
266 sbp.cursor--;
267 sbp.bra = sbp.cursor;
268 sbp.slice_del();
269 }
270 }
271 }
272
273 function r_e_ending() {
274 var v_1;
275 B_e_found = false;
276 sbp.ket = sbp.cursor;
277 if (sbp.eq_s_b(1, "e")) {
278 sbp.bra = sbp.cursor;
279 if (r_R1()) {
280 v_1 = sbp.limit - sbp.cursor;
281 if (sbp.out_grouping_b(g_v, 97, 232)) {
282 sbp.cursor = sbp.limit - v_1;
283 sbp.slice_del();
284 B_e_found = true;
285 r_undouble();
286 }
287 }
288 }
289 }
290
291 function r_en_ending() {
292 var v_1;
293 if (r_R1()) {
294 v_1 = sbp.limit - sbp.cursor;
295 if (sbp.out_grouping_b(g_v, 97, 232)) {
296 sbp.cursor = sbp.limit - v_1;
297 if (!sbp.eq_s_b(3, "gem")) {
298 sbp.cursor = sbp.limit - v_1;
299 sbp.slice_del();
300 r_undouble();
301 }
302 }
303 }
304 }
305
306 function r_standard_suffix() {
307 var among_var, v_1 = sbp.limit - sbp.cursor,
308 v_2, v_3, v_4, v_5, v_6;
309 sbp.ket = sbp.cursor;
310 among_var = sbp.find_among_b(a_3, 5);
311 if (among_var) {
312 sbp.bra = sbp.cursor;
313 switch (among_var) {
314 case 1:
315 if (r_R1())
316 sbp.slice_from("heid");
317 break;
318 case 2:
319 r_en_ending();
320 break;
321 case 3:
322 if (r_R1() && sbp.out_grouping_b(g_v_j, 97, 232))
323 sbp.slice_del();
324 break;
325 }
326 }
327 sbp.cursor = sbp.limit - v_1;
328 r_e_ending();
329 sbp.cursor = sbp.limit - v_1;
330 sbp.ket = sbp.cursor;
331 if (sbp.eq_s_b(4, "heid")) {
332 sbp.bra = sbp.cursor;
333 if (r_R2()) {
334 v_2 = sbp.limit - sbp.cursor;
335 if (!sbp.eq_s_b(1, "c")) {
336 sbp.cursor = sbp.limit - v_2;
337 sbp.slice_del();
338 sbp.ket = sbp.cursor;
339 if (sbp.eq_s_b(2, "en")) {
340 sbp.bra = sbp.cursor;
341 r_en_ending();
342 }
343 }
344 }
345 }
346 sbp.cursor = sbp.limit - v_1;
347 sbp.ket = sbp.cursor;
348 among_var = sbp.find_among_b(a_4, 6);
349 if (among_var) {
350 sbp.bra = sbp.cursor;
351 switch (among_var) {
352 case 1:
353 if (r_R2()) {
354 sbp.slice_del();
355 v_3 = sbp.limit - sbp.cursor;
356 sbp.ket = sbp.cursor;
357 if (sbp.eq_s_b(2, "ig")) {
358 sbp.bra = sbp.cursor;
359 if (r_R2()) {
360 v_4 = sbp.limit - sbp.cursor;
361 if (!sbp.eq_s_b(1, "e")) {
362 sbp.cursor = sbp.limit - v_4;
363 sbp.slice_del();
364 break;
365 }
366 }
367 }
368 sbp.cursor = sbp.limit - v_3;
369 r_undouble();
370 }
371 break;
372 case 2:
373 if (r_R2()) {
374 v_5 = sbp.limit - sbp.cursor;
375 if (!sbp.eq_s_b(1, "e")) {
376 sbp.cursor = sbp.limit - v_5;
377 sbp.slice_del();
378 }
379 }
380 break;
381 case 3:
382 if (r_R2()) {
383 sbp.slice_del();
384 r_e_ending();
385 }
386 break;
387 case 4:
388 if (r_R2())
389 sbp.slice_del();
390 break;
391 case 5:
392 if (r_R2() && B_e_found)
393 sbp.slice_del();
394 break;
395 }
396 }
397 sbp.cursor = sbp.limit - v_1;
398 if (sbp.out_grouping_b(g_v_I, 73, 232)) {
399 v_6 = sbp.limit - sbp.cursor;
400 if (sbp.find_among_b(a_5, 4) && sbp.out_grouping_b(g_v, 97, 232)) {
401 sbp.cursor = sbp.limit - v_6;
402 sbp.ket = sbp.cursor;
403 if (sbp.cursor > sbp.limit_backward) {
404 sbp.cursor--;
405 sbp.bra = sbp.cursor;
406 sbp.slice_del();
407 }
408 }
409 }
410 }
411 this.stem = function() {
412 var v_1 = sbp.cursor;
413 r_prelude();
414 sbp.cursor = v_1;
415 r_mark_regions();
416 sbp.limit_backward = v_1;
417 sbp.cursor = sbp.limit;
418 r_standard_suffix();
419 sbp.cursor = sbp.limit_backward;
420 r_postlude();
421 return true;
422 }
423 };
424
425 /* and return a function that stems a word for the current locale */
426 return function(token) {
427 // for lunr version 2
428 if (typeof token.update === "function") {
429 return token.update(function(word) {
430 st.setCurrent(word);
431 st.stem();
432 return st.getCurrent();
433 })
434 } else { // for lunr version <= 1
435 st.setCurrent(token);
436 st.stem();
437 return st.getCurrent();
438 }
439 }
440 })();
441
442 lunr.Pipeline.registerFunction(lunr.nl.stemmer, 'stemmer-nl');
443
444 lunr.nl.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(' '));
445
446 lunr.Pipeline.registerFunction(lunr.nl.stopWordFilter, 'stopWordFilter-nl');
447 };
448 }))