UNPKG

@orama/stemmers

Version:
1 lines 4.76 kB
function r(){this.p=function(r){this.j=r,this.cursor=0,this.a=this.j.length,this.f=0,this.c=this.cursor,this.d=this.a},this.z=function(){return this.j},this.w=function(r){this.j=r.j,this.cursor=r.cursor,this.a=r.a,this.f=r.f,this.c=r.c,this.d=r.d},this.i=function(r,s,t){if(this.cursor>=this.a)return!1;var i=this.j.charCodeAt(this.cursor);return!(i>t)&&!(i<s)&&0!=(r[(i-=s)>>>3]&1<<(7&i))&&(this.cursor++,!0)},this.n=function(r,s,t){if(this.cursor<=this.f)return!1;var i=this.j.charCodeAt(this.cursor-1);return!(i>t)&&!(i<s)&&0!=(r[(i-=s)>>>3]&1<<(7&i))&&(this.cursor--,!0)},this.k=function(r,s,t){if(this.cursor>=this.a)return!1;var i=this.j.charCodeAt(this.cursor);return i>t||i<s?(this.cursor++,!0):0==(r[(i-=s)>>>3]&1<<(7&i))&&(this.cursor++,!0)},this.q=function(r,s,t){if(this.cursor<=this.f)return!1;var i=this.j.charCodeAt(this.cursor-1);return i>t||i<s?(this.cursor--,!0):0==(r[(i-=s)>>>3]&1<<(7&i))&&(this.cursor--,!0)},this.m=function(r){return!(this.a-this.cursor<r.length)&&this.j.slice(this.cursor,this.cursor+r.length)==r&&(this.cursor+=r.length,!0)},this.g=function(r){return!(this.cursor-this.f<r.length)&&this.j.slice(this.cursor-r.length,this.cursor)==r&&(this.cursor-=r.length,!0)},this.o=function(r){for(var s=0,t=r.length,i=this.cursor,h=this.a,e=0,c=0,u=!1;;){var o,n=s+(t-s>>>1),f=0,a=e<c?e:c,d=r[n];for(o=a;o<d[0].length;o++){if(i+a==h){f=-1;break}if(0!=(f=this.j.charCodeAt(i+a)-d[0].charCodeAt(o)))break;a++}if(0>f?(t=n,c=a):(s=n,e=a),1>=t-s){if(0<s||t==s||u)break;u=!0}}for(;;){if(e>=(d=r[s])[0].length&&(this.cursor=i+d[0].length,4>d.length||(s=d[3](this),this.cursor=i+d[0].length,s)))return d[2];if(0>(s=d[1]))return 0}},this.h=function(r){for(var s=0,t=r.length,i=this.cursor,h=this.f,e=0,c=0,u=!1;;){var o,n=s+(t-s>>1),f=0,a=e<c?e:c,d=r[n];for(o=d[0].length-1-a;0<=o;o--){if(i-a==h){f=-1;break}if(0!=(f=this.j.charCodeAt(i-1-a)-d[0].charCodeAt(o)))break;a++}if(0>f?(t=n,c=a):(s=n,e=a),1>=t-s){if(0<s||t==s||u)break;u=!0}}for(;;){if(e>=(d=r[s])[0].length&&(this.cursor=i-d[0].length,4>d.length||(s=d[3](this),this.cursor=i-d[0].length,s)))return d[2];if(0>(s=d[1]))return 0}},this.s=function(r,s,t){var i=t.length-(s-r);return this.j=this.j.slice(0,r)+t+this.j.slice(s),this.a+=i,this.cursor>=s?this.cursor+=i:this.cursor>r&&(this.cursor=r),i},this.t=function(){return!(0>this.c)&&!(this.c>this.d)&&!(this.d>this.a)&&!(this.a>this.j.length)},this.b=function(r){var s=!1;return this.t()&&(this.s(this.c,this.d,r),s=!0),s},this.e=function(){return this.b("")},this.r=function(r,s,t){s=this.s(r,s,t),r<=this.c&&(this.c+=s),r<=this.d&&(this.d+=s)},this.u=function(){var r="";return this.t()&&(r=this.j.slice(this.c,this.d)),r},this.v=function(){return this.j.slice(0,this.a)}}let s=new function(){function s(){var r=t.a-t.cursor;if(!(t.cursor<f)){var s=t.f;t.f=f,t.d=t.cursor,0==t.h(h)?t.f=s:(t.c=t.cursor,t.f=s,t.cursor=t.a-r,t.cursor<=t.f||(t.cursor--,t.c=t.cursor,t.e()))}}var t=new r,i=[["hed",-1,1],["ethed",0,1],["ered",-1,1],["e",-1,1],["erede",3,1],["ende",3,1],["erende",5,1],["ene",3,1],["erne",3,1],["ere",3,1],["en",-1,1],["heden",10,1],["eren",10,1],["er",-1,1],["heder",13,1],["erer",13,1],["s",-1,2],["heds",16,1],["es",16,1],["endes",18,1],["erendes",19,1],["enes",18,1],["ernes",18,1],["eres",18,1],["ens",16,1],["hedens",24,1],["erens",24,1],["ers",16,1],["ets",16,1],["erets",28,1],["et",-1,1],["eret",30,1]],h=[["gd",-1,-1],["dt",-1,-1],["gt",-1,-1],["kt",-1,-1]],e=[["ig",-1,1],["lig",0,1],["elig",1,1],["els",-1,1],["l\xf8st",-1,2]],c=[119,223,119,1],u=[17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,0,48,0,128],o=[239,254,42,3,0,0,0,0,0,0,0,0,0,0,0,0,16],n=0,f=0,a="";this.l=function(){var r=t.cursor;r:{f=t.a;var h=t.cursor,d=t.cursor+3;if(!(d>t.a)){for(t.cursor=d,n=t.cursor,t.cursor=h;;){if(h=t.cursor,t.i(u,97,248)){t.cursor=h;break}if(t.cursor=h,t.cursor>=t.a)break r;t.cursor++}for(;!t.k(u,97,248);){if(t.cursor>=t.a)break r;t.cursor++}(f=t.cursor)<n&&(f=n)}}if(t.cursor=r,t.f=t.cursor,t.cursor=t.a,r=t.a-t.cursor,!(t.cursor<f))if(d=t.f,t.f=f,t.d=t.cursor,0==(h=t.h(i)))t.f=d;else switch(t.c=t.cursor,t.f=d,h){case 1:t.e();break;case 2:t.n(o,97,229)&&t.e()}if((t.cursor=t.a-r,r=t.a-t.cursor,s(),t.cursor=t.a-r,r=t.a-t.cursor,h=t.a-t.cursor,t.d=t.cursor,!(t.g("st")&&(t.c=t.cursor,t.g("ig")&&!t.e())))&&(t.cursor=t.a-h,!(t.cursor<f)))if(d=t.f,t.f=f,t.d=t.cursor,0==(h=t.h(e)))t.f=d;else switch(t.c=t.cursor,t.f=d,h){case 1:if(!t.e())break;h=t.a-t.cursor,s(),t.cursor=t.a-h;break;case 2:t.b("l\xf8s")}return t.cursor=t.a-r,r=t.a-t.cursor,t.cursor<f||(h=t.f,t.f=f,t.d=t.cursor,t.n(c,98,122)?(t.c=t.cursor,""!=(a=t.u())&&(t.f=h,t.g(a)&&t.e())):t.f=h),t.cursor=t.a-r,t.cursor=t.f,!0},this.stemWord=function(r){return t.p(r),this.l(),t.j}};export function stemmer(r){return s.stemWord(r)}export const language="danish";