Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Unified Diff: ui/app_list/search/tokenized_string_match.cc

Issue 1138193002: Changed the app list string matching formula. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/app_list/search/tokenized_string_match_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/app_list/search/tokenized_string_match.cc
diff --git a/ui/app_list/search/tokenized_string_match.cc b/ui/app_list/search/tokenized_string_match.cc
index e94f0ebef0f186e03b900fba9e4c62c26b552903..c7035bbf5658aee2ebfd6754a3deae8668cfac0e 100644
--- a/ui/app_list/search/tokenized_string_match.cc
+++ b/ui/app_list/search/tokenized_string_match.cc
@@ -4,6 +4,8 @@
#include "ui/app_list/search/tokenized_string_match.h"
+#include <cmath>
+
#include "base/i18n/string_search.h"
#include "base/logging.h"
#include "ui/app_list/search/tokenized_string_char_iterator.h"
@@ -218,10 +220,14 @@ bool TokenizedStringMatch::Calculate(const TokenizedString& query,
}
}
- // Using length() for normalizing is not 100% correct but should be good
- // enough compared with using real char count of the text.
- if (text.text().length())
- relevance_ /= text.text().length();
+ // Temper the relevance score with an exponential curve. Each point of
+ // relevance (roughly, each keystroke) is worth less than the last. This means
+ // that typing a few characters of a word is enough to promote matches very
+ // high, with any subsequent characters being worth comparatively less.
+ // TODO(mgiuca): This doesn't really play well with Omnibox results, since as
+ // you type more characters, the app/omnibox results tend to jump over each
+ // other.
+ relevance_ = 1.0 - std::pow(0.5, relevance_);
return relevance_ > kNoMatchScore;
}
« no previous file with comments | « no previous file | ui/app_list/search/tokenized_string_match_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698