diff options
| author | Niklas Baumstark | 2012-01-21 15:53:25 +0100 |
|---|---|---|
| committer | Niklas Baumstark | 2012-04-10 23:54:36 +0200 |
| commit | 642694bcc5850b31648bf56d8e2bd65184f377d3 (patch) | |
| tree | 490d5d88094d4a3b516128e167f143dbd6dd3bc2 /lib | |
| parent | 3520212b6ef4945b96fc061ecfe7c198195e1ee4 (diff) | |
| download | vimium-642694bcc5850b31648bf56d8e2bd65184f377d3.tar.bz2 | |
fix relevancy heuristic
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/completion.js | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/completion.js b/lib/completion.js index 1eb87d51..afdb7f55 100644 --- a/lib/completion.js +++ b/lib/completion.js @@ -21,7 +21,8 @@ var completion = (function() { } /** Calculates a very simple similarity value between a :query and a :string. The current - * implementation simply returns the cumulated length of query parts that are also in the string. + * implementation simply returns the cumulated length of query parts that are also found + * in the string, raised to the power of 3. */ self.calculateRelevancy = function(query, str) { query = self.normalize(query); @@ -37,7 +38,7 @@ var completion = (function() { } } - return sum; + return sum * sum * sum; } /** Trims the size of the regex cache to the configured size using a FIFO algorithm. */ @@ -201,13 +202,15 @@ var completion = (function() { this.readyCallback = this.fallbackReadyCallback = function(results) { this.completions = results; } + this.extractStringFromMatch = function(match) { return stripHtmlTags(match.str); } } AsyncFuzzyUrlCompleter.prototype = { // to be implemented by subclasses refresh: function() { }, calculateRelevancy: function(query, match) { - return match.url.length * 10 / (fuzzyMatcher.calculateRelevancy(query, match.str)+1); + return match.url.length * 10 / + (fuzzyMatcher.calculateRelevancy(query, this.extractStringFromMatch(match)) + 1); }, filter: function(query, callback) { @@ -216,7 +219,7 @@ var completion = (function() { var handler = function(results) { var filtered = []; fuzzyMatcher.filter(query, - results, function(comp) { return stripHtmlTags(comp.str) }, + results, self.extractStringFromMatch, self.id, function(match) { filtered.push(createHighlightingCompletion( |
