From 4abd6fe7602108ef7b2179645f570e0737444777 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 3 Nov 2012 08:19:57 +0000 Subject: Improve consistency and fix relevancy calculation. Problem: - The word relevancy calculation is case sensitive, all other matching is case insensitive. Improve consistency: - Highlighting of elements in the vomnibox is case insensitive; this does not match the case sensitive relevancy calculation. Fix: - Bookmark titles, in particular, tend to contain capital letters. Unless the query term also contains the relevant capital letters, then the term was scored at zero, pushing what seem to be good matches to the bottom of the list. In fact, they were only included in the list at all because they happen to pass the `RankingUtils.matches()` test. --- background_scripts/completion.coffee | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'background_scripts') diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee index f7313756..96b74100 100644 --- a/background_scripts/completion.coffee +++ b/background_scripts/completion.coffee @@ -254,7 +254,7 @@ RankingUtils = matches: (queryTerms, url, title) -> for term in queryTerms regexp = RegexpCache.get(term) - return false unless title.match(regexp) || url.match(regexp) + return false unless (title && title.match(regexp)) || (url && url.match(regexp)) true # Returns a number between [0, 1] indicating how often the query terms appear in the url and title. @@ -264,8 +264,8 @@ RankingUtils = titleScore = 0.0 for term in queryTerms queryLength += term.length - urlScore += 1 if url.indexOf(term) >= 0 - titleScore += 1 if title && title.indexOf(term) >= 0 + urlScore += 1 if RankingUtils.matches([term], url, null) + titleScore += 1 if RankingUtils.matches([term], null, title) urlScore = urlScore / queryTerms.length urlScore = urlScore * RankingUtils.normalizeDifference(queryLength, url.length) if title -- cgit v1.2.3