@orama/stemmers
Version:
Stemmers for Orama
1 lines • 6.92 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,c=this.a,u=0,o=0,h=!1;;){var e,n=s+(t-s>>>1),a=0,f=u<o?u:o,g=r[n];for(e=f;e<g[0].length;e++){if(i+f==c){a=-1;break}if(0!=(a=this.j.charCodeAt(i+f)-g[0].charCodeAt(e)))break;f++}if(0>a?(t=n,o=f):(s=n,u=f),1>=t-s){if(0<s||t==s||h)break;h=!0}}for(;;){if(u>=(g=r[s])[0].length&&(this.cursor=i+g[0].length,4>g.length||(s=g[3](this),this.cursor=i+g[0].length,s)))return g[2];if(0>(s=g[1]))return 0}},this.h=function(r){for(var s=0,t=r.length,i=this.cursor,c=this.f,u=0,o=0,h=!1;;){var e,n=s+(t-s>>1),a=0,f=u<o?u:o,g=r[n];for(e=g[0].length-1-f;0<=e;e--){if(i-f==c){a=-1;break}if(0!=(a=this.j.charCodeAt(i-1-f)-g[0].charCodeAt(e)))break;f++}if(0>a?(t=n,o=f):(s=n,u=f),1>=t-s){if(0<s||t==s||h)break;h=!0}}for(;;){if(u>=(g=r[s])[0].length&&(this.cursor=i-g[0].length,4>g.length||(s=g[3](this),this.cursor=i-g[0].length,s)))return g[2];if(0>(s=g[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(){var s=new r,t=[["в",-1,1],["ив",0,2],["ыв",0,2],["вши",-1,1],["ивши",3,2],["ывши",3,2],["вшись",-1,1],["ившись",6,2],["ывшись",6,2]],i=[["ее",-1,1],["ие",-1,1],["ое",-1,1],["ые",-1,1],["ими",-1,1],["ыми",-1,1],["ей",-1,1],["ий",-1,1],["ой",-1,1],["ый",-1,1],["ем",-1,1],["им",-1,1],["ом",-1,1],["ым",-1,1],["его",-1,1],["ого",-1,1],["ему",-1,1],["ому",-1,1],["их",-1,1],["ых",-1,1],["ею",-1,1],["ою",-1,1],["ую",-1,1],["юю",-1,1],["ая",-1,1],["яя",-1,1]],c=[["ем",-1,1],["нн",-1,1],["вш",-1,1],["ивш",2,2],["ывш",2,2],["щ",-1,1],["ющ",5,1],["ующ",6,2]],u=[["сь",-1,1],["ся",-1,1]],o=[["ла",-1,1],["ила",0,2],["ыла",0,2],["на",-1,1],["ена",3,2],["ете",-1,1],["ите",-1,2],["йте",-1,1],["ейте",7,2],["уйте",7,2],["ли",-1,1],["или",10,2],["ыли",10,2],["й",-1,1],["ей",13,2],["уй",13,2],["л",-1,1],["ил",16,2],["ыл",16,2],["ем",-1,1],["им",-1,2],["ым",-1,2],["н",-1,1],["ен",22,2],["ло",-1,1],["ило",24,2],["ыло",24,2],["но",-1,1],["ено",27,2],["нно",27,1],["ет",-1,1],["ует",30,2],["ит",-1,2],["ыт",-1,2],["ют",-1,1],["уют",34,2],["ят",-1,2],["ны",-1,1],["ены",37,2],["ть",-1,1],["ить",39,2],["ыть",39,2],["ешь",-1,1],["ишь",-1,2],["ю",-1,2],["ую",44,2]],h=[["а",-1,1],["ев",-1,1],["ов",-1,1],["е",-1,1],["ие",3,1],["ье",3,1],["и",-1,1],["еи",6,1],["ии",6,1],["ами",6,1],["ями",6,1],["иями",10,1],["й",-1,1],["ей",12,1],["ией",13,1],["ий",12,1],["ой",12,1],["ам",-1,1],["ем",-1,1],["ием",18,1],["ом",-1,1],["ям",-1,1],["иям",21,1],["о",-1,1],["у",-1,1],["ах",-1,1],["ях",-1,1],["иях",26,1],["ы",-1,1],["ь",-1,1],["ю",-1,1],["ию",30,1],["ью",30,1],["я",-1,1],["ия",33,1],["ья",33,1]],e=[["ост",-1,1],["ость",-1,1]],n=[["ейше",-1,1],["н",-1,2],["ейш",-1,1],["ь",-1,3]],a=[33,65,8,232],f=0,g=0;this.l=function(){for(var r,l=s.cursor;;){var d=s.cursor;r:{for(;;){var b=s.cursor;if(s.c=s.cursor,s.m("ё")){s.d=s.cursor,s.cursor=b;break}if(s.cursor=b,s.cursor>=s.a)break r;s.cursor++}if(!s.b("е"))return!1;continue}s.cursor=d;break}s.cursor=l,f=g=s.a,l=s.cursor;s:{for(;!s.i(a,1072,1103);){if(s.cursor>=s.a)break s;s.cursor++}for(g=s.cursor;!s.k(a,1072,1103);){if(s.cursor>=s.a)break s;s.cursor++}for(;!s.i(a,1072,1103);){if(s.cursor>=s.a)break s;s.cursor++}for(;!s.k(a,1072,1103);){if(s.cursor>=s.a)break s;s.cursor++}f=s.cursor}if(s.cursor=l,s.f=s.cursor,s.cursor=s.a,s.cursor<g)return!1;if(l=s.f,s.f=g,d=s.a-s.cursor,b=s.a-s.cursor,!function(){var r;if(s.d=s.cursor,0==(r=s.h(t)))return!1;switch(s.c=s.cursor,r){case 1:if((r=s.a-s.cursor,!s.g("а"))&&(s.cursor=s.a-r,!s.g("я")))return!1;if(!s.e())return!1;break;case 2:if(!s.e())return!1}return!0}()){s.cursor=s.a-b,b=s.a-s.cursor,s.d=s.cursor,0==s.h(u)?r=!1:(s.c=s.cursor,r=!!s.e()),r||(s.cursor=s.a-b);t:if(b=s.a-s.cursor,!function(){var r,t;if(s.d=s.cursor,0==s.h(i)?t=!1:(s.c=s.cursor,t=!!s.e()),!t)return!1;t=s.a-s.cursor;s:if(s.d=s.cursor,0==(r=s.h(c)))s.cursor=s.a-t;else switch(s.c=s.cursor,r){case 1:if((r=s.a-s.cursor,!s.g("а"))&&(s.cursor=s.a-r,!s.g("я"))){s.cursor=s.a-t;break s}if(!s.e())return!1;break;case 2:if(!s.e())return!1}return!0}()){if(s.cursor=s.a-b,function(){var r;if(s.d=s.cursor,0==(r=s.h(o)))return!1;switch(s.c=s.cursor,r){case 1:if((r=s.a-s.cursor,!s.g("а"))&&(s.cursor=s.a-r,!s.g("я")))return!1;if(!s.e())return!1;break;case 2:if(!s.e())return!1}return!0}())break t;s.cursor=s.a-b,s.d=s.cursor,0!=s.h(h)&&(s.c=s.cursor,s.e())}}if(s.cursor=s.a-d,d=s.a-s.cursor,s.d=s.cursor,s.g("и")){if(s.c=s.cursor,!s.e())return!1}else s.cursor=s.a-d;if(d=s.a-s.cursor,s.d=s.cursor,0!=s.h(e)&&(s.c=s.cursor,f<=s.cursor&&s.e()),s.cursor=s.a-d,d=s.a-s.cursor,s.d=s.cursor,0!=(b=s.h(n)))switch(s.c=s.cursor,b){case 1:if(!s.e()||(s.d=s.cursor,!s.g("н")))break;s.c=s.cursor,s.g("н")&&s.e();break;case 2:s.g("н")&&s.e();break;case 3:s.e()}return s.cursor=s.a-d,s.f=l,s.cursor=s.f,!0},this.stemWord=function(r){return s.p(r),this.l(),s.j}};export function stemmer(r){return s.stemWord(r)}export const language="russian";