!function(){vart=function(e){varn=newt.Index;returnn.pipeline.add(t.trimmer,t.stopWordFilter,t.stemmer),e&&e.call(n,n),n};t.version="0.5.12",t.utils={},t.utils.warn=function(t){returnfunction(e){t.console&&console.warn&&console.warn(e)}}(this),t.EventEmitter=function(){this.events={}},t.EventEmitter.prototype.addListener=function(){vart=Array.prototype.slice.call(arguments),e=t.pop(),n=t;if("function"!=typeofe)thrownewTypeError("last argument must be a function");n.forEach(function(t){this.hasHandler(t)||(this.events[t]=[]),this.events[t].push(e)},this)},t.EventEmitter.prototype.removeListener=function(t,e){if(this.hasHandler(t)){varn=this.events[t].indexOf(e);this.events[t].splice(n,1),this.events[t].length||deletethis.events[t]}},t.EventEmitter.prototype.emit=function(t){if(this.hasHandler(t)){vare=Array.prototype.slice.call(arguments,1);this.events[t].forEach(function(t){t.apply(void0,e)})}},t.EventEmitter.prototype.hasHandler=function(t){returntinthis.events},t.tokenizer=function(t){returnarguments.length&&null!=t&&void0!=t?Array.isArray(t)?t.map(function(t){returnt.toLowerCase()}):t.toString().trim().toLowerCase().split(/[\s\-\/]+/):[]},t.Pipeline=function(){this._stack=[]},t.Pipeline.registeredFunctions={},t.Pipeline.registerFunction=function(e,n){ninthis.registeredFunctions&&t.utils.warn("Overwriting existing registered function: "+n),e.label=n,t.Pipeline.registeredFunctions[e.label]=e},t.Pipeline.warnIfFunctionNotRegistered=function(e){varn=e.label&&e.labelinthis.registeredFunctions;n||t.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},t.Pipeline.load=function(e){varn=newt.Pipeline;returne.forEach(function(e){vari=t.Pipeline.registeredFunctions[e];if(!i)thrownewError("Cannot load un-registered function: "+e);n.add(i)}),n},t.Pipeline.prototype.add=function(){vare=Array.prototype.slice.call(arguments);e.forEach(function(e){t.Pipeline.warnIfFunctionNotRegistered(e),this._stack.push(e)},this)},t.Pipeline.prototype.after=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);vari=this._stack.indexOf(e);if(-1==i)thrownewError("Cannot find existingFn");i+=1,this._stack.splice(i,0,n)},t.Pipeline.prototype.before=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);vari=this._stack.indexOf(e);if(-1==i)thrownewError("Cannot find existingFn");this._stack.splice(i,0,n)},t.Pipeline.prototype.remove=function(t){vare=this._stack.indexOf(t);-1!=e&&this._stack.splice(e,1)},t.Pipeline.prototype.run=function(t){for(vare=[],n=t.length,i=this._stack.length,o=0;n>o;o++){for(varr=t[o],s=0;i>s&&(r=this._stack[s](r,o,t),void0!==r);s++);void0!==r&&e.push(r)}returne},t.Pipeline.prototype.reset=function(){this._stack=[]},t.Pipeline.prototype.toJSON=function(){returnthis._stack.map(function(e){returnt.Pipeline.warnIfFunctionNotRegistered(e),e.label})},t.Vector=function(){this._magnitude=null,this.list=void0,this.length=0},t.Vector.Node=function(t,e,n){this.idx=t,this.val=e,this.next=n},t.Vector.prototype.insert=function(e,n){this._magnitude=void0;vari=this.list;if(!i)returnthis.list=newt.Vector.Node(e,n,i),this.length++;if(e<i.idx)returnthis.list=newt.Vector.Node(e,n,i),this.length++;for(varo=i,r=i.next;void0!=r;){if(e<r.idx)returno.next=newt.Vector.Node(e,n,r),this.length++;o=r,r=r.next}returno.next=newt.Vector.Node(e,n,r),this.length++},t.Vector.prototype.magnitude=function(){if(this._magnitude)returnthis._magnitude;for(vart,e=this.list,n=0;e;)t=e.val,n+=t*t,e=e.next;returnthis._magnitude=Math.sqrt(n)},t.Vector.prototype.dot=function(t){for(vare=this.list,n=t.list,i=0;e&&n;)e.idx<n.idx?e=e.next:e.idx>n.idx?n=n.next:(i+=e.val*n.val,e=e.next,n=n.next);returni},t.Vector.prototype.similarity=function(t){returnthis.dot(t)/(this.magnitude()*t.magnitude())},t.SortedSet=function(){this.length=0,this.elements=[]},t.SortedSet.load=function(t){vare=newthis;returne.elements=t,e.length=t.length,e},t.SortedSet.prototype.add=function(){vart,e;for(t=0;t<arguments.length;t++)e=arguments[t],~this.indexOf(e)||this.elements.