| 1 |
/*! |
| 2 |
* Lunr languages, `Vietnamese` language |
| 3 |
* https://github.com/MihaiValentin/lunr-languages |
| 4 |
* |
| 5 |
* Copyright 2017, Keerati Thiwanruk |
| 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.vi = function() { |
| 57 |
this.pipeline.reset(); |
| 58 |
this.pipeline.add( |
| 59 |
lunr.vi.stopWordFilter, |
| 60 |
lunr.vi.trimmer |
| 61 |
); |
| 62 |
}; |
| 63 |
|
| 64 |
/* lunr trimmer function */ |
| 65 |
lunr.vi.wordCharacters = "[" + |
| 66 |
"A-Za-z" + |
| 67 |
"\u0300\u0350" + // dấu huyền |
| 68 |
"\u0301\u0351" + // dấu sắc |
| 69 |
"\u0309" + // dấu hỏi |
| 70 |
"\u0323" + // dấu nặng |
| 71 |
"\u0303\u0343" + // dấu ngã |
| 72 |
"\u00C2\u00E2" + // Â |
| 73 |
"\u00CA\u00EA" + // Ê |
| 74 |
"\u00D4\u00F4" + // Ô |
| 75 |
"\u0102-\u0103" + // Ă |
| 76 |
"\u0110-\u0111" + // Đ |
| 77 |
"\u01A0-\u01A1" + // Ơ |
| 78 |
"\u01AF-\u01B0" + // Ư |
| 79 |
"]"; |
| 80 |
lunr.vi.trimmer = lunr.trimmerSupport.generateTrimmer(lunr.vi.wordCharacters); |
| 81 |
lunr.Pipeline.registerFunction(lunr.vi.trimmer, 'trimmer-vi'); |
| 82 |
lunr.vi.stopWordFilter = lunr.generateStopWordFilter('là cái nhưng mà'.split(' ')); |
| 83 |
}; |
| 84 |
})) |