diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-09 20:40:18 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-09 20:40:18 +0000 |
commit | aa613d6a7ac972a04dd8cdacf2f859f94a8323f1 (patch) | |
tree | 1c0970248a087b30efe8e79b164e2689202a8de8 /chrome/browser/autocomplete | |
parent | 78b2d6be203b2db0af23e00695b5260217e7ba23 (diff) | |
download | chromium_src-aa613d6a7ac972a04dd8cdacf2f859f94a8323f1.zip chromium_src-aa613d6a7ac972a04dd8cdacf2f859f94a8323f1.tar.gz chromium_src-aa613d6a7ac972a04dd8cdacf2f859f94a8323f1.tar.bz2 |
Tweaks the ranking of past searches so they get autocompleted.
If you don't like the scoring I've given them, please suggest an
alternative.
BUG=61518
TEST=none
Review URL: http://codereview.chromium.org/4751001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65566 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete')
-rw-r--r-- | chrome/browser/autocomplete/autocomplete.h | 14 | ||||
-rw-r--r-- | chrome/browser/autocomplete/search_provider.cc | 24 |
2 files changed, 29 insertions, 9 deletions
diff --git a/chrome/browser/autocomplete/autocomplete.h b/chrome/browser/autocomplete/autocomplete.h index 25c8341..4f24852 100644 --- a/chrome/browser/autocomplete/autocomplete.h +++ b/chrome/browser/autocomplete/autocomplete.h @@ -42,10 +42,11 @@ // --------------------------------------------------------------------|----- // Keyword (non-substituting or in keyword UI mode, exact match) | 1500 // HistoryURL (exact or inline autocomplete match) | 1400 +// Search Primary Provider (past query in history within 2 days) | 1399** // Search Primary Provider (what you typed) | 1300 // HistoryURL (what you typed) | 1200 // Keyword (substituting, exact match) | 1100 -// Search Primary Provider (past query in history) | 1050-- +// Search Primary Provider (past query in history older than 2 days) | 1050-- // HistoryContents (any match in title of starred page) | 1000++ // HistoryURL (inexact match) | 900++ // Search Primary Provider (navigational suggestion) | 800++ @@ -63,10 +64,11 @@ // --------------------------------------------------------------------|----- // Keyword (non-substituting or in keyword UI mode, exact match) | 1500 // HistoryURL (exact or inline autocomplete match) | 1400 +// Search Primary Provider (past query in history within 2 days) | 1399** // HistoryURL (what you typed) | 1200 // Search Primary Provider (what you typed) | 1150 // Keyword (substituting, exact match) | 1100 -// Search Primary Provider (past query in history) | 1050-- +// Search Primary Provider (past query in history older than 2 days) | 1050-- // HistoryContents (any match in title of starred page) | 1000++ // HistoryURL (inexact match) | 900++ // Search Primary Provider (navigational suggestion) | 800++ @@ -102,8 +104,9 @@ // Keyword (non-substituting or in keyword UI mode, exact match) | 1500 // Keyword (substituting, exact match) | 1450 // HistoryURL (exact or inline autocomplete match) | 1400 +// Search Primary Provider (past query in history within 2 days) | 1399** // Search Primary Provider (what you typed) | 1300 -// Search Primary Provider (past query in history) | 1050-- +// Search Primary Provider (past query in history older than 2 days) | 1050-- // HistoryContents (any match in title of starred page) | 1000++ // HistoryURL (inexact match) | 900++ // Search Primary Provider (navigational suggestion) | 800++ @@ -119,8 +122,9 @@ // // FORCED_QUERY input type: // --------------------------------------------------------------------|----- +// Search Primary Provider (past query in history within 2 days) | 1399** // Search Primary Provider (what you typed) | 1300 -// Search Primary Provider (past query in history) | 1050-- +// Search Primary Provider (past query in history older than 2 days) | 1050-- // HistoryContents (any match in title of starred page) | 1000++ // Search Primary Provider (navigational suggestion) | 800++ // HistoryContents (any match in title of nonstarred page) | 700++ @@ -140,6 +144,8 @@ // ++: a series of matches with relevance from n up to (n + max_matches). // --: relevance score falls off over time (discounted 50 points @ 15 minutes, // 450 points @ two weeks) +// --: relevance score falls off over two days (discounted 99 points after two +// days). class AutocompleteInput; struct AutocompleteMatch; diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc index 408e647..ef8eb13 100644 --- a/chrome/browser/autocomplete/search_provider.cc +++ b/chrome/browser/autocomplete/search_provider.cc @@ -565,11 +565,25 @@ int SearchProvider::CalculateRelevanceForWhatYouTyped() const { int SearchProvider::CalculateRelevanceForHistory(const Time& time, bool is_keyword) const { - // The relevance of past searches falls off over time. This curve is chosen - // so that the relevance of a search 15 minutes ago is discounted about 50 - // points, while the relevance of a search two weeks ago is discounted about - // 450 points. - const double elapsed_time = std::max((Time::Now() - time).InSecondsF(), 0.); + // The relevance of past searches falls off over time. There are two distinct + // equations used. If the first equation is used (searches to the primary + // provider with a type other than URL) the score starts at 1399 and falls to + // 1300. If the second equation is used the relevance of a search 15 minutes + // ago is discounted about 50 points, while the relevance of a search two + // weeks ago is discounted about 450 points. + double elapsed_time = std::max((Time::Now() - time).InSecondsF(), 0.); + + if (providers_.is_primary_provider(is_keyword) && + input_.type() != AutocompleteInput::URL) { + // Searches with the past two days get a different curve. + const double autocomplete_time= 2 * 24 * 60 * 60; + if (elapsed_time < autocomplete_time) { + return 1399 - static_cast<int>(99 * + std::pow(elapsed_time / autocomplete_time, 2.5)); + } + elapsed_time -= autocomplete_time; + } + const int score_discount = static_cast<int>(6.5 * std::pow(elapsed_time, 0.3)); |