diff options
| author | Stephen Blott | 2012-11-03 08:19:57 +0000 |
|---|---|---|
| committer | Stephen Blott | 2012-11-03 08:19:57 +0000 |
| commit | 4abd6fe7602108ef7b2179645f570e0737444777 (patch) | |
| tree | fd98b22b1d0219be7467a869a348aa499861832d /background_scripts | |
| parent | 4b58e9defe25cb851f5a7fa7ae957a2d5d2170d0 (diff) | |
| download | vimium-4abd6fe7602108ef7b2179645f570e0737444777.tar.bz2 | |
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.
Diffstat (limited to 'background_scripts')
| -rw-r--r-- | background_scripts/completion.coffee | 6 |
1 files changed, 3 insertions, 3 deletions
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 |
