@orama/stemmers
Version:
Stemmers for Orama
1 lines • 5.01 kB
JavaScript
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,u=this.a,c=0,h=0,e=!1;;){var n,o=s+(t-s>>>1),a=0,f=c<h?c:h,b=r[o];for(n=f;n<b[0].length;n++){if(i+f==u){a=-1;break}if(0!=(a=this.j.charCodeAt(i+f)-b[0].charCodeAt(n)))break;f++}if(0>a?(t=o,h=f):(s=o,c=f),1>=t-s){if(0<s||t==s||e)break;e=!0}}for(;;){if(c>=(b=r[s])[0].length&&(this.cursor=i+b[0].length,4>b.length||(s=b[3](this),this.cursor=i+b[0].length,s)))return b[2];if(0>(s=b[1]))return 0}},this.h=function(r){for(var s=0,t=r.length,i=this.cursor,u=this.f,c=0,h=0,e=!1;;){var n,o=s+(t-s>>1),a=0,f=c<h?c:h,b=r[o];for(n=b[0].length-1-f;0<=n;n--){if(i-f==u){a=-1;break}if(0!=(a=this.j.charCodeAt(i-1-f)-b[0].charCodeAt(n)))break;f++}if(0>a?(t=o,h=f):(s=o,c=f),1>=t-s){if(0<s||t==s||e)break;e=!0}}for(;;){if(c>=(b=r[s])[0].length&&(this.cursor=i-b[0].length,4>b.length||(s=b[3](this),this.cursor=i-b[0].length,s)))return b[2];if(0>(s=b[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(){return u.d=u.cursor,0!=u.h(e)&&(u.c=u.cursor,!!u.e()&&(b-=1,!0))}function t(){return!!u.i(a,97,117)}function i(){var r;if(u.c=u.cursor,0!=(r=u.o(o)))switch(u.d=u.cursor,r){case 1:if(!u.e())break;f=2,b-=1;break;case 2:if(!u.b("ajar"))break;b-=1;break;case 3:if(!u.e())break;f=4,b-=1;break;case 4:if(!u.b("ajar"))break;f=4,b-=1}}var u=new r,c=[["kah",-1,1],["lah",-1,1],["pun",-1,1]],h=[["nya",-1,1],["ku",-1,1],["mu",-1,1]],e=[["i",-1,1,function(){if(!(2>=f))return!1;var r=u.a-u.cursor;return!u.g("s")&&(u.cursor=u.a-r,!0)}],["an",-1,1,function(){return 1!=f}],["kan",1,1,function(){return 3!=f&&2!=f}]],n=[["di",-1,1],["ke",-1,2],["me",-1,1],["mem",2,5],["men",2,1],["meng",4,1],["meny",4,3,t],["pem",-1,6],["pen",-1,2],["peng",8,2],["peny",8,4,t],["ter",-1,1]],o=[["be",-1,3,function(){return!!(u.k(a,97,117)&&u.m("er"))}],["belajar",0,4],["ber",0,3],["pe",-1,1],["pelajar",3,2],["per",3,1]],a=[17,65,16],f=0,b=0;this.l=function(){b=0;for(var r=u.cursor;;){var t=u.cursor;r:{for(;!u.i(a,97,117);){if(u.cursor>=u.a)break r;u.cursor++}b+=1;continue}u.cursor=t;break}if(u.cursor=r,!(2<b)||(f=0,u.f=u.cursor,u.cursor=u.a,r=u.a-u.cursor,u.d=u.cursor,0!=u.h(c)&&(u.c=u.cursor,u.e()&&(b-=1)),u.cursor=u.a-r,!(2<b))||(r=u.a-u.cursor,u.d=u.cursor,0!=u.h(h)&&(u.c=u.cursor,u.e()&&(b-=1)),u.cursor=u.a-r,u.cursor=u.f,!(2<b)))return!1;s:{if(t=u.cursor,r=u.cursor,function(){var r;if(u.c=u.cursor,0==(r=u.o(n)))return!1;switch(u.d=u.cursor,r){case 1:if(!u.e())return!1;f=1,b-=1;break;case 2:if(!u.e())return!1;f=3,b-=1;break;case 3:if(f=1,!u.b("s"))return!1;b-=1;break;case 4:if(f=3,!u.b("s"))return!1;b-=1;break;case 5:f=1,b-=1;s:{r=u.cursor;var s=u.cursor;if(u.i(a,97,117)){if(u.cursor=s,!u.b("p"))return!1;break s}if(u.cursor=r,!u.e())return!1}break;case 6:f=3,b-=1;s:{if(r=u.cursor,s=u.cursor,u.i(a,97,117)){if(u.cursor=s,!u.b("p"))return!1;break s}if(u.cursor=r,!u.e())return!1}}return!0}()){t=u.cursor;var e=u.cursor;2<b&&(u.f=u.cursor,u.cursor=u.a,s()&&(u.cursor=u.f,u.cursor=e,2<b&&i())),u.cursor=t,u.cursor=r;break s}u.cursor=t,r=u.cursor,i(),u.cursor=r,r=u.cursor,2<b&&(u.f=u.cursor,u.cursor=u.a,s()&&(u.cursor=u.f)),u.cursor=r}return!0},this.stemWord=function(r){return u.p(r),this.l(),u.j}};export function stemmer(r){return s.stemWord(r)}export const language="indonesian";