diff options
author | dominich@chromium.org <dominich@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-16 15:25:50 +0000 |
---|---|---|
committer | dominich@chromium.org <dominich@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-16 15:25:50 +0000 |
commit | 61c256ec1f1bf63686598c15defe97ca424dcde1 (patch) | |
tree | 0d271310539f881b5e47b9b54487f2b1a168f6a9 /chrome/browser/autocomplete/history_url_provider.cc | |
parent | 238b63f5d24e2fe475fc57c1d98693033f1498b5 (diff) | |
download | chromium_src-61c256ec1f1bf63686598c15defe97ca424dcde1.zip chromium_src-61c256ec1f1bf63686598c15defe97ca424dcde1.tar.gz chromium_src-61c256ec1f1bf63686598c15defe97ca424dcde1.tar.bz2 |
Change scoring for history url provider.
BUG=92896
TEST=
Review URL: http://codereview.chromium.org/7650023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96947 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete/history_url_provider.cc')
-rw-r--r-- | chrome/browser/autocomplete/history_url_provider.cc | 44 |
1 files changed, 27 insertions, 17 deletions
diff --git a/chrome/browser/autocomplete/history_url_provider.cc b/chrome/browser/autocomplete/history_url_provider.cc index 8e9c114..9fcaaef 100644 --- a/chrome/browser/autocomplete/history_url_provider.cc +++ b/chrome/browser/autocomplete/history_url_provider.cc @@ -483,9 +483,31 @@ int HistoryURLProvider::CalculateRelevance(AutocompleteInput::Type input_type, float HistoryURLProvider::CalculateConfidence( const history::HistoryMatch& match, const history::HistoryMatches& matches) { - // TODO(dominich): Take into account bookmarked page? - // TODO(dominich): See CompareHistoryMatch for more measures to include. - // Using typed count in place of visit count as: + // Calculate a score based on typed count. + const float typed_numerator = match.url_info.typed_count(); + float typed_denominator = 0.0f; + for (history::HistoryMatches::const_iterator it = matches.begin(); + it != matches.end(); ++it) { + typed_denominator += it->url_info.typed_count(); + } + const float typed_score = (typed_denominator > 0.0f) ? + (typed_numerator / typed_denominator) : 0.0f; + + // Calculate a score based on visit count + const float visit_numerator = match.url_info.visit_count(); + float visit_denominator = 0.0f; + for (history::HistoryMatches::const_iterator it = matches.begin(); + it != matches.end(); ++it) { + visit_denominator += it->url_info.visit_count(); + } + const float visit_score = (visit_denominator > 0.0f) ? + (visit_numerator / visit_denominator) : 0.0f; + + // Calculate a score based on innermost matching. + const float innermost_score = (match.innermost_match ? 1.0f : 0.0f); + + // TODO(dominich): Add a boost for bookmarked pages? + // Prefer typed count to visit count as: // - It's a better indicator of what the user wants to open given that they // are typing in the address bar (users tend to open certain URLs by typing // and others by e.g. bookmarks, so visit_count is a good indicator of @@ -495,20 +517,8 @@ float HistoryURLProvider::CalculateConfidence( // (meaning many high-visit_count-URLs may be present in one query and // absent in a similar one), leading to wild swings in confidence for the // same result across distinct queries. - float numerator = match.url_info.typed_count(); - float denominator = 0.0f; - for (history::HistoryMatches::const_iterator it = matches.begin(); - it != matches.end(); ++it) { - denominator += it->url_info.typed_count(); - } - if (denominator < 1) { - numerator = match.url_info.visit_count(); - for (history::HistoryMatches::const_iterator it = matches.begin(); - it != matches.end(); ++it) { - denominator += it->url_info.visit_count(); - } - } - return (denominator > 0.0f ? numerator / denominator : 0); + // Add a boost for innermost matches (matches after scheme or 'www.'). + return (0.5f * typed_score) + (0.3f * visit_score) + (0.2f * innermost_score); } // static |