Comparing version 2.0.1 to 2.0.2
@@ -222,5 +222,12 @@ /*! | ||
idf = lunr.idf(this.invertedIndex[term], this.documentCount), | ||
score = idf * ((this._k1 + 1) * tf) / (this._k1 * (1 - this._b + this._b * (documentLength / this.averageDocumentLength)) + tf) | ||
score = idf * ((this._k1 + 1) * tf) / (this._k1 * (1 - this._b + this._b * (documentLength / this.averageDocumentLength)) + tf), | ||
scoreWithPrecision = Math.round(score * 1000) / 1000 | ||
// Converts 1.23456789 to 1.234. | ||
// Reducing the precision so that the vectors take up less | ||
// space when serialised. Doing it now so that they behave | ||
// the same before and after serialisation. Also, this is | ||
// the fastest approach to reducing a number's precision in | ||
// JavaScript. | ||
documentVector.insert(termIndex, score) | ||
documentVector.insert(termIndex, scoreWithPrecision) | ||
} | ||
@@ -227,0 +234,0 @@ |
@@ -117,2 +117,15 @@ lunr.QueryLexer = function (str) { | ||
// This matches the separator used when tokenising fields | ||
// within a document. These should match otherwise it is | ||
// not possible to search for some tokens within a document. | ||
// | ||
// It is possible for the user to change the separator on the | ||
// tokenizer so it _might_ clash with any other of the special | ||
// characters already used within the search string, e.g. :. | ||
// | ||
// This means that it is possible to change the separator in | ||
// such a way that makes some words unsearchable using a search | ||
// string. | ||
lunr.QueryLexer.termSeparator = lunr.tokenizer.separator | ||
lunr.QueryLexer.lexText = function (lexer) { | ||
@@ -146,4 +159,3 @@ while (true) { | ||
// TODO: there may be more separators we want to consider | ||
if (char == " ") { | ||
if (char.match(lunr.QueryLexer.termSeparator)) { | ||
return lunr.QueryLexer.lexTerm | ||
@@ -150,0 +162,0 @@ } |
{ | ||
"name": "lunr", | ||
"description": "Simple full-text search in your browser.", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"author": "Oliver Nightingale", | ||
@@ -6,0 +6,0 @@ "keywords": ["search"], |
@@ -116,2 +116,12 @@ suite('lunr.QueryLexer', function () { | ||
suite('hyphen (-) considered a seperator', function () { | ||
setup(function () { | ||
this.lexer = lex('foo-bar') | ||
}) | ||
test('produces 1 lexeme', function () { | ||
assert.lengthOf(this.lexer.lexemes, 2) | ||
}) | ||
}) | ||
suite('term with field', function () { | ||
@@ -118,0 +128,0 @@ setup(function () { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
573393
18085