From 1a9ea85f683c892592d7092c361e835c8b0f4f3e Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Tue, 5 May 2015 06:14:12 +0100 Subject: Search completion; tweak scoring. --- background_scripts/completion.coffee | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'background_scripts') diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee index e76139c2..33d8a563 100644 --- a/background_scripts/completion.coffee +++ b/background_scripts/completion.coffee @@ -353,6 +353,8 @@ class SearchEngineCompleter suggestions.push @mkSuggestion null, queryTerms, type, mkUrl(query), title, @computeRelevancy, 1 suggestions[0].autoSelect = true queryTerms = queryTerms[1..] + else + query = queryTerms.join " " if queryTerms.length == 0 return onComplete suggestions @@ -367,13 +369,11 @@ class SearchEngineCompleter # relevancy). We assume that the completion engine has already factored that in. Also, completion # engines often handle spelling mistakes, in which case we wouldn't find the query terms in the # suggestion anyway. - # - The score is based on the length of the last query term. The idea is that the user is already - # happy with the earlier terms. - # - The score is higher if the last query term is longer. The idea is that search suggestions are more + # - The score is higher if the query term is longer. The idea is that search suggestions are more # likely to be relevant if, after typing some number of characters, the user hasn't yet found # a useful suggestion from another completer. # - Scores are weighted such that they retain the order provided by the completion engine. - characterCount = queryTerms[queryTerms.length - 1].length + characterCount = query.length - queryTerms.length + 1 score = 0.6 * (Math.min(characterCount, 10.0)/10.0) if 0 < existingSuggestions.length -- cgit v1.2.3