OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/history/scored_history_match.h" | 5 #include "chrome/browser/history/scored_history_match.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <iterator> | 9 #include <iterator> |
10 #include <numeric> | 10 #include <numeric> |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 if (use_new_scoring) { | 112 if (use_new_scoring) { |
113 const float topicality_score = GetTopicalityScore( | 113 const float topicality_score = GetTopicalityScore( |
114 terms.size(), url, url_matches, title_matches, word_starts); | 114 terms.size(), url, url_matches, title_matches, word_starts); |
115 const float recency_score = GetRecencyScore( | 115 const float recency_score = GetRecencyScore( |
116 (now - row.last_visit()).InDays()); | 116 (now - row.last_visit()).InDays()); |
117 const float popularity_score = GetPopularityScore( | 117 const float popularity_score = GetPopularityScore( |
118 row.typed_count(), row.visit_count()); | 118 row.typed_count(), row.visit_count()); |
119 | 119 |
120 // Combine recency, popularity, and topicality scores into one. | 120 // Combine recency, popularity, and topicality scores into one. |
121 // Example of how this functions: Suppose the omnibox has one | 121 // Example of how this functions: Suppose the omnibox has one |
122 // input term. Suppose we have a URL that has 8 typed visits with | 122 // input term. Suppose we have a URL that has 30 typed visits with |
123 // the most recent being within a day and the omnibox input term | 123 // the most recent being within a day and the omnibox input term |
124 // has a single URL hostname hit at a word boundary. Then this | 124 // has a single URL hostname hit at a word boundary. Then this |
125 // URL will score 1300 ( = 8 * 162.5), which is exactly the value of | 125 // URL will score 1200 ( = 30 * 40.0). |
126 // search what you type. That is, it's the boundary of what might | 126 raw_score = 40.0 * topicality_score * recency_score * popularity_score; |
127 // end up being inlined. | |
128 raw_score = 162.5 * topicality_score * recency_score * popularity_score; | |
129 raw_score = | 127 raw_score = |
130 (raw_score <= kint32max) ? static_cast<int>(raw_score) : kint32max; | 128 (raw_score <= kint32max) ? static_cast<int>(raw_score) : kint32max; |
131 } else { // "old" scoring | 129 } else { // "old" scoring |
132 // Get partial scores based on term matching. Note that the score for | 130 // Get partial scores based on term matching. Note that the score for |
133 // each of the URL and title are adjusted by the fraction of the | 131 // each of the URL and title are adjusted by the fraction of the |
134 // terms appearing in each. | 132 // terms appearing in each. |
135 int url_score = ScoreComponentForMatches(url_matches, url.length()) * | 133 int url_score = ScoreComponentForMatches(url_matches, url.length()) * |
136 std::min(url_matches.size(), terms.size()) / terms.size(); | 134 std::min(url_matches.size(), terms.size()) / terms.size(); |
137 int title_score = | 135 int title_score = |
138 ScoreComponentForMatches(title_matches, title.length()) * | 136 ScoreComponentForMatches(title_matches, title.length()) * |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 // Add a beacon to the logs that'll allow us to identify later what | 524 // Add a beacon to the logs that'll allow us to identify later what |
527 // new scoring state a user is in. Do this by incrementing a bucket in | 525 // new scoring state a user is in. Do this by incrementing a bucket in |
528 // a histogram, where the bucket represents the user's new scoring state. | 526 // a histogram, where the bucket represents the user's new scoring state. |
529 UMA_HISTOGRAM_ENUMERATION( | 527 UMA_HISTOGRAM_ENUMERATION( |
530 "Omnibox.HistoryQuickProviderNewScoringFieldTrialBeacon", | 528 "Omnibox.HistoryQuickProviderNewScoringFieldTrialBeacon", |
531 new_scoring_option, NUM_OPTIONS); | 529 new_scoring_option, NUM_OPTIONS); |
532 | 530 |
533 } | 531 } |
534 | 532 |
535 } // namespace history | 533 } // namespace history |
OLD | NEW |