1
0
mirror of https://github.com/nextapps-de/flexsearch.git synced 2025-09-01 09:53:56 +02:00

MOD minor refactoring

This commit is contained in:
Thomas Wilkerling
2018-04-23 09:32:12 +02:00
parent 382bc4846e
commit fe544b773a
6 changed files with 73 additions and 49 deletions

View File

@@ -72,7 +72,7 @@ __Note:__ This feature is actually not enabled by default.
###### TF-IDF / BM25? ###### TF-IDF / BM25?
> "TF-IDF and all kinds of variations (like BM25) is a big mistake in searching algorithm today. They does'nt provide either: a meaningful relevance of a term as well as the importance of it! Like many pseudo-intelligent algorithm this is also an example of mathematical stupidity." — Thomas Wilkerling, _Contextual-based Scoring_, 2018 > "TF-IDF and all kinds of variations (like BM25) is a big mistake in searching algorithms today. They don't provide neither: a meaningful relevance of a term nor the importance of it! Like many pseudo-intelligent algorithms this is also just an example of mathematical stupidity." — Thomas Wilkerling, _Contextual-based Scoring_, 2018
<a name="webworker"></a> <a name="webworker"></a>
#### Web-Worker Support #### Web-Worker Support

View File

@@ -266,7 +266,7 @@ var SUPPORT_ASYNC = true;
//if(options){ //if(options){
options || (options = defaults); options || (options = defaults);
var custom = options['profile']; var custom = options['profile'];
var profile = custom ? profiles[custom] : {}; var profile = custom ? profiles[custom] : {};
@@ -279,10 +279,10 @@ var SUPPORT_ASYNC = true;
options['worker'] = false; options['worker'] = false;
if(SUPPORT_ASYNC){ // if(SUPPORT_ASYNC){
//
options['async'] = true; // options['async'] = true;
} // }
this._worker = null; this._worker = null;
} }
@@ -295,11 +295,14 @@ var SUPPORT_ASYNC = true;
self._task_completed = 0; self._task_completed = 0;
self._task_result = []; self._task_result = [];
self._current_callback = null; self._current_callback = null;
//self._ids_count = new Array(threads);
self._worker = new Array(threads); self._worker = new Array(threads);
for(var i = 0; i < threads; i++){ for(var i = 0; i < threads; i++){
self._worker[i] = add_worker(self.id, i, options || defaults, function(id, query, result, limit){ //self._ids_count[i] = 0;
self._worker[i] = add_worker(self.id, i, options /*|| defaults*/, function(id, query, result, limit){
if(self._task_completed === self.worker){ if(self._task_completed === self.worker){
@@ -317,6 +320,7 @@ var SUPPORT_ASYNC = true;
if(self._current_callback && (self._task_completed === self.worker)){ if(self._current_callback && (self._task_completed === self.worker)){
// store result to cache // store result to cache
// TODO: add worker cache, may remove global cache
if(self.cache){ if(self.cache){
@@ -326,6 +330,8 @@ var SUPPORT_ASYNC = true;
self._current_callback(self._task_result); self._current_callback(self._task_result);
self._task_result = []; self._task_result = [];
} }
return self;
}); });
} }
} }
@@ -433,10 +439,11 @@ var SUPPORT_ASYNC = true;
*/ */
this._timer = null; this._timer = null;
this._status = true;
if(SUPPORT_CACHE) { if(SUPPORT_CACHE) {
this._cache_status = true;
this.cache = custom = ( this.cache = custom = (
options['cache'] || options['cache'] ||
@@ -557,7 +564,10 @@ var SUPPORT_ASYNC = true;
if(SUPPORT_WORKER && this.worker){ if(SUPPORT_WORKER && this.worker){
if(++this._current_task >= this._worker.length) this._current_task = 0; if(++this._current_task >= this._worker.length){
this._current_task = 0;
}
this._worker[this._current_task].postMessage(this._current_task, { this._worker[this._current_task].postMessage(this._current_task, {
@@ -568,9 +578,15 @@ var SUPPORT_ASYNC = true;
this._ids[id] = "" + this._current_task; this._ids[id] = "" + this._current_task;
// TODO: improve auto-balancing
//this._ids_count[this._current_task]++;
return this; return this;
} }
// collect tasks for non-blocking processing
// TODO: actually auto-enabled in worker
if(SUPPORT_ASYNC && this.async){ if(SUPPORT_ASYNC && this.async){
this._stack[id] || ( this._stack[id] || (
@@ -766,7 +782,11 @@ var SUPPORT_ASYNC = true;
// update status // update status
this._ids[id] = "1"; this._ids[id] = "1";
this._status = false;
if(SUPPORT_CACHE){
this._cache_status = false;
}
} }
} }
@@ -801,14 +821,16 @@ var SUPPORT_ASYNC = true;
if(SUPPORT_WORKER && this.worker){ if(SUPPORT_WORKER && this.worker){
var int = parseInt(this._ids[id], 10); var current_task = parseInt(this._ids[id], 10);
this._worker[int].postMessage(int, { this._worker[current_task].postMessage(current_task, {
'remove': true, 'remove': true,
'id': id 'id': id
}); });
//this._ids_count[current_task]--;
delete this._ids[id]; delete this._ids[id];
return this; return this;
@@ -844,7 +866,10 @@ var SUPPORT_ASYNC = true;
delete this._ids[id]; delete this._ids[id];
this._status = false; if(SUPPORT_CACHE){
this._cache_status = false;
}
} }
return this; return this;
@@ -928,27 +953,26 @@ var SUPPORT_ASYNC = true;
/** @type {!string|Array<string>} */ /** @type {!string|Array<string>} */
var _query = query; var _query = query;
// invalidate cache if(SUPPORT_CACHE && this.cache){
if(!this._status){ // invalidate cache
if(SUPPORT_CACHE && this.cache){ if(!this._cache_status){
this._cache.reset(); this._cache.reset();
this._cache_status = true;
} }
this._status = true; // validate cache
}
// validate cache else {
else if(SUPPORT_CACHE && this.cache){ var cache = this._cache.get(query);
var cache = this._cache.get(query); if(cache){
if(cache){ return cache;
}
return cache;
} }
} }
@@ -1153,7 +1177,7 @@ var SUPPORT_ASYNC = true;
'items': items, 'items': items,
'sequences': words, 'sequences': words,
'chars': chars, 'chars': chars,
'status': this._status, //'status': this._cache_status,
'cache': this._stack_keys.length, 'cache': this._stack_keys.length,
'matcher': global_matcher.length, 'matcher': global_matcher.length,
'worker': this.worker 'worker': this.worker

View File

@@ -7,13 +7,13 @@
'use strict';(function(d,v,n){var t;(t=n.define)&&t.amd?t([],function(){return v}):(t=n.modules)?t[d.toLowerCase()]=v:"undefined"!==typeof module?module.exports=v:n[d]=v})("FlexSearch",function(){function d(a){"string"===typeof a&&(a=B[a]);a||(a=x);this.id=a.id||G++;this.init(a);v(this,"index",function(){return this.a});v(this,"length",function(){return Object.keys(this.a).length})}function v(a,b,c){Object.defineProperty(a,b,{get:c})}function n(a){return new RegExp(a,"g")}function t(a,b,c){if("undefined"=== 'use strict';(function(d,v,n){var t;(t=n.define)&&t.amd?t([],function(){return v}):(t=n.modules)?t[d.toLowerCase()]=v:"undefined"!==typeof module?module.exports=v:n[d]=v})("FlexSearch",function(){function d(a){"string"===typeof a&&(a=B[a]);a||(a=x);this.id=a.id||G++;this.init(a);v(this,"index",function(){return this.a});v(this,"length",function(){return Object.keys(this.a).length})}function v(a,b,c){Object.defineProperty(a,b,{get:c})}function n(a){return new RegExp(a,"g")}function t(a,b,c){if("undefined"===
typeof c){for(c=0;c<b.length;c+=2)a=a.replace(b[c],b[c+1]);return a}return a.replace(b,c)}function z(a,b,c,e,f,p,g){if("undefined"===typeof b[c]){var h=f?(9-(g||6))*p+(g||6)*f:p;b[c]=h;h>=g&&(a=a[h+.5|0],a=a[c]||(a[c]=[]),a[a.length]=e)}return h||b[c]}function A(a,b){if(a)for(var c=Object.keys(a),e=0,f=c.length;e<f;e++){var p=c[e],g=a[p];if(g)for(var h=0,k=g.length;h<k;h++)if(g[h]===b){1===k?delete a[p]:g.splice(h,1);break}else"object"===typeof g[h]&&A(g[h],b)}}function C(a){var b=[];if(!a)return b; typeof c){for(c=0;c<b.length;c+=2)a=a.replace(b[c],b[c+1]);return a}return a.replace(b,c)}function z(a,b,c,e,f,p,g){if("undefined"===typeof b[c]){var h=f?(9-(g||6))*p+(g||6)*f:p;b[c]=h;h>=g&&(a=a[h+.5|0],a=a[c]||(a[c]=[]),a[a.length]=e)}return h||b[c]}function A(a,b){if(a)for(var c=Object.keys(a),e=0,f=c.length;e<f;e++){var p=c[e],g=a[p];if(g)for(var h=0,k=g.length;h<k;h++)if(g[h]===b){1===k?delete a[p]:g.splice(h,1);break}else"object"===typeof g[h]&&A(g[h],b)}}function C(a){var b=[];if(!a)return b;
for(var c=0,e=0,f=0,p="",g=a.length,h=0;h<g;h++){var k=a[h];"a"===k||"e"===k||"i"===k||"o"===k||"u"===k||"y"===k?c++:e++;" "!==k&&(p+=k);if(" "===k||c>=(8<g?2:1)&&2<=e||2<=c&&e>=(8<g?2:1)||h===g-1)p&&(b[f]&&2<p.length&&f++,b[f]=b[f]?b[f]+p:p," "===k&&f++,p=""),e=c=0}return b}function H(a,b){a=a.length-b.length;return 0>a?1:0<a?-1:0}function I(a,b){a=a.length-b.length;return 0>a?-1:0<a?1:0}function J(a,b,c){var e=[],f=[],p=a.length;if(1<p){a.sort(I);for(var g={},h=a[0],k=h.length,y=0;y<k;)g[h[y++]]= for(var c=0,e=0,f=0,p="",g=a.length,h=0;h<g;h++){var k=a[h];"a"===k||"e"===k||"i"===k||"o"===k||"u"===k||"y"===k?c++:e++;" "!==k&&(p+=k);if(" "===k||c>=(8<g?2:1)&&2<=e||2<=c&&e>=(8<g?2:1)||h===g-1)p&&(b[f]&&2<p.length&&f++,b[f]=b[f]?b[f]+p:p," "===k&&f++,p=""),e=c=0}return b}function H(a,b){a=a.length-b.length;return 0>a?1:0<a?-1:0}function I(a,b){a=a.length-b.length;return 0>a?-1:0<a?1:0}function J(a,b,c){var e=[],f=[],p=a.length;if(1<p){a.sort(I);for(var g={},h=a[0],k=h.length,y=0;y<k;)g[h[y++]]=
1;for(var q,d=0,m=1;m<p;){var l=!1,n=m===p-1;f=[];h=a[m];k=h.length;for(y=-1;y<k;){var r=g[q=h[++y]];if(r===m){if(n&&(e[d++]=q,b&&d===b))return e;l=!0;g[q]=m+1}else c&&(r=f[r]||(f[r]=[]),r[r.length]=q)}if(!l&&!c)break;m++}if(c&&(b||(b=1E3),d=e.length,k=f.length,d<b&&k))for(m=k-1;0<=m;m--)if(q=f[m])for(y=0;y<q.length;y++)if(e[d++]=q[y],b&&d===b)return e}else p&&(e=a[0],b&&e.length>b&&(e=e.slice(0,b)));return e}var x={encode:"icase",mode:"forward",f:!1,cache:!1,async:!1,j:!1,threshold:0,depth:0},B= 1;for(var q,d=0,m=1;m<p;){var l=!1,n=m===p-1;f=[];h=a[m];k=h.length;for(y=-1;y<k;){var r=g[q=h[++y]];if(r===m){if(n&&(e[d++]=q,b&&d===b))return e;l=!0;g[q]=m+1}else c&&(r=f[r]||(f[r]=[]),r[r.length]=q)}if(!l&&!c)break;m++}if(c&&(b||(b=1E3),d=e.length,k=f.length,d<b&&k))for(m=k-1;0<=m;m--)if(q=f[m])for(y=0;y<q.length;y++)if(e[d++]=q[y],b&&d===b)return e}else p&&(e=a[0],b&&e.length>b&&(e=e.slice(0,b)));return e}var x={encode:"icase",mode:"forward",f:!1,cache:!1,async:!1,i:!1,threshold:0,depth:0},B=
{memory:{encode:"extra",mode:"strict",threshold:7},speed:{encode:"icase",mode:"strict",threshold:7,depth:2},match:{encode:"extra",mode:"full"},score:{encode:"extra",mode:"strict",threshold:5,depth:4},balance:{encode:"balance",mode:"ngram",threshold:6,depth:3},fastest:{encode:"icase",mode:"strict",threshold:9,depth:1}},w=[],G=0,D=n("[ -/]"),E={},F={};d.new=function(a){return new this(a)};d.create=function(a){return d.new(a)};d.registerMatcher=function(a){for(var b in a)a.hasOwnProperty(b)&&(w[w.length]= {memory:{encode:"extra",mode:"strict",threshold:7},speed:{encode:"icase",mode:"strict",threshold:7,depth:2},match:{encode:"extra",mode:"full"},score:{encode:"extra",mode:"strict",threshold:5,depth:4},balance:{encode:"balance",mode:"ngram",threshold:6,depth:3},fastest:{encode:"icase",mode:"strict",threshold:9,depth:1}},w=[],G=0,D=n("[ -/]"),E={},F={};d.new=function(a){return new this(a)};d.create=function(a){return d.new(a)};d.registerMatcher=function(a){for(var b in a)a.hasOwnProperty(b)&&(w[w.length]=
n(b),w[w.length]=a[b]);return this};d.registerEncoder=function(a,b){u[a]=b;return this};d.registerLanguage=function(a,b){E[a]=b.filter;F[a]=b.stemmer;return this};d.encode=function(a,b){return u[a].call(u,b)};d.prototype.init=function(a){this.i=[];a||(a=x);var b=a.profile;b=b?B[b]:{};this.mode=a.mode||b.mode||this.mode||x.mode;this.threshold=a.threshold||b.threshold||this.threshold||x.threshold;this.depth=a.depth||b.depth||this.depth||x.depth;this.f=a.suggest||this.f||x.f;this.c=(b=a.encode||b.encode)&& n(b),w[w.length]=a[b]);return this};d.registerEncoder=function(a,b){u[a]=b;return this};d.registerLanguage=function(a,b){E[a]=b.filter;F[a]=b.stemmer;return this};d.encode=function(a,b){return u[a].call(u,b)};d.prototype.init=function(a){this.h=[];a||(a=x);var b=a.profile;b=b?B[b]:{};this.mode=a.mode||b.mode||this.mode||x.mode;this.threshold=a.threshold||b.threshold||this.threshold||x.threshold;this.depth=a.depth||b.depth||this.depth||x.depth;this.f=a.suggest||this.f||x.f;this.c=(b=a.encode||b.encode)&&
u[b]||("function"===typeof b?b:this.c||!1);(b=a.matcher)&&this.addMatcher(b);if(b=a.filter){b=E[b]||b;var c=this.c,e={};if(b)for(var f=0;f<b.length;f++){var p=c?c.call(u,b[f]):b[f];e[p]=String.fromCharCode(65E3-b.length+f)}this.filter=e}if(b=a.stemmer){a=F[b]||b;b=this.c;c=[];if(a){e=0;for(var g in a)a.hasOwnProperty(g)&&(f=b?b.call(u,g):g,c[e++]=n("(?=.{"+(f.length+3)+",})"+f+"$"),c[e++]=b?b.call(u,a[g]):a[g])}this.stemmer=c}this.g=[{},{},{},{},{},{},{},{},{},{}];this.b={};this.a={};this.h=!0;return this}; u[b]||("function"===typeof b?b:this.c||!1);(b=a.matcher)&&this.addMatcher(b);if(b=a.filter){b=E[b]||b;var c=this.c,e={};if(b)for(var f=0;f<b.length;f++){var p=c?c.call(u,b[f]):b[f];e[p]=String.fromCharCode(65E3-b.length+f)}this.filter=e}if(b=a.stemmer){a=F[b]||b;b=this.c;c=[];if(a){e=0;for(var g in a)a.hasOwnProperty(g)&&(f=b?b.call(u,g):g,c[e++]=n("(?=.{"+(f.length+3)+",})"+f+"$"),c[e++]=b?b.call(u,a[g]):a[g])}this.stemmer=c}this.g=[{},{},{},{},{},{},{},{},{},{}];this.b={};this.a={};return this};
d.prototype.encode=function(a){a&&w.length&&(a=t(a,w));a&&this.i.length&&(a=t(a,this.i));a&&this.c&&(a=this.c.call(u,a));a&&this.stemmer&&(a=t(a,this.stemmer));return a};d.prototype.addMatcher=function(a){var b=this.i,c;for(c in a)a.hasOwnProperty(c)&&(b[b.length]=n(c),b[b.length]=a[c]);return this};d.prototype.add=function(a,b,c){if("string"===typeof b&&b&&(a||0===a))if(this.a[a]&&!c)this.update(a,b);else{b=this.encode(b);if(!b.length)return this;c=this.mode;b="function"===typeof c?c(b):"ngram"=== d.prototype.encode=function(a){a&&w.length&&(a=t(a,w));a&&this.h.length&&(a=t(a,this.h));a&&this.c&&(a=this.c.call(u,a));a&&this.stemmer&&(a=t(a,this.stemmer));return a};d.prototype.addMatcher=function(a){var b=this.h,c;for(c in a)a.hasOwnProperty(c)&&(b[b.length]=n(c),b[b.length]=a[c]);return this};d.prototype.add=function(a,b,c){if("string"===typeof b&&b&&(a||0===a))if(this.a[a]&&!c)this.update(a,b);else{b=this.encode(b);if(!b.length)return this;c=this.mode;b="function"===typeof c?c(b):"ngram"===
c?C(b):b.split(D);for(var e={_ctx:{}},f=this.threshold,p=this.depth,g=this.g,h=b.length,k=0;k<h;k++){var d=b[k];if(d){var q=d.length,n=(h-k)/h;switch(c){case "reverse":case "both":for(var m="",l=q-1;1<=l;l--)m=d[l]+m,z(g,e,m,a,(q-l)/q,n,f);case "forward":m="";for(l=0;l<q;l++)m+=d[l],z(g,e,m,a,1,n,f);break;case "full":for(l=0;l<q;l++)for(var t=(q-l)/q,r=q;r>l;r--)m=d.substring(l,r),z(g,e,m,a,t,n,f);break;default:if(l=z(g,e,d,a,1,n,f),p&&1<h&&l>=f)for(q=e._ctx[d]||(e._ctx[d]={}),d=this.b[d]||(this.b[d]= c?C(b):b.split(D);for(var e={_ctx:{}},f=this.threshold,p=this.depth,g=this.g,h=b.length,k=0;k<h;k++){var d=b[k];if(d){var q=d.length,n=(h-k)/h;switch(c){case "reverse":case "both":for(var m="",l=q-1;1<=l;l--)m=d[l]+m,z(g,e,m,a,(q-l)/q,n,f);case "forward":m="";for(l=0;l<q;l++)m+=d[l],z(g,e,m,a,1,n,f);break;case "full":for(l=0;l<q;l++)for(var t=(q-l)/q,r=q;r>l;r--)m=d.substring(l,r),z(g,e,m,a,t,n,f);break;default:if(l=z(g,e,d,a,1,n,f),p&&1<h&&l>=f)for(q=e._ctx[d]||(e._ctx[d]={}),d=this.b[d]||(this.b[d]=
[{},{},{},{},{},{},{},{},{},{}]),l=k-p,r=k+p+1,0>l&&(l=0),r>h&&(r=h);l<r;l++)l!==k&&z(d,q,b[l],a,0,10-(l<k?k-l:l-k),f)}}}this.a[a]="1";this.h=!1}return this};d.prototype.update=function(a,b){this.a[a]&&b&&"string"===typeof b&&(this.remove(a),this.add(a,b,!0));return this};d.prototype.remove=function(a){if(this.a[a]){for(var b=0;10>b;b++)A(this.g[b],a);this.depth&&A(this.b,a);delete this.a[a];this.h=!1}return this};d.prototype.search=function(a,b,c){var e=[];if(a&&"object"===typeof a){c=a.callback|| [{},{},{},{},{},{},{},{},{},{}]),l=k-p,r=k+p+1,0>l&&(l=0),r>h&&(r=h);l<r;l++)l!==k&&z(d,q,b[l],a,0,10-(l<k?k-l:l-k),f)}}}this.a[a]="1"}return this};d.prototype.update=function(a,b){this.a[a]&&b&&"string"===typeof b&&(this.remove(a),this.add(a,b,!0));return this};d.prototype.remove=function(a){if(this.a[a]){for(var b=0;10>b;b++)A(this.g[b],a);this.depth&&A(this.b,a);delete this.a[a]}return this};d.prototype.search=function(a,b,c){var e=[];if(a&&"object"===typeof a){c=a.callback||b;b=a.limit;var f=
b;b=a.limit;var f=a.threshold;a=a.query}f=(f||this.threshold||0)|0;"function"===typeof b?(c=b,b=1E3):b||(b=1E3);if(c){var d=this;K(function(){c(d.search(a,b));d=null},1,"search-"+this.id);return null}if(!a||"string"!==typeof a)return e;this.h||(this.h=!0);var g=this.encode(a);if(!g.length)return e;var h=this.mode;g="function"===typeof h?h(g):"ngram"===h?C(g):g.split(D);h=g.length;var k=!0,n=[],q={};if(1<h)if(this.depth){var t=!0,m=g[0];q[m]="1"}else g.sort(H);var l;if(!t||(l=this.b)[m])for(var u= a.threshold;a=a.query}f=(f||this.threshold||0)|0;"function"===typeof b?(c=b,b=1E3):b||(b=1E3);if(c){var d=this;K(function(){c(d.search(a,b));d=null},1,"search-"+this.id);return null}if(!a||"string"!==typeof a)return e;var g=this.encode(a);if(!g.length)return e;var h=this.mode;g="function"===typeof h?h(g):"ngram"===h?C(g):g.split(D);h=g.length;var k=!0,n=[],q={};if(1<h)if(this.depth){var t=!0,m=g[0];q[m]="1"}else g.sort(H);var l;if(!t||(l=this.b)[m])for(var u=t?1:0;u<h;u++){var r=g[u];if(r&&!q[r]){for(var v,
t?1:0;u<h;u++){var r=g[u];if(r&&!q[r]){for(var v,x=!1,w=[],z=0,A=9;A>=f;A--)if(v=(t?l[m]:this.g)[A][r])w[z++]=v,x=!0;if(x)n[n.length]=1<z?n.concat.apply([],w):w[0];else if(!this.f){k=!1;break}q[r]="1"}m=r}else k=!1;k&&(e=J(n,b,this.f));return e};d.prototype.reset=function(){this.destroy();return this.init()};d.prototype.destroy=function(){this.filter=this.stemmer=this.g=this.b=this.a=null;return this};var u={icase:function(a){return a.toLowerCase()},balance:function(){var a=[n("[-/]")," ",n("[^a-z0-9 ]"), x=!1,w=[],z=0,A=9;A>=f;A--)if(v=(t?l[m]:this.g)[A][r])w[z++]=v,x=!0;if(x)n[n.length]=1<z?n.concat.apply([],w):w[0];else if(!this.f){k=!1;break}q[r]="1"}m=r}else k=!1;k&&(e=J(n,b,this.f));return e};d.prototype.reset=function(){this.destroy();return this.init()};d.prototype.destroy=function(){this.filter=this.stemmer=this.g=this.b=this.a=null;return this};var u={icase:function(a){return a.toLowerCase()},balance:function(){var a=[n("[-/]")," ",n("[^a-z0-9 ]"),"",n("\\s\\s+")," "];return function(b){b=
"",n("\\s\\s+")," "];return function(b){b=t(b.toLowerCase(),a);for(var c="",e="",f="",d=0;d<b.length;d++){var g=b[d];if(g!==e)if(d&&"h"===g){if(f="a"===f||"e"===f||"i"===f||"o"===f||"u"===f||"y"===f,("a"===e||"e"===e||"i"===e||"o"===e||"u"===e||"y"===e)&&f||" "===e)c+=g}else c+=g;f=d===b.length-1?"":b[d+1];e=g}return c}}()},K=null;return d}(!1),this); t(b.toLowerCase(),a);for(var c="",e="",f="",d=0;d<b.length;d++){var g=b[d];if(g!==e)if(d&&"h"===g){if(f="a"===f||"e"===f||"i"===f||"o"===f||"u"===f||"y"===f,("a"===e||"e"===e||"i"===e||"o"===e||"u"===e||"y"===e)&&f||" "===e)c+=g}else c+=g;f=d===b.length-1?"":b[d+1];e=g}return c}}()},K=null;return d}(!1),this);

28
flexsearch.min.js vendored
View File

@@ -4,27 +4,27 @@
Released under the Apache 2.0 Licence Released under the Apache 2.0 Licence
https://github.com/nextapps-de/flexsearch https://github.com/nextapps-de/flexsearch
*/ */
'use strict';(function(v,C,f){var w;(w=f.define)&&w.amd?w([],function(){return C}):(w=f.modules)?w[v.toLowerCase()]=C:"undefined"!==typeof module?module.exports=C:f[v]=C})("FlexSearch",function N(v){function f(a){"string"===typeof a&&(a=G[a]);a||(a=x);this.id=a.id||O++;this.init(a);w(this,"index",function(){return this.a});w(this,"length",function(){return Object.keys(this.a).length})}function w(a,b,e){Object.defineProperty(a,b,{get:e})}function d(a){return new RegExp(a,"g")}function y(a,b,e){if("undefined"=== 'use strict';(function(v,C,f){var w;(w=f.define)&&w.amd?w([],function(){return C}):(w=f.modules)?w[v.toLowerCase()]=C:"undefined"!==typeof module?module.exports=C:f[v]=C})("FlexSearch",function N(v){function f(a){"string"===typeof a&&(a=G[a]);a||(a=y);this.id=a.id||O++;this.init(a);w(this,"index",function(){return this.a});w(this,"length",function(){return Object.keys(this.a).length})}function w(a,b,e){Object.defineProperty(a,b,{get:e})}function d(a){return new RegExp(a,"g")}function x(a,b,e){if("undefined"===
typeof e){for(e=0;e<b.length;e+=2)a=a.replace(b[e],b[e+1]);return a}return a.replace(b,e)}function z(a,b,e,c,k,t,g){if("undefined"===typeof b[e]){var h=k?(9-(g||6))*t+(g||6)*k:t;b[e]=h;h>=g&&(a=a[h+.5|0],a=a[e]||(a[e]=[]),a[a.length]=c)}return h||b[e]}function q(a,b){if(a)for(var e=Object.keys(a),c=0,k=e.length;c<k;c++){var t=e[c],g=a[t];if(g)for(var h=0,d=g.length;h<d;h++)if(g[h]===b){1===d?delete a[t]:g.splice(h,1);break}else"object"===typeof g[h]&&q(g[h],b)}}function H(a){var b=[];if(!a)return b; typeof e){for(e=0;e<b.length;e+=2)a=a.replace(b[e],b[e+1]);return a}return a.replace(b,e)}function z(a,b,e,c,k,t,g){if("undefined"===typeof b[e]){var h=k?(9-(g||6))*t+(g||6)*k:t;b[e]=h;h>=g&&(a=a[h+.5|0],a=a[e]||(a[e]=[]),a[a.length]=c)}return h||b[e]}function q(a,b){if(a)for(var e=Object.keys(a),c=0,k=e.length;c<k;c++){var t=e[c],g=a[t];if(g)for(var h=0,d=g.length;h<d;h++)if(g[h]===b){1===d?delete a[t]:g.splice(h,1);break}else"object"===typeof g[h]&&q(g[h],b)}}function H(a){var b=[];if(!a)return b;
for(var e=0,c=0,k=0,t="",g=a.length,h=0;h<g;h++){var d=a[h];"a"===d||"e"===d||"i"===d||"o"===d||"u"===d||"y"===d?e++:c++;" "!==d&&(t+=d);if(" "===d||e>=(8<g?2:1)&&2<=c||2<=e&&c>=(8<g?2:1)||h===g-1)t&&(b[k]&&2<t.length&&k++,b[k]=b[k]?b[k]+t:t," "===d&&k++,t=""),c=e=0}return b}function E(a){for(var b="",e="",c="",k=0;k<a.length;k++){var d=a[k];if(d!==e)if(k&&"h"===d){if(c="a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c,("a"===e||"e"===e||"i"===e||"o"===e||"u"===e||"y"===e)&&c||" "===e)b+=d}else b+= for(var e=0,c=0,k=0,t="",g=a.length,h=0;h<g;h++){var d=a[h];"a"===d||"e"===d||"i"===d||"o"===d||"u"===d||"y"===d?e++:c++;" "!==d&&(t+=d);if(" "===d||e>=(8<g?2:1)&&2<=c||2<=e&&c>=(8<g?2:1)||h===g-1)t&&(b[k]&&2<t.length&&k++,b[k]=b[k]?b[k]+t:t," "===d&&k++,t=""),c=e=0}return b}function E(a){for(var b="",e="",c="",k=0;k<a.length;k++){var d=a[k];if(d!==e)if(k&&"h"===d){if(c="a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c,("a"===e||"e"===e||"i"===e||"o"===e||"u"===e||"y"===e)&&c||" "===e)b+=d}else b+=
d;c=k===a.length-1?"":a[k+1];e=d}return b}function P(a,b){var e={};if(a)for(var c=0;c<a.length;c++){var k=b?b.call(A,a[c]):a[c];e[k]=String.fromCharCode(65E3-a.length+c)}return e}function Q(a,b){var e=[];if(a){var c=0,k;for(k in a)if(a.hasOwnProperty(k)){var t=b?b.call(A,k):k;e[c++]=d("(?=.{"+(t.length+3)+",})"+t+"$");e[c++]=b?b.call(A,a[k]):a[k]}}return e}function R(a,b){a=a.length-b.length;return 0>a?1:0<a?-1:0}function S(a,b){a=a.length-b.length;return 0>a?-1:0<a?1:0}function T(a,b,e){var c=[], d;c=k===a.length-1?"":a[k+1];e=d}return b}function P(a,b){var e={};if(a)for(var c=0;c<a.length;c++){var k=b?b.call(A,a[c]):a[c];e[k]=String.fromCharCode(65E3-a.length+c)}return e}function Q(a,b){var e=[];if(a){var c=0,k;for(k in a)if(a.hasOwnProperty(k)){var t=b?b.call(A,k):k;e[c++]=d("(?=.{"+(t.length+3)+",})"+t+"$");e[c++]=b?b.call(A,a[k]):a[k]}}return e}function R(a,b){a=a.length-b.length;return 0>a?1:0<a?-1:0}function S(a,b){a=a.length-b.length;return 0>a?-1:0<a?1:0}function T(a,b,e){var c=[],
k=[],d=a.length;if(1<d){a.sort(S);for(var g={},h=a[0],f=h.length,m=0;m<f;)g[h[m++]]=1;for(var p,u=0,n=1;n<d;){var l=!1,q=n===d-1;k=[];h=a[n];f=h.length;for(m=-1;m<f;){var r=g[p=h[++m]];if(r===n){if(q&&(c[u++]=p,b&&u===b))return c;l=!0;g[p]=n+1}else e&&(r=k[r]||(k[r]=[]),r[r.length]=p)}if(!l&&!e)break;n++}if(e&&(b||(b=1E3),u=c.length,f=k.length,u<b&&f))for(n=f-1;0<=n;n--)if(p=k[n])for(m=0;m<p.length;m++)if(c[u++]=p[m],b&&u===b)return c}else d&&(c=a[0],b&&c.length>b&&(c=c.slice(0,b)));return c}function F(a){a.B|| k=[],d=a.length;if(1<d){a.sort(S);for(var g={},h=a[0],f=h.length,m=0;m<f;)g[h[m++]]=1;for(var p,u=0,n=1;n<d;){var l=!1,q=n===d-1;k=[];h=a[n];f=h.length;for(m=-1;m<f;){var r=g[p=h[++m]];if(r===n){if(q&&(c[u++]=p,b&&u===b))return c;l=!0;g[p]=n+1}else e&&(r=k[r]||(k[r]=[]),r[r.length]=p)}if(!l&&!e)break;n++}if(e&&(b||(b=1E3),u=c.length,f=k.length,u<b&&f))for(n=f-1;0<=n;n--)if(p=k[n])for(m=0;m<p.length;m++)if(c[u++]=p[m],b&&u===b)return c}else d&&(c=a[0],b&&c.length>b&&(c=c.slice(0,b)));return c}function F(a){a.B||
(a.B=I(function(){a.B=null;var b=a.async;b&&(a.async=!1);if(a.b.length){for(var e=J(),c;(c=a.b.shift())||0===c;){var d=a.f[c];switch(d[0]){case D.add:a.add(d[1],d[2]);break;case D.remove:a.remove(d[1])}a.f[c]=null;delete a.f[c];if(100<J()-e)break}a.b.length&&F(a)}b&&(a.async=b)},1,"search-async-"+a.id))}function J(){return"undefined"!==typeof performance?performance.now():(new Date).getTime()}function U(a,b,e,c){a=v("flexsearch","id"+a,function(){var a,b;self.onmessage=function(c){if(c=c.data)if(c.search){var e= (a.B=I(function(){a.B=null;var b=a.async;b&&(a.async=!1);if(a.b.length){for(var e=J(),c;(c=a.b.shift())||0===c;){var d=a.f[c];switch(d[0]){case D.add:a.add(d[1],d[2]);break;case D.remove:a.remove(d[1])}a.f[c]=null;delete a.f[c];if(100<J()-e)break}a.b.length&&F(a)}b&&(a.async=b)},1,"search-async-"+a.id))}function J(){return"undefined"!==typeof performance?performance.now():(new Date).getTime()}function U(a,b,e,c){a=v("flexsearch","id"+a,function(){var a,b;self.onmessage=function(c){if(c=c.data)if(c.search){var e=
b.search(c.content,c.threshold?{limit:c.limit,threshold:c.threshold}:c.limit);self.postMessage({id:a,content:c.content,limit:c.limit,result:e})}else c.add?b.add(c.id,c.content):c.update?b.update(c.id,c.content):c.remove?b.remove(c.id):c.reset?b.reset():c.info?(c=b.info(),c.worker=a,b.debug&&console.log(c)):c.register&&(a=c.id,c.options.cache=!1,c.options.async=!0,c.options.worker=!1,b=(new Function(c.register.substring(c.register.indexOf("{")+1,c.register.lastIndexOf("}"))))(),b=new b(c.options))}}, b.search(c.content,c.threshold?{limit:c.limit,threshold:c.threshold}:c.limit);self.postMessage({id:a,content:c.content,limit:c.limit,result:e})}else c.add?b.add(c.id,c.content):c.update?b.update(c.id,c.content):c.remove?b.remove(c.id):c.reset?b.reset():c.info?(c=b.info(),c.worker=a,b.debug&&console.log(c)):c.register&&(a=c.id,c.options.cache=!1,c.options.async=!0,c.options.worker=!1,b=(new Function(c.register.substring(c.register.indexOf("{")+1,c.register.lastIndexOf("}"))))(),b=new b(c.options))}},
function(a){(a=a.data)&&a.result?c(a.id,a.content,a.result,a.limit):e.debug&&console.log(a)},b);var d=N.toString();e.id=b;a.postMessage(b,{register:d,options:e,id:b});return a}var x={encode:"icase",mode:"forward",v:!1,cache:!1,async:!1,c:!1,threshold:0,depth:0},G={memory:{encode:"extra",mode:"strict",threshold:7},speed:{encode:"icase",mode:"strict",threshold:7,depth:2},match:{encode:"extra",mode:"full"},score:{encode:"extra",mode:"strict",threshold:5,depth:4},balance:{encode:"balance",mode:"ngram", function(a){(a=a.data)&&a.result?c(a.id,a.content,a.result,a.limit):e.debug&&console.log(a)},b);var d=N.toString();e.id=b;a.postMessage(b,{register:d,options:e,id:b});return a}var y={encode:"icase",mode:"forward",u:!1,cache:!1,async:!1,c:!1,threshold:0,depth:0},G={memory:{encode:"extra",mode:"strict",threshold:7},speed:{encode:"icase",mode:"strict",threshold:7,depth:2},match:{encode:"extra",mode:"full"},score:{encode:"extra",mode:"strict",threshold:5,depth:4},balance:{encode:"balance",mode:"ngram",
threshold:6,depth:3},fastest:{encode:"icase",mode:"strict",threshold:9,depth:1}},B=[],O=0,D={add:0,update:1,remove:2},K=d("[ -/]"),L={},M={};f.new=function(a){return new this(a)};f.create=function(a){return f.new(a)};f.registerMatcher=function(a){for(var b in a)a.hasOwnProperty(b)&&(B[B.length]=d(b),B[B.length]=a[b]);return this};f.registerEncoder=function(a,b){A[a]=b;return this};f.registerLanguage=function(a,b){L[a]=b.filter;M[a]=b.stemmer;return this};f.encode=function(a,b){return A[a].call(A, threshold:6,depth:3},fastest:{encode:"icase",mode:"strict",threshold:9,depth:1}},B=[],O=0,D={add:0,update:1,remove:2},K=d("[ -/]"),L={},M={};f.new=function(a){return new this(a)};f.create=function(a){return f.new(a)};f.registerMatcher=function(a){for(var b in a)a.hasOwnProperty(b)&&(B[B.length]=d(b),B[B.length]=a[b]);return this};f.registerEncoder=function(a,b){A[a]=b;return this};f.registerLanguage=function(a,b){L[a]=b.filter;M[a]=b.stemmer;return this};f.encode=function(a,b){return A[a].call(A,
b)};f.prototype.init=function(a){this.A=[];a||(a=x);var b=a.profile,e=b?G[b]:{};if(b=a.worker)if("undefined"===typeof Worker)a.worker=!1,a.async=!0,this.h=null;else{var c=this;b=parseInt(b,10)||4;c.m=-1;c.s=0;c.g=[];c.w=null;c.h=Array(b);for(var d=0;d<b;d++)c.h[d]=U(c.id,d,a||x,function(a,b,e,d){c.s!==c.c&&(c.g=c.g.concat(e),c.s++,d&&c.g.length>=d&&(c.s=c.c),c.w&&c.s===c.c&&(c.cache&&c.i.set(b,c.g),c.w(c.g),c.g=[]))})}this.mode=a.mode||e.mode||this.mode||x.mode;this.async=a.async||this.async||x.async; b)};f.prototype.init=function(a){this.A=[];a||(a=y);var b=a.profile,e=b?G[b]:{};if(b=a.worker)if("undefined"===typeof Worker)a.worker=!1,this.h=null;else{var c=this;b=parseInt(b,10)||4;c.m=-1;c.o=0;c.g=[];c.w=null;c.h=Array(b);for(var d=0;d<b;d++)c.h[d]=U(c.id,d,a,function(a,b,e,d){if(c.o!==c.c)return c.g=c.g.concat(e),c.o++,d&&c.g.length>=d&&(c.o=c.c),c.w&&c.o===c.c&&(c.cache&&c.i.set(b,c.g),c.w(c.g),c.g=[]),c})}this.mode=a.mode||e.mode||this.mode||y.mode;this.async=a.async||this.async||y.async;
this.c=a.worker||this.c||x.c;this.threshold=a.threshold||e.threshold||this.threshold||x.threshold;this.depth=a.depth||e.depth||this.depth||x.depth;this.v=a.suggest||this.v||x.v;this.u=(b=a.encode||e.encode)&&A[b]||("function"===typeof b?b:this.u||!1);this.debug=a.debug||this.debug;(b=a.matcher)&&this.addMatcher(b);if(b=a.filter)this.filter=P(L[b]||b,this.u);if(b=a.stemmer)this.stemmer=Q(M[b]||b,this.u);this.j=[{},{},{},{},{},{},{},{},{},{}];this.l={};this.a={};this.f={};this.b=[];this.B=null;this.o= this.c=a.worker||this.c||y.c;this.threshold=a.threshold||e.threshold||this.threshold||y.threshold;this.depth=a.depth||e.depth||this.depth||y.depth;this.u=a.suggest||this.u||y.u;this.s=(b=a.encode||e.encode)&&A[b]||("function"===typeof b?b:this.s||!1);this.debug=a.debug||this.debug;(b=a.matcher)&&this.addMatcher(b);if(b=a.filter)this.filter=P(L[b]||b,this.s);if(b=a.stemmer)this.stemmer=Q(M[b]||b,this.s);this.j=[{},{},{},{},{},{},{},{},{},{}];this.l={};this.a={};this.f={};this.b=[];this.B=null;this.v=
!0;this.i=(this.cache=b=a.cache||this.cache||x.cache)?new V(b):!1;return this};f.prototype.encode=function(a){a&&B.length&&(a=y(a,B));a&&this.A.length&&(a=y(a,this.A));a&&this.u&&(a=this.u.call(A,a));a&&this.stemmer&&(a=y(a,this.stemmer));return a};f.prototype.addMatcher=function(a){var b=this.A,e;for(e in a)a.hasOwnProperty(e)&&(b[b.length]=d(e),b[b.length]=a[e]);return this};f.prototype.add=function(a,b,e){if("string"===typeof b&&b&&(a||0===a))if(this.a[a]&&!e)this.update(a,b);else{if(this.c)return++this.m>= !0;this.i=(this.cache=b=a.cache||this.cache||y.cache)?new V(b):!1;return this};f.prototype.encode=function(a){a&&B.length&&(a=x(a,B));a&&this.A.length&&(a=x(a,this.A));a&&this.s&&(a=this.s.call(A,a));a&&this.stemmer&&(a=x(a,this.stemmer));return a};f.prototype.addMatcher=function(a){var b=this.A,e;for(e in a)a.hasOwnProperty(e)&&(b[b.length]=d(e),b[b.length]=a[e]);return this};f.prototype.add=function(a,b,e){if("string"===typeof b&&b&&(a||0===a))if(this.a[a]&&!e)this.update(a,b);else{if(this.c)return++this.m>=
this.h.length&&(this.m=0),this.h[this.m].postMessage(this.m,{add:!0,id:a,content:b}),this.a[a]=""+this.m,this;if(this.async)return this.f[a]||(this.b[this.b.length]=a),this.f[a]=[D.add,a,b],F(this),this;b=this.encode(b);if(!b.length)return this;e=this.mode;b="function"===typeof e?e(b):"ngram"===e?H(b):b.split(K);for(var c={_ctx:{}},d=this.threshold,t=this.depth,g=this.j,h=b.length,f=0;f<h;f++){var m=b[f];if(m){var p=m.length,u=(h-f)/h;switch(e){case "reverse":case "both":for(var n="",l=p-1;1<=l;l--)n= this.h.length&&(this.m=0),this.h[this.m].postMessage(this.m,{add:!0,id:a,content:b}),this.a[a]=""+this.m,this;if(this.async)return this.f[a]||(this.b[this.b.length]=a),this.f[a]=[D.add,a,b],F(this),this;b=this.encode(b);if(!b.length)return this;e=this.mode;b="function"===typeof e?e(b):"ngram"===e?H(b):b.split(K);for(var c={_ctx:{}},d=this.threshold,t=this.depth,g=this.j,h=b.length,f=0;f<h;f++){var m=b[f];if(m){var p=m.length,u=(h-f)/h;switch(e){case "reverse":case "both":for(var n="",l=p-1;1<=l;l--)n=
m[l]+n,z(g,c,n,a,(p-l)/p,u,d);case "forward":n="";for(l=0;l<p;l++)n+=m[l],z(g,c,n,a,1,u,d);break;case "full":for(l=0;l<p;l++)for(var q=(p-l)/p,r=p;r>l;r--)n=m.substring(l,r),z(g,c,n,a,q,u,d);break;default:if(l=z(g,c,m,a,1,u,d),t&&1<h&&l>=d)for(p=c._ctx[m]||(c._ctx[m]={}),m=this.l[m]||(this.l[m]=[{},{},{},{},{},{},{},{},{},{}]),l=f-t,r=f+t+1,0>l&&(l=0),r>h&&(r=h);l<r;l++)l!==f&&z(m,p,b[l],a,0,10-(l<f?f-l:l-f),d)}}}this.a[a]="1";this.o=!1}return this};f.prototype.update=function(a,b){this.a[a]&&b&& m[l]+n,z(g,c,n,a,(p-l)/p,u,d);case "forward":n="";for(l=0;l<p;l++)n+=m[l],z(g,c,n,a,1,u,d);break;case "full":for(l=0;l<p;l++)for(var q=(p-l)/p,r=p;r>l;r--)n=m.substring(l,r),z(g,c,n,a,q,u,d);break;default:if(l=z(g,c,m,a,1,u,d),t&&1<h&&l>=d)for(p=c._ctx[m]||(c._ctx[m]={}),m=this.l[m]||(this.l[m]=[{},{},{},{},{},{},{},{},{},{}]),l=f-t,r=f+t+1,0>l&&(l=0),r>h&&(r=h);l<r;l++)l!==f&&z(m,p,b[l],a,0,10-(l<f?f-l:l-f),d)}}}this.a[a]="1";this.v=!1}return this};f.prototype.update=function(a,b){this.a[a]&&b&&
"string"===typeof b&&(this.remove(a),this.add(a,b,!0));return this};f.prototype.remove=function(a){if(this.a[a]){if(this.c){var b=parseInt(this.a[a],10);this.h[b].postMessage(b,{remove:!0,id:a});delete this.a[a];return this}if(this.async)return this.f[a]||(this.b[this.b.length]=a),this.f[a]=[D.remove,a],F(this),this;for(b=0;10>b;b++)q(this.j[b],a);this.depth&&q(this.l,a);delete this.a[a];this.o=!1}return this};f.prototype.search=function(a,b,e){var c=[];if(a&&"object"===typeof a){e=a.callback||b; "string"===typeof b&&(this.remove(a),this.add(a,b,!0));return this};f.prototype.remove=function(a){if(this.a[a]){if(this.c){var b=parseInt(this.a[a],10);this.h[b].postMessage(b,{remove:!0,id:a});delete this.a[a];return this}if(this.async)return this.f[a]||(this.b[this.b.length]=a),this.f[a]=[D.remove,a],F(this),this;for(b=0;10>b;b++)q(this.j[b],a);this.depth&&q(this.l,a);delete this.a[a];this.v=!1}return this};f.prototype.search=function(a,b,e){var c=[];if(a&&"object"===typeof a){e=a.callback||b;
b=a.limit;var d=a.threshold;a=a.query}d=(d||this.threshold||0)|0;"function"===typeof b?(e=b,b=1E3):b||(b=1E3);if(this.c){this.w=e;this.s=0;this.g=[];for(c=0;c<this.c;c++)this.h[c].postMessage(c,{search:!0,limit:b,threshold:d,content:a});return null}if(e){var f=this;I(function(){e(f.search(a,b));f=null},1,"search-"+this.id);return null}if(!a||"string"!==typeof a)return c;var g=a;if(!this.o)this.cache&&this.i.reset(),this.o=!0;else if(this.cache){var h=this.i.get(a);if(h)return h}g=this.encode(g);if(!g.length)return c; b=a.limit;var d=a.threshold;a=a.query}d=(d||this.threshold||0)|0;"function"===typeof b?(e=b,b=1E3):b||(b=1E3);if(this.c){this.w=e;this.o=0;this.g=[];for(c=0;c<this.c;c++)this.h[c].postMessage(c,{search:!0,limit:b,threshold:d,content:a});return null}if(e){var f=this;I(function(){e(f.search(a,b));f=null},1,"search-"+this.id);return null}if(!a||"string"!==typeof a)return c;var g=a;if(this.cache)if(this.v){var h=this.i.get(a);if(h)return h}else this.i.reset(),this.v=!0;g=this.encode(g);if(!g.length)return c;
h=this.mode;g="function"===typeof h?h(g):"ngram"===h?H(g):g.split(K);h=g.length;var q=!0,m=[],p={};if(1<h)if(this.depth){var u=!0,n=g[0];p[n]="1"}else g.sort(R);var l;if(!u||(l=this.l)[n])for(var v=u?1:0;v<h;v++){var r=g[v];if(r&&!p[r]){for(var w,x=!1,y=[],z=0,A=9;A>=d;A--)if(w=(u?l[n]:this.j)[A][r])y[z++]=w,x=!0;if(x)m[m.length]=1<z?m.concat.apply([],y):y[0];else if(!this.v){q=!1;break}p[r]="1"}n=r}else q=!1;q&&(c=T(m,b,this.v));this.cache&&this.i.set(a,c);return c};f.prototype.info=function(){if(this.c)for(var a= h=this.mode;g="function"===typeof h?h(g):"ngram"===h?H(g):g.split(K);h=g.length;var q=!0,m=[],p={};if(1<h)if(this.depth){var u=!0,n=g[0];p[n]="1"}else g.sort(R);var l;if(!u||(l=this.l)[n])for(var v=u?1:0;v<h;v++){var r=g[v];if(r&&!p[r]){for(var w,y=!1,x=[],z=0,A=9;A>=d;A--)if(w=(u?l[n]:this.j)[A][r])x[z++]=w,y=!0;if(y)m[m.length]=1<z?m.concat.apply([],x):x[0];else if(!this.u){q=!1;break}p[r]="1"}n=r}else q=!1;q&&(c=T(m,b,this.u));this.cache&&this.i.set(a,c);return c};f.prototype.info=function(){if(this.c)for(var a=
0;a<this.c;a++)this.h[a].postMessage(a,{info:!0,id:this.id});else{for(var b,e,c=0,d=0,f=0,g=0;10>g;g++)for(b=Object.keys(this.j[g]),a=0;a<b.length;a++)e=this.j[g][b[a]].length,c+=1*e+2*b[a].length+4,d+=e,f+=2*b[a].length;b=Object.keys(this.a);e=b.length;for(a=0;a<e;a++)c+=2*b[a].length+2;return{id:this.id,memory:c,items:e,sequences:d,chars:f,status:this.o,cache:this.b.length,matcher:B.length,worker:this.c}}};f.prototype.reset=function(){this.destroy();return this.init()};f.prototype.destroy=function(){this.cache&& 0;a<this.c;a++)this.h[a].postMessage(a,{info:!0,id:this.id});else{for(var b,e,c=0,d=0,f=0,g=0;10>g;g++)for(b=Object.keys(this.j[g]),a=0;a<b.length;a++)e=this.j[g][b[a]].length,c+=1*e+2*b[a].length+4,d+=e,f+=2*b[a].length;b=Object.keys(this.a);e=b.length;for(a=0;a<e;a++)c+=2*b[a].length+2;return{id:this.id,memory:c,items:e,sequences:d,chars:f,cache:this.b.length,matcher:B.length,worker:this.c}}};f.prototype.reset=function(){this.destroy();return this.init()};f.prototype.destroy=function(){this.cache&&
(this.i.reset(),this.i=null);this.filter=this.stemmer=this.j=this.l=this.a=this.f=this.b=null;return this};var A={icase:function(a){return a.toLowerCase()},simple:function(){var a=[d("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",d("[\u00e8\u00e9\u00ea\u00eb]"),"e",d("[\u00ec\u00ed\u00ee\u00ef]"),"i",d("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",d("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",d("[\u00fd\u0177\u00ff]"),"y",d("\u00f1"),"n",d("\u00e7"),"c",d("\u00df"),"s",d(" & ")," and ",d("[-/]")," ",d("[^a-z0-9 ]"), (this.i.reset(),this.i=null);this.filter=this.stemmer=this.j=this.l=this.a=this.f=this.b=null;return this};var A={icase:function(a){return a.toLowerCase()},simple:function(){var a=[d("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",d("[\u00e8\u00e9\u00ea\u00eb]"),"e",d("[\u00ec\u00ed\u00ee\u00ef]"),"i",d("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",d("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",d("[\u00fd\u0177\u00ff]"),"y",d("\u00f1"),"n",d("\u00e7"),"c",d("\u00df"),"s",d(" & ")," and ",d("[-/]")," ",d("[^a-z0-9 ]"),
"",d("\\s\\s+")," "];return function(b){b=y(b.toLowerCase(),a);return" "!==b?b:""}}(),advanced:function(){var a=[d("ae"),"a",d("ai"),"ei",d("ay"),"ei",d("ey"),"ei",d("oe"),"o",d("ue"),"u",d("ie"),"i",d("sz"),"s",d("zs"),"s",d("sh"),"s",d("ck"),"k",d("cc"),"k",d("dt"),"t",d("ph"),"f",d("pf"),"f",d("ou"),"o",d("uo"),"u"];return function(b,d){if(!b)return b;b=this.simple(b);2<b.length&&(b=y(b,a));d||1<b.length&&(b=E(b));return b}}(),extra:function(){var a=[d("p"),"b",d("z"),"s",d("[cgq]"),"k",d("n"), "",d("\\s\\s+")," "];return function(b){b=x(b.toLowerCase(),a);return" "!==b?b:""}}(),advanced:function(){var a=[d("ae"),"a",d("ai"),"ei",d("ay"),"ei",d("ey"),"ei",d("oe"),"o",d("ue"),"u",d("ie"),"i",d("sz"),"s",d("zs"),"s",d("sh"),"s",d("ck"),"k",d("cc"),"k",d("dt"),"t",d("ph"),"f",d("pf"),"f",d("ou"),"o",d("uo"),"u"];return function(b,d){if(!b)return b;b=this.simple(b);2<b.length&&(b=x(b,a));d||1<b.length&&(b=E(b));return b}}(),extra:function(){var a=[d("p"),"b",d("z"),"s",d("[cgq]"),"k",d("n"),
"m",d("d"),"t",d("[vw]"),"f",d("[aeiouy]"),""];return function(b){if(!b)return b;b=this.advanced(b,!0);if(1<b.length){b=b.split(" ");for(var d=0;d<b.length;d++){var c=b[d];1<c.length&&(b[d]=c[0]+y(c.substring(1),a))}b=b.join(" ");b=E(b)}return b}}(),balance:function(){var a=[d("[-/]")," ",d("[^a-z0-9 ]"),"",d("\\s\\s+")," "];return function(b){return E(y(b.toLowerCase(),a))}}()},I=function(){var a={};return function(b,d,c){var e=a[c];e&&clearTimeout(e);return a[c]=setTimeout(b,d)}}(),V=function(){function a(a){this.reset(); "m",d("d"),"t",d("[vw]"),"f",d("[aeiouy]"),""];return function(b){if(!b)return b;b=this.advanced(b,!0);if(1<b.length){b=b.split(" ");for(var d=0;d<b.length;d++){var c=b[d];1<c.length&&(b[d]=c[0]+x(c.substring(1),a))}b=b.join(" ");b=E(b)}return b}}(),balance:function(){var a=[d("[-/]")," ",d("[^a-z0-9 ]"),"",d("\\s\\s+")," "];return function(b){return E(x(b.toLowerCase(),a))}}()},I=function(){var a={};return function(b,d,c){var e=a[c];e&&clearTimeout(e);return a[c]=setTimeout(b,d)}}(),V=function(){function a(a){this.reset();
this.b=!0!==a&&a}a.prototype.reset=function(){this.cache={};this.count={};this.index={};this.a=[]};a.prototype.set=function(a,d){if(this.b&&"undefined"===typeof this.cache[a]){var b=this.a.length;if(b===this.b){b--;var e=this.a[b];delete this.cache[e];delete this.count[e];delete this.index[e]}this.index[a]=b;this.a[b]=a;this.count[a]=-1;this.cache[a]=d;this.get(a)}else this.cache[a]=d};a.prototype.get=function(a){var b=this.cache[a];if(this.b&&b){var c=++this.count[a],d=this.index,f=d[a];if(0<f){for(var g= this.b=!0!==a&&a}a.prototype.reset=function(){this.cache={};this.count={};this.index={};this.a=[]};a.prototype.set=function(a,d){if(this.b&&"undefined"===typeof this.cache[a]){var b=this.a.length;if(b===this.b){b--;var e=this.a[b];delete this.cache[e];delete this.count[e];delete this.index[e]}this.index[a]=b;this.a[b]=a;this.count[a]=-1;this.cache[a]=d;this.get(a)}else this.cache[a]=d};a.prototype.get=function(a){var b=this.cache[a];if(this.b&&b){var c=++this.count[a],d=this.index,f=d[a];if(0<f){for(var g=
this.a,h=f;this.count[g[--f]]<=c&&-1!==f;);f++;if(f!==h){for(c=h;c>f;c--)h=g[c-1],g[c]=h,d[h]=c;g[f]=a;d[a]=f}}}return b};return a}();return f}(function(){var v={},C=!("undefined"===typeof Blob||"undefined"===typeof URL||!URL.createObjectURL);return function(f,w,d,y,z){var q=f;f=C?URL.createObjectURL(new Blob(["var SUPPORT_WORKER = true;var SUPPORT_BUILTINS = true;var SUPPORT_DEBUG = true;var SUPPORT_CACHE = true;var SUPPORT_ASYNC = true;("+d.toString()+")()"],{type:"text/javascript"})):"../"+q+".js"; this.a,h=f;this.count[g[--f]]<=c&&-1!==f;);f++;if(f!==h){for(c=h;c>f;c--)h=g[c-1],g[c]=h,d[h]=c;g[f]=a;d[a]=f}}}return b};return a}();return f}(function(){var v={},C=!("undefined"===typeof Blob||"undefined"===typeof URL||!URL.createObjectURL);return function(f,w,d,x,z){var q=f;f=C?URL.createObjectURL(new Blob(["var SUPPORT_WORKER = true;var SUPPORT_BUILTINS = true;var SUPPORT_DEBUG = true;var SUPPORT_CACHE = true;var SUPPORT_ASYNC = true;("+d.toString()+")()"],{type:"text/javascript"})):"../"+q+".js";
q+="-"+w;v[q]||(v[q]=[]);v[q][z]=new Worker(f);v[q][z].onmessage=y;console.log("Register Worker: "+q+"@"+z);return{postMessage:function(d,f){v[q][d].postMessage(f)}}}}()),this); q+="-"+w;v[q]||(v[q]=[]);v[q][z]=new Worker(f);v[q][z].onmessage=x;console.log("Register Worker: "+q+"@"+z);return{postMessage:function(d,f){v[q][d].postMessage(f)}}}}()),this);

View File

@@ -1,6 +1,6 @@
{ {
"name": "flexsearch", "name": "flexsearch",
"version": "0.2.63", "version": "0.2.65",
"description": "Next-Generation full text search library with zero dependencies.", "description": "Next-Generation full text search library with zero dependencies.",
"homepage": "https://github.com/nextapps-de/flexsearch/", "homepage": "https://github.com/nextapps-de/flexsearch/",
"author": "Thomas Wilkerling", "author": "Thomas Wilkerling",

View File

@@ -1126,7 +1126,7 @@ if(env !== 'light'){
'id', 'id',
'chars', 'chars',
'status', //'status',
'cache', 'cache',
'items', 'items',
'matcher', 'matcher',