|
389 | 389 | return((0x7fffffff&hash)*2)+start; |
390 | 390 | } |
391 | 391 |
|
392 | | -functiontoTenBitHash(hash){ |
393 | | -// Специально для 1024-битного фильтра Блума |
394 | | -return(hash>>>30)^ |
395 | | -((hash>>>20)&0x3ff)^ |
396 | | -((hash>>>10)&0x3ff)^ |
397 | | -(hash&0x3ff); |
| 392 | +functionto11BitHash(hash){ |
| 393 | +// Специально для 2048-битного фильтра Блума |
| 394 | +return((hash>>>22)&0x7ff)^ |
| 395 | +((hash>>>11)&0x7ff)^ |
| 396 | +(hash&0x7ff); |
398 | 397 | } |
399 | 398 |
|
400 | 399 | /** |
401 | | - *@param {Uint8ClampedArray} filter -128 bytes |
402 | | - *@param {number}hash10 -Ten bits |
| 400 | + *@param {Uint8ClampedArray} filter -256 bytes |
| 401 | + *@param {number}hash11 -Eleven bits |
403 | 402 | *@returns {boolean} |
404 | 403 | */ |
405 | | -functioninBloom(filter,hash10){ |
406 | | -return!!((filter[hash10>>>3]>>>(7-(hash10%8)))&1); |
| 404 | +functioninBloom(filter,hash11){ |
| 405 | +return!!((filter[hash11>>>3]>>>(7-(hash11%8)))&1); |
407 | 406 | } |
408 | 407 |
|
409 | | -functionbloomAdd(filter,hash10){ |
410 | | -constindex=hash10>>>3; |
411 | | -filter[index]=filter[index]|(1<<(7-(hash10%8))); |
| 408 | +functionbloomAdd(filter,hash11){ |
| 409 | +constindex=hash11>>>3; |
| 410 | +filter[index]=filter[index]|(1<<(7-(hash11%8))); |
412 | 411 | } |
413 | 412 |
|
414 | 413 | functionpackEnding(lowerCaseUnicodeString){ |
|
478 | 477 | 126869,23630,11218 |
479 | 478 | ]); |
480 | 479 |
|
481 | | -conststressBloomAB=newUint8ClampedArray(128); |
482 | | -stressHashesA.forEach(h=>bloomAdd(stressBloomAB,toTenBitHash(h))); |
483 | | -stressHashesB.forEach(h=>bloomAdd(stressBloomAB,toTenBitHash(h))); |
| 480 | +conststressBloomAB=newUint8ClampedArray(256); |
| 481 | +stressHashesA.forEach(h=>bloomAdd(stressBloomAB,to11BitHash(h))); |
| 482 | +stressHashesB.forEach(h=>bloomAdd(stressBloomAB,to11BitHash(h))); |
484 | 483 |
|
485 | 484 | // Stemmer data |
486 | 485 | constmobileVowelA=newSet(['бубен','бугор', |
|
854 | 853 | homonyms.push([extendedFlags,settings]); |
855 | 854 | } |
856 | 855 |
|
857 | | -bloomAdd(_bloomFilter,toTenBitHash(lemmaObject._hash)); |
| 856 | +bloomAdd(_bloomFilter,to11BitHash(lemmaObject._hash)); |
858 | 857 | }; |
859 | 858 |
|
860 | 859 | const_toResult=ch=>{ |
|
872 | 871 | } |
873 | 872 |
|
874 | 873 | this.hasStressedEndingSingular=function(query,grCase){ |
875 | | -if(inBloom(_bloomFilter,toTenBitHash(query._hash))){ |
| 874 | +if(inBloom(_bloomFilter,to11BitHash(query._hash))){ |
876 | 875 |
|
877 | 876 | constcaseIndex=CaseValues.indexOf(grCase); |
878 | 877 |
|
|
896 | 895 | }; |
897 | 896 |
|
898 | 897 | this.hasStressedEndingPlural=function(query,grCase){ |
899 | | -if(inBloom(_bloomFilter,toTenBitHash(query._hash))){ |
| 898 | +if(inBloom(_bloomFilter,to11BitHash(query._hash))){ |
900 | 899 |
|
901 | 900 | constcaseIndex=CaseValues.indexOf(grCase); |
902 | 901 |
|
|
2064 | 2063 | } |
2065 | 2064 | } |
2066 | 2065 |
|
2067 | | -consthighPriorityBloomFilter=newUint8ClampedArray(128); |
| 2066 | +consthighPriorityBloomFilter=newUint8ClampedArray(256); |
2068 | 2067 | consthighPriorityExceptions=Object.freeze([ |
2069 | 2068 | [ |
2070 | 2069 | [ |
|
2161 | 2160 |
|
2162 | 2161 | for(construleofhighPriorityExceptions){ |
2163 | 2162 | Object.keys(rule[1]).map(word=> |
2164 | | -bloomAdd(highPriorityBloomFilter,toTenBitHash(calculateHash(word)))); |
| 2163 | +bloomAdd(highPriorityBloomFilter,to11BitHash(calculateHash(word)))); |
2165 | 2164 | } |
2166 | 2165 |
|
2167 | 2166 | // Слова в первом склонении, которые оканчиваются на -я в мн.ч., |
|
2337 | 2336 | } |
2338 | 2337 | } |
2339 | 2338 |
|
2340 | | -if(inBloom(highPriorityBloomFilter,toTenBitHash(lemma._hash))){ |
| 2339 | +if(inBloom(highPriorityBloomFilter,to11BitHash(lemma._hash))){ |
2341 | 2340 | for(const[key,genderExceptions]ofhighPriorityExceptions){ |
2342 | 2341 |
|
2343 | 2342 | constkeyGender=key[0]; |
|