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

Side by Side Diff: chrome/browser/history/scored_history_match.h

Issue 905023003: Adding knobs on HQP provider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing mark comments. Created 5 years, 10 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 unified diff | Download patch
OLDNEW
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 #ifndef CHROME_BROWSER_HISTORY_SCORED_HISTORY_MATCH_H_ 5 #ifndef CHROME_BROWSER_HISTORY_SCORED_HISTORY_MATCH_H_
6 #define CHROME_BROWSER_HISTORY_SCORED_HISTORY_MATCH_H_ 6 #define CHROME_BROWSER_HISTORY_SCORED_HISTORY_MATCH_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 11 matching lines...) Expand all
22 22
23 // An HistoryMatch that has a score as well as metrics defining where in the 23 // An HistoryMatch that has a score as well as metrics defining where in the
24 // history item's URL and/or page title matches have occurred. 24 // history item's URL and/or page title matches have occurred.
25 class ScoredHistoryMatch : public history::HistoryMatch { 25 class ScoredHistoryMatch : public history::HistoryMatch {
26 public: 26 public:
27 // The maximum number of recent visits to examine in GetFrequency(). 27 // The maximum number of recent visits to examine in GetFrequency().
28 // Public so url_index_private_data.cc knows how many visits it is 28 // Public so url_index_private_data.cc knows how many visits it is
29 // expected to deliver (at minimum) to this class. 29 // expected to deliver (at minimum) to this class.
30 static const size_t kMaxVisitsToScore; 30 static const size_t kMaxVisitsToScore;
31 31
32 // ScoreMaxRelevance maps from an intermediate-score to the maximum
33 // final-relevance score given to a URL for this intermediate score.
34 // This is used to store the score ranges of HQP relevance buckets.
35 // Please see GetFinalRelevancyScore() for details.
36 typedef std::pair<double, int> ScoreMaxRelevance;
37
32 ScoredHistoryMatch(); // Required by STL. 38 ScoredHistoryMatch(); // Required by STL.
33 39
34 // Creates a new match with a raw score calculated for the history item 40 // Creates a new match with a raw score calculated for the history item
35 // given in |row| with recent visits as indicated in |visits|. First 41 // given in |row| with recent visits as indicated in |visits|. First
36 // determines if the row qualifies by seeing if all of the terms in 42 // determines if the row qualifies by seeing if all of the terms in
37 // |terms_vector| occur in |row|. If so, calculates a raw score. This raw 43 // |terms_vector| occur in |row|. If so, calculates a raw score. This raw
38 // score is in part determined by whether the matches occur at word 44 // score is in part determined by whether the matches occur at word
39 // boundaries, the locations of which are stored in |word_starts|. For some 45 // boundaries, the locations of which are stored in |word_starts|. For some
40 // terms, it's appropriate to look for the word boundary within the term. 46 // terms, it's appropriate to look for the word boundary within the term.
41 // For instance, the term ".net" should look for a word boundary at the "n". 47 // For instance, the term ".net" should look for a word boundary at the "n".
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 // end_pos == string::npos is treated as end_pos = length of string. 82 // end_pos == string::npos is treated as end_pos = length of string.
77 static TermMatches FilterTermMatchesByWordStarts( 83 static TermMatches FilterTermMatchesByWordStarts(
78 const TermMatches& term_matches, 84 const TermMatches& term_matches,
79 const WordStarts& terms_to_word_starts_offsets, 85 const WordStarts& terms_to_word_starts_offsets,
80 const WordStarts& word_starts, 86 const WordStarts& word_starts,
81 size_t start_pos, 87 size_t start_pos,
82 size_t end_pos); 88 size_t end_pos);
83 89
84 private: 90 private:
85 friend class ScoredHistoryMatchTest; 91 friend class ScoredHistoryMatchTest;
92 FRIEND_TEST_ALL_PREFIXES(ScoredHistoryMatchTest, GetFinalRelevancyScore);
86 FRIEND_TEST_ALL_PREFIXES(ScoredHistoryMatchTest, ScoringBookmarks); 93 FRIEND_TEST_ALL_PREFIXES(ScoredHistoryMatchTest, ScoringBookmarks);
87 FRIEND_TEST_ALL_PREFIXES(ScoredHistoryMatchTest, ScoringDiscountFrecency); 94 FRIEND_TEST_ALL_PREFIXES(ScoredHistoryMatchTest, ScoringDiscountFrecency);
88 FRIEND_TEST_ALL_PREFIXES(ScoredHistoryMatchTest, ScoringScheme); 95 FRIEND_TEST_ALL_PREFIXES(ScoredHistoryMatchTest, ScoringScheme);
89 FRIEND_TEST_ALL_PREFIXES(ScoredHistoryMatchTest, ScoringTLD); 96 FRIEND_TEST_ALL_PREFIXES(ScoredHistoryMatchTest, ScoringTLD);
90 97
91 // The number of days of recency scores to precompute. 98 // The number of days of recency scores to precompute.
92 static const int kDaysToPrecomputeRecencyScoresFor; 99 static const int kDaysToPrecomputeRecencyScoresFor;
93 100
94 // The number of raw term score buckets use; raw term scores 101 // The number of raw term score buckets use; raw term scores
95 // greater this are capped at the score of the largest bucket. 102 // greater this are capped at the score of the largest bucket.
(...skipping 24 matching lines...) Expand all
120 // Examines the first kMaxVisitsToScore and return a score (higher is 127 // Examines the first kMaxVisitsToScore and return a score (higher is
121 // better) based the rate of visits, whether the page is bookmarked, and 128 // better) based the rate of visits, whether the page is bookmarked, and
122 // how often those visits are typed navigations (i.e., explicitly 129 // how often those visits are typed navigations (i.e., explicitly
123 // invoked by the user). |now| is passed in to avoid unnecessarily 130 // invoked by the user). |now| is passed in to avoid unnecessarily
124 // recomputing it frequently. 131 // recomputing it frequently.
125 static float GetFrequency(const base::Time& now, 132 static float GetFrequency(const base::Time& now,
126 const bool bookmarked, 133 const bool bookmarked,
127 const VisitInfoVector& visits); 134 const VisitInfoVector& visits);
128 135
129 // Combines the two component scores into a final score that's 136 // Combines the two component scores into a final score that's
130 // an appropriate value to use as a relevancy score. 137 // an appropriate value to use as a relevancy score. Scoring buckets are
138 // specified through |hqp_relevance_buckets|. Please see the function
139 // implementation for more details.
131 static float GetFinalRelevancyScore( 140 static float GetFinalRelevancyScore(
132 float topicality_score, 141 float topicality_score,
133 float frequency_score); 142 float frequency_score,
143 const std::vector<ScoreMaxRelevance>& hqp_relevance_buckets);
144
145 // Initializes the HQP experimental params,
Mark P 2015/02/18 00:03:32 nit: should this be a ":" or "("/")", not a ","?
Ashok vardhan 2015/02/18 01:11:21 Done.
146 // |hqp_experimental_scoring_enabled_|, |topicality_threshold_| and
147 // |hqp_relevance_buckets_| specified through omnibox field trials.
Mark P 2015/02/18 00:03:32 You missed this earlier comment: By the way, this
Ashok vardhan 2015/02/18 01:11:21 Done.
148 static void InitializeHQPExperimentalParams();
134 149
135 // Sets |also_do_hup_like_scoring_|, 150 // Sets |also_do_hup_like_scoring_|,
136 // |max_assigned_score_for_non_inlineable_matches_|, |bookmark_value_|, 151 // |max_assigned_score_for_non_inlineable_matches_|, |bookmark_value_|,
137 // |allow_tld_matches_|, and |allow_scheme_matches_| based on the field 152 // |allow_tld_matches_|, and |allow_scheme_matches_| based on the field
138 // trial state. 153 // trial state.
139 static void Init(); 154 static void Init();
140 155
141 // An interim score taking into consideration location and completeness 156 // An interim score taking into consideration location and completeness
142 // of the match. 157 // of the match.
143 int raw_score_; 158 int raw_score_;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 // state. 208 // state.
194 static bool also_do_hup_like_scoring_; 209 static bool also_do_hup_like_scoring_;
195 210
196 // The maximum score that can be assigned to non-inlineable matches. 211 // The maximum score that can be assigned to non-inlineable matches.
197 // This is useful because often we want inlineable matches to come 212 // This is useful because often we want inlineable matches to come
198 // first (even if they don't sometimes score as well as non-inlineable 213 // first (even if they don't sometimes score as well as non-inlineable
199 // matches) because if a non-inlineable match comes first than all matches 214 // matches) because if a non-inlineable match comes first than all matches
200 // will get demoted later in HistoryQuickProvider to non-inlineable scores. 215 // will get demoted later in HistoryQuickProvider to non-inlineable scores.
201 // Set to -1 to indicate no maximum score. 216 // Set to -1 to indicate no maximum score.
202 static int max_assigned_score_for_non_inlineable_matches_; 217 static int max_assigned_score_for_non_inlineable_matches_;
218
219 // True, if we enable hqp experimental scoring.
Mark P 2015/02/18 00:03:32 nit: True, if we enable hqp experimental scoring.
Ashok vardhan 2015/02/18 01:11:21 Done.
220 static bool hqp_experimental_scoring_enabled_;
221
222 // |topicality_threshold_| is used to control the topicality scoring.
223 // If |topicality_threshold_| > 0, then URLs with topicality-score < threshold
224 // are given score 0. By default it is initalized to -1.
Mark P 2015/02/18 00:03:32 "score of 0" or "topicality score of 0"? I think
Ashok vardhan 2015/02/18 01:11:21 Done.
225 static float topicality_threshold_;
226
227 // |hqp_relevance_buckets_| gives mapping from (topicality*frequency)
228 // to the final relevance scoring. Please see GetFinalRelevancyScore()
229 // for more details and scoring method.
230 static std::vector<ScoreMaxRelevance>* hqp_relevance_buckets_;
231
203 }; 232 };
204 typedef std::vector<ScoredHistoryMatch> ScoredHistoryMatches; 233 typedef std::vector<ScoredHistoryMatch> ScoredHistoryMatches;
205 234
206 } // namespace history 235 } // namespace history
207 236
208 #endif // CHROME_BROWSER_HISTORY_SCORED_HISTORY_MATCH_H_ 237 #endif // CHROME_BROWSER_HISTORY_SCORED_HISTORY_MATCH_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/history/scored_history_match.cc » ('j') | chrome/browser/history/scored_history_match.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698