2020-04-27 20:08:31 +02:00
/ * !
* Lunr languages , ` Danish ` language
* https : //github.com/MihaiValentin/lunr-languages
*
* Copyright 2014 , Mihai Valentin
* http : //www.mozilla.org/MPL/
* /
/ * !
* based on
* Snowball JavaScript Library v0 . 3
* http : //code.google.com/p/urim/
* http : //snowball.tartarus.org/
*
* Copyright 2010 , Oleg Mazko
* http : //www.mozilla.org/MPL/
* /
/ * *
* export the module via AMD , CommonJS or as a browser global
* Export code from https : //github.com/umdjs/umd/blob/master/returnExports.js
* /
2020-05-18 11:35:33 +02:00
2020-04-27 20:08:31 +02:00
( function ( root , factory ) {
if ( typeof define === 'function' && define . amd ) {
// AMD. Register as an anonymous module.
define ( factory )
} else if ( typeof exports === 'object' ) {
/ * *
* Node . Does not work with strict CommonJS , but
* only CommonJS - like environments that support module . exports ,
* like Node .
* /
module . exports = factory ( )
} else {
// Browser globals (root is window)
factory ( ) ( root . lunr ) ;
}
} ( this , function ( ) {
/ * *
* Just return a value to define the module export .
* This example returns an object , but the module
* can return a function as the exported value .
* /
return function ( lunr ) {
/* throw error if lunr is not yet included */
if ( 'undefined' === typeof lunr ) {
throw new Error ( 'Lunr is not present. Please include / require Lunr before this script.' ) ;
}
/* throw error if lunr stemmer support is not yet included */
if ( 'undefined' === typeof lunr . stemmerSupport ) {
throw new Error ( 'Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.' ) ;
}
/* register specific locale function */
lunr . da = function ( ) {
this . pipeline . reset ( ) ;
this . pipeline . add (
lunr . da . trimmer ,
lunr . da . stopWordFilter ,
lunr . da . stemmer
) ;
// for lunr version 2
// this is necessary so that every searched word is also stemmed before
// in lunr <= 1 this is not needed, as it is done using the normal pipeline
if ( this . searchPipeline ) {
this . searchPipeline . reset ( ) ;
this . searchPipeline . add ( lunr . da . stemmer )
}
} ;
/* lunr trimmer function */
lunr . da . 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" ;
lunr . da . trimmer = lunr . trimmerSupport . generateTrimmer ( lunr . da . wordCharacters ) ;
lunr . Pipeline . registerFunction ( lunr . da . trimmer , 'trimmer-da' ) ;
/* lunr stemmer function */
lunr . da . stemmer = ( function ( ) {
/* create the wrapped stemmer object */
var Among = lunr . stemmerSupport . Among ,
SnowballProgram = lunr . stemmerSupport . SnowballProgram ,
st = new function DanishStemmer ( ) {
var a _0 = [ new Among ( "hed" , - 1 , 1 ) , new Among ( "ethed" , 0 , 1 ) ,
new Among ( "ered" , - 1 , 1 ) , new Among ( "e" , - 1 , 1 ) ,
new Among ( "erede" , 3 , 1 ) , new Among ( "ende" , 3 , 1 ) ,
new Among ( "erende" , 5 , 1 ) , new Among ( "ene" , 3 , 1 ) ,
new Among ( "erne" , 3 , 1 ) , new Among ( "ere" , 3 , 1 ) ,
new Among ( "en" , - 1 , 1 ) , new Among ( "heden" , 10 , 1 ) ,
new Among ( "eren" , 10 , 1 ) , new Among ( "er" , - 1 , 1 ) ,
new Among ( "heder" , 13 , 1 ) , new Among ( "erer" , 13 , 1 ) ,
new Among ( "s" , - 1 , 2 ) , new Among ( "heds" , 16 , 1 ) ,
new Among ( "es" , 16 , 1 ) , new Among ( "endes" , 18 , 1 ) ,
new Among ( "erendes" , 19 , 1 ) , new Among ( "enes" , 18 , 1 ) ,
new Among ( "ernes" , 18 , 1 ) , new Among ( "eres" , 18 , 1 ) ,
new Among ( "ens" , 16 , 1 ) , new Among ( "hedens" , 24 , 1 ) ,
new Among ( "erens" , 24 , 1 ) , new Among ( "ers" , 16 , 1 ) ,
new Among ( "ets" , 16 , 1 ) , new Among ( "erets" , 28 , 1 ) ,
new Among ( "et" , - 1 , 1 ) , new Among ( "eret" , 30 , 1 )
] ,
a _1 = [
new Among ( "gd" , - 1 , - 1 ) , new Among ( "dt" , - 1 , - 1 ) ,
new Among ( "gt" , - 1 , - 1 ) , new Among ( "kt" , - 1 , - 1 )
] ,
a _2 = [
new Among ( "ig" , - 1 , 1 ) , new Among ( "lig" , 0 , 1 ) ,
new Among ( "elig" , 1 , 1 ) , new Among ( "els" , - 1 , 1 ) ,
new Among ( "l\u00F8st" , - 1 , 2 )
] ,
g _v = [ 17 , 65 , 16 , 1 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 48 , 0 , 128
] ,
g _s _ending = [ 239 , 254 , 42 , 3 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 16
] ,
I _x , I _p1 , S _ch , sbp = new SnowballProgram ( ) ;
this . setCurrent = function ( word ) {
sbp . setCurrent ( word ) ;
} ;
this . getCurrent = function ( ) {
return sbp . getCurrent ( ) ;
} ;
function r _mark _regions ( ) {
var v _1 , c = sbp . cursor + 3 ;
I _p1 = sbp . limit ;
if ( 0 <= c && c <= sbp . limit ) {
I _x = c ;
while ( true ) {
v _1 = sbp . cursor ;
if ( sbp . in _grouping ( g _v , 97 , 248 ) ) {
sbp . cursor = v _1 ;
break ;
}
sbp . cursor = v _1 ;
if ( v _1 >= sbp . limit )
return ;
sbp . cursor ++ ;
}
while ( ! sbp . out _grouping ( g _v , 97 , 248 ) ) {
if ( sbp . cursor >= sbp . limit )
return ;
sbp . cursor ++ ;
}
I _p1 = sbp . cursor ;
if ( I _p1 < I _x )
I _p1 = I _x ;
}
}
function r _main _suffix ( ) {
var among _var , v _1 ;
if ( sbp . cursor >= I _p1 ) {
v _1 = sbp . limit _backward ;
sbp . limit _backward = I _p1 ;
sbp . ket = sbp . cursor ;
among _var = sbp . find _among _b ( a _0 , 32 ) ;
sbp . limit _backward = v _1 ;
if ( among _var ) {
sbp . bra = sbp . cursor ;
switch ( among _var ) {
case 1 :
sbp . slice _del ( ) ;
break ;
case 2 :
if ( sbp . in _grouping _b ( g _s _ending , 97 , 229 ) )
sbp . slice _del ( ) ;
break ;
}
}
}
}
function r _consonant _pair ( ) {
var v _1 = sbp . limit - sbp . cursor ,
v _2 ;
if ( sbp . cursor >= I _p1 ) {
v _2 = sbp . limit _backward ;
sbp . limit _backward = I _p1 ;
sbp . ket = sbp . cursor ;
if ( sbp . find _among _b ( a _1 , 4 ) ) {
sbp . bra = sbp . cursor ;
sbp . limit _backward = v _2 ;
sbp . cursor = sbp . limit - v _1 ;
if ( sbp . cursor > sbp . limit _backward ) {
sbp . cursor -- ;
sbp . bra = sbp . cursor ;
sbp . slice _del ( ) ;
}
} else
sbp . limit _backward = v _2 ;
}
}
function r _other _suffix ( ) {
var among _var , v _1 = sbp . limit - sbp . cursor ,
v _2 , v _3 ;
sbp . ket = sbp . cursor ;
if ( sbp . eq _s _b ( 2 , "st" ) ) {
sbp . bra = sbp . cursor ;
if ( sbp . eq _s _b ( 2 , "ig" ) )
sbp . slice _del ( ) ;
}
sbp . cursor = sbp . limit - v _1 ;
if ( sbp . cursor >= I _p1 ) {
v _2 = sbp . limit _backward ;
sbp . limit _backward = I _p1 ;
sbp . ket = sbp . cursor ;
among _var = sbp . find _among _b ( a _2 , 5 ) ;
sbp . limit _backward = v _2 ;
if ( among _var ) {
sbp . bra = sbp . cursor ;
switch ( among _var ) {
case 1 :
sbp . slice _del ( ) ;
v _3 = sbp . limit - sbp . cursor ;
r _consonant _pair ( ) ;
sbp . cursor = sbp . limit - v _3 ;
break ;
case 2 :
sbp . slice _from ( "l\u00F8s" ) ;
break ;
}
}
}
}
function r _undouble ( ) {
var v _1 ;
if ( sbp . cursor >= I _p1 ) {
v _1 = sbp . limit _backward ;
sbp . limit _backward = I _p1 ;
sbp . ket = sbp . cursor ;
if ( sbp . out _grouping _b ( g _v , 97 , 248 ) ) {
sbp . bra = sbp . cursor ;
S _ch = sbp . slice _to ( S _ch ) ;
sbp . limit _backward = v _1 ;
if ( sbp . eq _v _b ( S _ch ) )
sbp . slice _del ( ) ;
} else
sbp . limit _backward = v _1 ;
}
}
this . stem = function ( ) {
var v _1 = sbp . cursor ;
r _mark _regions ( ) ;
sbp . limit _backward = v _1 ;
sbp . cursor = sbp . limit ;
r _main _suffix ( ) ;
sbp . cursor = sbp . limit ;
r _consonant _pair ( ) ;
sbp . cursor = sbp . limit ;
r _other _suffix ( ) ;
sbp . cursor = sbp . limit ;
r _undouble ( ) ;
return true ;
}
} ;
/* and return a function that stems a word for the current locale */
return function ( token ) {
// for lunr version 2
if ( typeof token . update === "function" ) {
return token . update ( function ( word ) {
st . setCurrent ( word ) ;
st . stem ( ) ;
return st . getCurrent ( ) ;
} )
} else { // for lunr version <= 1
st . setCurrent ( token ) ;
st . stem ( ) ;
return st . getCurrent ( ) ;
}
}
} ) ( ) ;
lunr . Pipeline . registerFunction ( lunr . da . stemmer , 'stemmer-da' ) ;
lunr . da . stopWordFilter = lunr . generateStopWordFilter ( 'ad af alle alt anden at blev blive bliver da de dem den denne der deres det dette dig din disse dog du efter eller en end er et for fra ham han hans har havde have hende hendes her hos hun hvad hvis hvor i ikke ind jeg jer jo kunne man mange med meget men mig min mine mit mod ned noget nogle nu når og også om op os over på selv sig sin sine sit skal skulle som sådan thi til ud under var vi vil ville vor være været' . split ( ' ' ) ) ;
lunr . Pipeline . registerFunction ( lunr . da . stopWordFilter , 'stopWordFilter-da' ) ;
} ;
2020-05-18 11:35:33 +02:00
} ) )