@orama/stemmers
Version:
Stemmers for Orama
1 lines • 12.4 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,e,s){if(this.cursor>=this.a)return!1;var t=this.j.charCodeAt(this.cursor);return!(t>s)&&!(t<e)&&0!=(r[(t-=e)>>>3]&1<<(7&t))&&(this.cursor++,!0)},this.n=function(r,e,s){if(this.cursor<=this.f)return!1;var t=this.j.charCodeAt(this.cursor-1);return!(t>s)&&!(t<e)&&0!=(r[(t-=e)>>>3]&1<<(7&t))&&(this.cursor--,!0)},this.k=function(r,e,s){if(this.cursor>=this.a)return!1;var t=this.j.charCodeAt(this.cursor);return t>s||t<e?(this.cursor++,!0):0==(r[(t-=e)>>>3]&1<<(7&t))&&(this.cursor++,!0)},this.q=function(r,e,s){if(this.cursor<=this.f)return!1;var t=this.j.charCodeAt(this.cursor-1);return t>s||t<e?(this.cursor--,!0):0==(r[(t-=e)>>>3]&1<<(7&t))&&(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 e=0,s=r.length,t=this.cursor,c=this.a,u=0,i=0,a=!1;;){var n,o=e+(s-e>>>1),h=0,f=u<i?u:i,b=r[o];for(n=f;n<b[0].length;n++){if(t+f==c){h=-1;break}if(0!=(h=this.j.charCodeAt(t+f)-b[0].charCodeAt(n)))break;f++}if(0>h?(s=o,i=f):(e=o,u=f),1>=s-e){if(0<e||s==e||a)break;a=!0}}for(;;){if(u>=(b=r[e])[0].length&&(this.cursor=t+b[0].length,4>b.length||(e=b[3](this),this.cursor=t+b[0].length,e)))return b[2];if(0>(e=b[1]))return 0}},this.h=function(r){for(var e=0,s=r.length,t=this.cursor,c=this.f,u=0,i=0,a=!1;;){var n,o=e+(s-e>>1),h=0,f=u<i?u:i,b=r[o];for(n=b[0].length-1-f;0<=n;n--){if(t-f==c){h=-1;break}if(0!=(h=this.j.charCodeAt(t-1-f)-b[0].charCodeAt(n)))break;f++}if(0>h?(s=o,i=f):(e=o,u=f),1>=s-e){if(0<e||s==e||a)break;a=!0}}for(;;){if(u>=(b=r[e])[0].length&&(this.cursor=t-b[0].length,4>b.length||(e=b[3](this),this.cursor=t-b[0].length,e)))return b[2];if(0>(e=b[1]))return 0}},this.s=function(r,e,s){var t=s.length-(e-r);return this.j=this.j.slice(0,r)+s+this.j.slice(e),this.a+=t,this.cursor>=e?this.cursor+=t:this.cursor>r&&(this.cursor=r),t},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 e=!1;return this.t()&&(this.s(this.c,this.d,r),e=!0),e},this.e=function(){return this.b("")},this.r=function(r,e,s){e=this.s(r,e,s),r<=this.c&&(this.c+=e),r<=this.d&&(this.d+=e)},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 e=new function(){function e(){return u.d=u.cursor,0!=u.h(v)&&(u.c=u.cursor,!!(4<u.j.length&&u.e()))}function s(){return u.d=u.cursor,0!=u.h(w)&&(u.c=u.cursor,!!(5<=u.j.length&&u.e()))}function t(){return u.d=u.cursor,0!=u.h(A)&&(u.c=u.cursor,!!(4<=u.j.length&&u.e()))}function c(){var r;if(u.d=u.cursor,0==(r=u.h(x)))return!1;switch(u.c=u.cursor,r){case 1:if(!(4<=u.j.length)||!u.e())return!1;break;case 2:if(!(5<=u.j.length)||!u.e())return!1;break;case 3:if(!(5<u.j.length)||!u.e())return!1;break;case 4:if(!(6<=u.j.length)||!u.e())return!1}return!0}var u=new r,i=[["ـ",-1,1],["ً",-1,1],["ٌ",-1,1],["ٍ",-1,1],["َ",-1,1],["ُ",-1,1],["ِ",-1,1],["ّ",-1,1],["ْ",-1,1],["٠",-1,2],["١",-1,3],["٢",-1,4],["٣",-1,5],["٤",-1,6],["٥",-1,7],["٦",-1,8],["٧",-1,9],["٨",-1,10],["٩",-1,11],["ﺀ",-1,12],["ﺁ",-1,16],["ﺂ",-1,16],["ﺃ",-1,13],["ﺄ",-1,13],["ﺅ",-1,17],["ﺆ",-1,17],["ﺇ",-1,14],["ﺈ",-1,14],["ﺉ",-1,15],["ﺊ",-1,15],["ﺋ",-1,15],["ﺌ",-1,15],["ﺍ",-1,18],["ﺎ",-1,18],["ﺏ",-1,19],["ﺐ",-1,19],["ﺑ",-1,19],["ﺒ",-1,19],["ﺓ",-1,20],["ﺔ",-1,20],["ﺕ",-1,21],["ﺖ",-1,21],["ﺗ",-1,21],["ﺘ",-1,21],["ﺙ",-1,22],["ﺚ",-1,22],["ﺛ",-1,22],["ﺜ",-1,22],["ﺝ",-1,23],["ﺞ",-1,23],["ﺟ",-1,23],["ﺠ",-1,23],["ﺡ",-1,24],["ﺢ",-1,24],["ﺣ",-1,24],["ﺤ",-1,24],["ﺥ",-1,25],["ﺦ",-1,25],["ﺧ",-1,25],["ﺨ",-1,25],["ﺩ",-1,26],["ﺪ",-1,26],["ﺫ",-1,27],["ﺬ",-1,27],["ﺭ",-1,28],["ﺮ",-1,28],["ﺯ",-1,29],["ﺰ",-1,29],["ﺱ",-1,30],["ﺲ",-1,30],["ﺳ",-1,30],["ﺴ",-1,30],["ﺵ",-1,31],["ﺶ",-1,31],["ﺷ",-1,31],["ﺸ",-1,31],["ﺹ",-1,32],["ﺺ",-1,32],["ﺻ",-1,32],["ﺼ",-1,32],["ﺽ",-1,33],["ﺾ",-1,33],["ﺿ",-1,33],["ﻀ",-1,33],["ﻁ",-1,34],["ﻂ",-1,34],["ﻃ",-1,34],["ﻄ",-1,34],["ﻅ",-1,35],["ﻆ",-1,35],["ﻇ",-1,35],["ﻈ",-1,35],["ﻉ",-1,36],["ﻊ",-1,36],["ﻋ",-1,36],["ﻌ",-1,36],["ﻍ",-1,37],["ﻎ",-1,37],["ﻏ",-1,37],["ﻐ",-1,37],["ﻑ",-1,38],["ﻒ",-1,38],["ﻓ",-1,38],["ﻔ",-1,38],["ﻕ",-1,39],["ﻖ",-1,39],["ﻗ",-1,39],["ﻘ",-1,39],["ﻙ",-1,40],["ﻚ",-1,40],["ﻛ",-1,40],["ﻜ",-1,40],["ﻝ",-1,41],["ﻞ",-1,41],["ﻟ",-1,41],["ﻠ",-1,41],["ﻡ",-1,42],["ﻢ",-1,42],["ﻣ",-1,42],["ﻤ",-1,42],["ﻥ",-1,43],["ﻦ",-1,43],["ﻧ",-1,43],["ﻨ",-1,43],["ﻩ",-1,44],["ﻪ",-1,44],["ﻫ",-1,44],["ﻬ",-1,44],["ﻭ",-1,45],["ﻮ",-1,45],["ﻯ",-1,46],["ﻰ",-1,46],["ﻱ",-1,47],["ﻲ",-1,47],["ﻳ",-1,47],["ﻴ",-1,47],["ﻵ",-1,51],["ﻶ",-1,51],["ﻷ",-1,49],["ﻸ",-1,49],["ﻹ",-1,50],["ﻺ",-1,50],["ﻻ",-1,48],["ﻼ",-1,48]],a=[["آ",-1,1],["أ",-1,1],["ؤ",-1,1],["إ",-1,1],["ئ",-1,1]],n=[["آ",-1,1],["أ",-1,1],["ؤ",-1,2],["إ",-1,1],["ئ",-1,3]],o=[["ال",-1,2],["بال",-1,1],["كال",-1,1],["لل",-1,2]],h=[["أآ",-1,2],["أأ",-1,1],["أؤ",-1,1],["أإ",-1,4],["أا",-1,3]],f=[["ف",-1,1],["و",-1,1]],b=[["ال",-1,2],["بال",-1,1],["كال",-1,1],["لل",-1,2]],k=[["ب",-1,1],["با",0,-1],["بب",0,2],["كك",-1,3]],l=[["سأ",-1,4],["ست",-1,2],["سن",-1,3],["سي",-1,1]],g=[["تست",-1,1],["نست",-1,1],["يست",-1,1]],j=[["كما",-1,3],["هما",-1,3],["نا",-1,2],["ها",-1,2],["ك",-1,1],["كم",-1,2],["هم",-1,2],["هن",-1,2],["ه",-1,1],["ي",-1,1]],d=[["ن",-1,1]],v=[["ا",-1,1],["و",-1,1],["ي",-1,1]],w=[["ات",-1,1]],A=[["ت",-1,1]],C=[["ة",-1,1]],m=[["ي",-1,1]],p=[["كما",-1,3],["هما",-1,3],["نا",-1,2],["ها",-1,2],["ك",-1,1],["كم",-1,2],["هم",-1,2],["كن",-1,2],["هن",-1,2],["ه",-1,1],["كمو",-1,3],["ني",-1,2]],x=[["ا",-1,1],["تا",0,2],["تما",0,4],["نا",0,2],["ت",-1,1],["ن",-1,1],["ان",5,3],["تن",5,2],["ون",5,3],["ين",5,3],["ي",-1,1]],W=[["وا",-1,1],["تم",-1,1]],q=[["و",-1,1],["تمو",0,2]],z=[["ى",-1,1]],y=!1,B=!1,D=!1;this.l=function(){B=D=!0,y=!1;var r,v=u.cursor;if(u.c=u.cursor,0!=(r=u.o(o)))switch(u.d=u.cursor,r){case 1:if(!(4<u.j.length))break;D=!0,B=!1,y=!0;break;case 2:if(!(3<u.j.length))break;D=!0,B=!1,y=!0}u.cursor=v,function(){for(var r,e=u.cursor;;){var s=u.cursor;r:{e:{var t=u.cursor;if(u.c=u.cursor,0!=(r=u.o(i))){switch(u.d=u.cursor,r){case 1:if(!u.e())return;break;case 2:if(!u.b("0"))return;break;case 3:if(!u.b("1"))return;break;case 4:if(!u.b("2"))return;break;case 5:if(!u.b("3"))return;break;case 6:if(!u.b("4"))return;break;case 7:if(!u.b("5"))return;break;case 8:if(!u.b("6"))return;break;case 9:if(!u.b("7"))return;break;case 10:if(!u.b("8"))return;break;case 11:if(!u.b("9"))return;break;case 12:if(!u.b("ء"))return;break;case 13:if(!u.b("أ"))return;break;case 14:if(!u.b("إ"))return;break;case 15:if(!u.b("ئ"))return;break;case 16:if(!u.b("آ"))return;break;case 17:if(!u.b("ؤ"))return;break;case 18:if(!u.b("ا"))return;break;case 19:if(!u.b("ب"))return;break;case 20:if(!u.b("ة"))return;break;case 21:if(!u.b("ت"))return;break;case 22:if(!u.b("ث"))return;break;case 23:if(!u.b("ج"))return;break;case 24:if(!u.b("ح"))return;break;case 25:if(!u.b("خ"))return;break;case 26:if(!u.b("د"))return;break;case 27:if(!u.b("ذ"))return;break;case 28:if(!u.b("ر"))return;break;case 29:if(!u.b("ز"))return;break;case 30:if(!u.b("س"))return;break;case 31:if(!u.b("ش"))return;break;case 32:if(!u.b("ص"))return;break;case 33:if(!u.b("ض"))return;break;case 34:if(!u.b("ط"))return;break;case 35:if(!u.b("ظ"))return;break;case 36:if(!u.b("ع"))return;break;case 37:if(!u.b("غ"))return;break;case 38:if(!u.b("ف"))return;break;case 39:if(!u.b("ق"))return;break;case 40:if(!u.b("ك"))return;break;case 41:if(!u.b("ل"))return;break;case 42:if(!u.b("م"))return;break;case 43:if(!u.b("ن"))return;break;case 44:if(!u.b("ه"))return;break;case 45:if(!u.b("و"))return;break;case 46:if(!u.b("ى"))return;break;case 47:if(!u.b("ي"))return;break;case 48:if(!u.b("لا"))return;break;case 49:if(!u.b("لأ"))return;break;case 50:if(!u.b("لإ"))return;break;case 51:if(!u.b("لآ"))return}break e}if(u.cursor=t,u.cursor>=u.a)break r;u.cursor++}continue}u.cursor=s;break}u.cursor=e}(),u.f=u.cursor,u.cursor=u.a,v=u.a-u.cursor;r:{r=u.a-u.cursor;e:if(B){s:{var w=u.a-u.cursor;t:{for(var A=1;;){var x=u.a-u.cursor;if(function(){var r;if(u.d=u.cursor,0==(r=u.h(p)))return!1;switch(u.c=u.cursor,r){case 1:if(!(4<=u.j.length)||!u.e())return!1;break;case 2:if(!(5<=u.j.length)||!u.e())return!1;break;case 3:if(!(6<=u.j.length)||!u.e())return!1}return!0}()){A--;continue}u.cursor=u.a-x;break}if(!(0<A)){c:if(A=u.a-u.cursor,!c()){if(u.cursor=u.a-A,function(){var r;if(u.d=u.cursor,0==(r=u.h(q)))return!1;switch(u.c=u.cursor,r){case 1:if(!(4<=u.j.length)||!u.e())return!1;break;case 2:if(!(6<=u.j.length)||!u.e())return!1}return!0}())break c;if(u.cursor=u.a-A,u.cursor<=u.f)break t;u.cursor--}break s}}if(u.cursor=u.a-w,u.d=u.cursor,0==u.h(W)?A=!1:(u.c=u.cursor,A=!!(5<=u.j.length&&u.e())),A)break s;if(u.cursor=u.a-w,!c())break e}break r}if(u.cursor=u.a-r,D){w=u.a-u.cursor;t:if(A=u.a-u.cursor,u.d=u.cursor,0==u.h(C)?x=!1:(u.c=u.cursor,x=!!(4<=u.j.length&&u.e())),!x){u.cursor=u.a-A;c:if(!y&&function(){var r;if(u.d=u.cursor,0==(r=u.h(j)))return!1;switch(u.c=u.cursor,r){case 1:if(!(4<=u.j.length)||!u.e())return!1;break;case 2:if(!(5<=u.j.length)||!u.e())return!1;break;case 3:if(!(6<=u.j.length)||!u.e())return!1}return!0}()){u:if(x=u.a-u.cursor,!e()){if(u.cursor=u.a-x,s()||(u.cursor=u.a-x,t()))break u;if(u.cursor=u.a-x,u.cursor<=u.f)break c;u.cursor--}break t}u.cursor=u.a-A;c:if(u.d=u.cursor,0==u.h(d)?x=!1:(u.c=u.cursor,x=!!(5<u.j.length&&u.e())),x){u:if(x=u.a-u.cursor,!e()){if(u.cursor=u.a-x,s())break u;if(u.cursor=u.a-x,!t())break c}break t}if(u.cursor=u.a-A,!y&&e())break t;u.cursor=u.a-A,s()||(u.cursor=u.a-w)}if(u.d=u.cursor,0==u.h(m)?w=!1:(u.c=u.cursor,w=!!(3<=u.j.length&&u.e())),w)break r}u.cursor=u.a-r,u.d=u.cursor,0!=u.h(z)&&(u.c=u.cursor,u.b("ي"))}u.cursor=u.a-v,u.cursor=u.f,v=u.cursor,r=u.cursor,function(){var r;if(u.c=u.cursor,0==(r=u.o(h)))return!1;switch(u.d=u.cursor,r){case 1:if(!(3<u.j.length)||!u.b("أ"))return!1;break;case 2:if(!(3<u.j.length)||!u.b("آ"))return!1;break;case 3:if(!(3<u.j.length)||!u.b("ا"))return!1;break;case 4:if(!(3<u.j.length)||!u.b("إ"))return!1}return!0}()||(u.cursor=r),r=u.cursor,function(){if(u.c=u.cursor,0==u.o(f)||(u.d=u.cursor,!(3<u.j.length)))return!1;var r=u.cursor;return!u.m("ا")&&(u.cursor=r,!!u.e())}()||(u.cursor=r);r:if(r=u.cursor,!function(){var r;if(u.c=u.cursor,0==(r=u.o(b)))return!1;switch(u.d=u.cursor,r){case 1:if(!(5<u.j.length)||!u.e())return!1;break;case 2:if(!(4<u.j.length)||!u.e())return!1}return!0}()){if(u.cursor=r,D&&function(){var r;if(u.c=u.cursor,0==(r=u.o(k)))return!1;switch(u.d=u.cursor,r){case 1:if(!(3<u.j.length)||!u.e())return!1;break;case 2:if(!(3<u.j.length)||!u.b("ب"))return!1;break;case 3:if(!(3<u.j.length)||!u.b("ك"))return!1}return!0}())break r;u.cursor=r,B&&(r=u.cursor,function(){var r;if(u.c=u.cursor,0==(r=u.o(l)))return!1;switch(u.d=u.cursor,r){case 1:if(!(4<u.j.length)||!u.b("ي"))return!1;break;case 2:if(!(4<u.j.length)||!u.b("ت"))return!1;break;case 3:if(!(4<u.j.length)||!u.b("ن"))return!1;break;case 4:if(!(4<u.j.length)||!u.b("أ"))return!1}return!0}()||(u.cursor=r),u.c=u.cursor,0!=u.o(g)&&(u.d=u.cursor,4<u.j.length&&(B=!0,D=!1,u.b("است"))))}return u.cursor=v,!function(){if(r=u.cursor,u.f=u.cursor,u.cursor=u.a,u.d=u.cursor,0!=u.h(a)){if(u.c=u.cursor,!u.b("ء"))return;u.cursor=u.f}u.cursor=r;for(var r,e=u.cursor;;){var s=u.cursor;r:{e:{var t=u.cursor;if(u.c=u.cursor,0!=(r=u.o(n))){switch(u.d=u.cursor,r){case 1:if(!u.b("ا"))return;break;case 2:if(!u.b("و"))return;break;case 3:if(!u.b("ي"))return}break e}if(u.cursor=t,u.cursor>=u.a)break r;u.cursor++}continue}u.cursor=s;break}u.cursor=e}(),!0},this.stemWord=function(r){return u.p(r),this.l(),u.j}};export function stemmer(r){return e.stemWord(r)}export const language="arabic";