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

Unified Diff: chrome/browser/autocomplete/history_quick_provider.cc

Issue 7607007: Add confidence to AutocompleteMatch. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Response to pkasting Created 9 years, 4 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
Index: chrome/browser/autocomplete/history_quick_provider.cc
diff --git a/chrome/browser/autocomplete/history_quick_provider.cc b/chrome/browser/autocomplete/history_quick_provider.cc
index 57c9d118d7fdbb0cd3e9acc7bcd6a1a5dc2a43db..e2b0b71c0854cb564bc560b1f43a3b27acb78267 100644
--- a/chrome/browser/autocomplete/history_quick_provider.cc
+++ b/chrome/browser/autocomplete/history_quick_provider.cc
@@ -112,9 +112,11 @@ void HistoryQuickProvider::DoAutocomplete() {
const ScoredHistoryMatch& history_match(*match_iter);
if (history_match.raw_score > 0) {
AutocompleteMatch ac_match = QuickMatchToACMatch(
- history_match,
+ history_match, matches,
PreventInlineAutocomplete(autocomplete_input_),
&max_match_score);
+ UMA_HISTOGRAM_COUNTS_100("Autocomplete.Confidence_HistoryQuick",
+ ac_match.confidence * 100);
matches_.push_back(ac_match);
}
mrossetti 2011/08/09 23:40:43 You could calculate the denominator here and save
dominich 2011/08/10 16:10:13 See other comment regarding potential algorithm ch
}
@@ -126,15 +128,17 @@ const int HistoryQuickProvider::kMaxNonInliningScore =
AutocompleteMatch HistoryQuickProvider::QuickMatchToACMatch(
const ScoredHistoryMatch& history_match,
+ const ScoredHistoryMatches& history_matches,
bool prevent_inline_autocomplete,
int* max_match_score) {
DCHECK(max_match_score);
const history::URLRow& info = history_match.url_info;
int score = CalculateRelevance(history_match, max_match_score);
- AutocompleteMatch match(this, score, !!info.visit_count(),
+ float confidence = CalculateConfidence(history_match, history_matches);
+ AutocompleteMatch match(this, score, confidence, !!info.visit_count(),
history_match.url_matches.empty() ?
- AutocompleteMatch::HISTORY_URL :
- AutocompleteMatch::HISTORY_TITLE);
+ AutocompleteMatch::HISTORY_URL :
+ AutocompleteMatch::HISTORY_TITLE);
match.destination_url = info.url();
DCHECK(match.destination_url.is_valid());
@@ -201,6 +205,20 @@ int HistoryQuickProvider::CalculateRelevance(
}
// static
+float HistoryQuickProvider::CalculateConfidence(
+ const ScoredHistoryMatch& match,
+ const ScoredHistoryMatches& matches) {
+ float denominator = 0.0f;
+ for (ScoredHistoryMatches::const_iterator it = matches.begin();
mrossetti 2011/08/09 23:40:43 Why not just calculate the 'denominator' up in DoA
+ it != matches.end(); ++it) {
+ denominator += it->raw_score;
+ }
+ DCHECK(denominator > 0);
+
+ return static_cast<float>(match.raw_score) / denominator;
+}
+
+// static
ACMatchClassifications HistoryQuickProvider::SpansFromTermMatch(
const history::TermMatches& matches,
size_t text_length,

Powered by Google App Engine
This is Rietveld 408576698