diff options
author | georgey@chromium.org <georgey@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-11 00:38:59 +0000 |
---|---|---|
committer | georgey@chromium.org <georgey@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-11 00:38:59 +0000 |
commit | 56e2654b2e5564e45de62baa5bac976f01155e72 (patch) | |
tree | cf596e6fe919d6149d162a807b5197d6c4c0d014 /chrome/browser/autocomplete/shortcuts_provider.cc | |
parent | 265872914d4a775ab9d1718a404a94a0ce009698 (diff) | |
download | chromium_src-56e2654b2e5564e45de62baa5bac976f01155e72.zip chromium_src-56e2654b2e5564e45de62baa5bac976f01155e72.tar.gz chromium_src-56e2654b2e5564e45de62baa5bac976f01155e72.tar.bz2 |
Adjust scoring of shortcuts based on the percentage of entered data from linear to quadratic.
Right now we base score of the result on three factors: firstly, the score is dependent on the time
passed since last click on the shortcut, secondly the score is dependent on the number of usages of
the shortcut, and thirdly it dependent on the what percentage of the string is entered by the user.
First two dependencies are logarithmic, the third one is currently linear. This changelist changes it to
quadratic. For example, here are changes in scoring for 10 letter term, depending on how many letters
user entered (percentage is relative to score achieved based on first two factors):
1 letter entered - 10% using old scoring / 31% using new scoring, 2 letters - 20% / 44%, 3 letters - 30% / 54%,
4 letters - 40% / 63%, 5 - 50% / 71%, 6 - 60% / 77%, 7 - 70% / 84%, 8 - 80% / 89%. 9 - 90% / 95%,
10 (whole term) - 100% / 100%. As you see the score becomes "significant" quicker.
BUG=none
TEST=unit-test
Review URL: http://codereview.chromium.org/9252030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121589 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete/shortcuts_provider.cc')
-rw-r--r-- | chrome/browser/autocomplete/shortcuts_provider.cc | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/chrome/browser/autocomplete/shortcuts_provider.cc b/chrome/browser/autocomplete/shortcuts_provider.cc index ce2c38c..fecada3 100644 --- a/chrome/browser/autocomplete/shortcuts_provider.cc +++ b/chrome/browser/autocomplete/shortcuts_provider.cc @@ -118,13 +118,6 @@ void ShortcutsProvider::OnShortcutsLoaded() { initialized_ = true; } -int ShortcutsProvider::GetMaxScore() { - // For ease of unit testing, make the clamp value divisible by 4 (since some - // tests check for half or quarter of the max score). - const int kMaxScore = (AutocompleteResult::kLowestDefaultScore - 1) & ~3; - return kMaxScore; -} - void ShortcutsProvider::DeleteMatchesWithURLs(const std::set<GURL>& urls) { std::remove_if(matches_.begin(), matches_.end(), RemoveMatchPredicate(urls)); listener_->OnProviderUpdate(true); @@ -277,8 +270,13 @@ int ShortcutsProvider::CalculateScore(const string16& terms, DCHECK_LE(terms.length(), shortcut.text.length()); // The initial score is based on how much of the shortcut the user has typed. - double base_score = GetMaxScore() * static_cast<double>(terms.length()) / - shortcut.text.length(); + // Using the square root of the typed fraction boosts the base score rapidly + // as characters are typed, compared with simply using the typed fraction + // directly. This makes sense since the first characters typed are much more + // important for determining how likely it is a user wants a particular + // shortcut than are the remaining continued characters. + double base_score = (AutocompleteResult::kLowestDefaultScore - 1) * + sqrt(static_cast<double>(terms.length()) / shortcut.text.length()); // Then we decay this by half each week. const double kLn2 = 0.6931471805599453; @@ -309,4 +307,3 @@ void ShortcutsProvider::set_shortcuts_backend( if (shortcuts_backend_->initialized()) initialized_ = true; } - |