Chromium Code Reviews| 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 #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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 // end_pos == string::npos is treated as end_pos = length of string. | 76 // end_pos == string::npos is treated as end_pos = length of string. |
| 77 static TermMatches FilterTermMatchesByWordStarts( | 77 static TermMatches FilterTermMatchesByWordStarts( |
| 78 const TermMatches& term_matches, | 78 const TermMatches& term_matches, |
| 79 const WordStarts& terms_to_word_starts_offsets, | 79 const WordStarts& terms_to_word_starts_offsets, |
| 80 const WordStarts& word_starts, | 80 const WordStarts& word_starts, |
| 81 size_t start_pos, | 81 size_t start_pos, |
| 82 size_t end_pos); | 82 size_t end_pos); |
| 83 | 83 |
| 84 private: | 84 private: |
| 85 friend class ScoredHistoryMatchTest; | 85 friend class ScoredHistoryMatchTest; |
| 86 FRIEND_TEST_ALL_PREFIXES(ScoredHistoryMatchTest, GetFinalRelevancyScore); | |
| 86 FRIEND_TEST_ALL_PREFIXES(ScoredHistoryMatchTest, ScoringBookmarks); | 87 FRIEND_TEST_ALL_PREFIXES(ScoredHistoryMatchTest, ScoringBookmarks); |
| 87 FRIEND_TEST_ALL_PREFIXES(ScoredHistoryMatchTest, ScoringDiscountFrecency); | 88 FRIEND_TEST_ALL_PREFIXES(ScoredHistoryMatchTest, ScoringDiscountFrecency); |
| 88 FRIEND_TEST_ALL_PREFIXES(ScoredHistoryMatchTest, ScoringScheme); | 89 FRIEND_TEST_ALL_PREFIXES(ScoredHistoryMatchTest, ScoringScheme); |
| 89 FRIEND_TEST_ALL_PREFIXES(ScoredHistoryMatchTest, ScoringTLD); | 90 FRIEND_TEST_ALL_PREFIXES(ScoredHistoryMatchTest, ScoringTLD); |
| 90 | 91 |
| 91 // The number of days of recency scores to precompute. | 92 // The number of days of recency scores to precompute. |
| 92 static const int kDaysToPrecomputeRecencyScoresFor; | 93 static const int kDaysToPrecomputeRecencyScoresFor; |
| 93 | 94 |
| 94 // The number of raw term score buckets use; raw term scores | 95 // The number of raw term score buckets use; raw term scores |
| 95 // greater this are capped at the score of the largest bucket. | 96 // greater this are capped at the score of the largest bucket. |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 120 // Examines the first kMaxVisitsToScore and return a score (higher is | 121 // Examines the first kMaxVisitsToScore and return a score (higher is |
| 121 // better) based the rate of visits, whether the page is bookmarked, and | 122 // better) based the rate of visits, whether the page is bookmarked, and |
| 122 // how often those visits are typed navigations (i.e., explicitly | 123 // how often those visits are typed navigations (i.e., explicitly |
| 123 // invoked by the user). |now| is passed in to avoid unnecessarily | 124 // invoked by the user). |now| is passed in to avoid unnecessarily |
| 124 // recomputing it frequently. | 125 // recomputing it frequently. |
| 125 static float GetFrequency(const base::Time& now, | 126 static float GetFrequency(const base::Time& now, |
| 126 const bool bookmarked, | 127 const bool bookmarked, |
| 127 const VisitInfoVector& visits); | 128 const VisitInfoVector& visits); |
| 128 | 129 |
| 129 // Combines the two component scores into a final score that's | 130 // Combines the two component scores into a final score that's |
| 130 // an appropriate value to use as a relevancy score. | 131 // an appropriate value to use as a relevancy score. |
|
Mark P
2015/02/11 21:57:29
This comment doesn't make sense attached to this t
Ashok vardhan
2015/02/12 19:56:31
Done.
| |
| 132 typedef std::pair<double, int> ScoreMaxRelevance; | |
| 133 | |
| 131 static float GetFinalRelevancyScore( | 134 static float GetFinalRelevancyScore( |
| 132 float topicality_score, | 135 float topicality_score, |
| 133 float frequency_score); | 136 float frequency_score, |
| 137 std::vector<ScoreMaxRelevance>& hqp_relevance_buckets); | |
|
Mark P
2015/02/11 21:57:30
const
Ashok vardhan
2015/02/12 19:56:31
Done.
| |
| 138 | |
| 139 // Initializes the HQP experimental params. | |
| 140 // If the experimental scoring is enabled, it sets: | |
| 141 // | |
| 142 // 1. hqp_experimental to true. Default value is set to false. | |
| 143 // | |
| 144 // 2. It initializes the topicality_threshold_, and hqp_scoring from the | |
| 145 // finch experiment params. | |
| 146 // | |
| 147 // 3. topicality_threshold_ is used to control the topicality scoring. | |
| 148 // If topicality_threshold > 0, then URLs with topicality score < threshold, | |
| 149 // are given score 0. It is initalized to -1; | |
| 150 // | |
| 151 // 4. hqp_relevance_buckets_, buckets that gives the mapping from | |
| 152 // (topicality*frequency) to the final relevance scoring. | |
| 153 // Please see GetFinalRelevancyScore() for more details and scoring method. | |
| 154 bool hqp_experimental_scoring_enabled_; | |
| 155 float topicality_threshold_; | |
| 156 | |
| 157 std::vector<ScoreMaxRelevance> hqp_relevance_buckets_; | |
| 158 | |
| 159 void InitializeHQPExperimentalParams(); | |
| 134 | 160 |
| 135 // Sets |also_do_hup_like_scoring_|, | 161 // Sets |also_do_hup_like_scoring_|, |
| 136 // |max_assigned_score_for_non_inlineable_matches_|, |bookmark_value_|, | 162 // |max_assigned_score_for_non_inlineable_matches_|, |bookmark_value_|, |
| 137 // |allow_tld_matches_|, and |allow_scheme_matches_| based on the field | 163 // |allow_tld_matches_|, and |allow_scheme_matches_| based on the field |
| 138 // trial state. | 164 // trial state. |
| 139 static void Init(); | 165 static void Init(); |
| 140 | 166 |
| 141 // An interim score taking into consideration location and completeness | 167 // An interim score taking into consideration location and completeness |
| 142 // of the match. | 168 // of the match. |
| 143 int raw_score_; | 169 int raw_score_; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 199 // matches) because if a non-inlineable match comes first than all matches | 225 // matches) because if a non-inlineable match comes first than all matches |
| 200 // will get demoted later in HistoryQuickProvider to non-inlineable scores. | 226 // will get demoted later in HistoryQuickProvider to non-inlineable scores. |
| 201 // Set to -1 to indicate no maximum score. | 227 // Set to -1 to indicate no maximum score. |
| 202 static int max_assigned_score_for_non_inlineable_matches_; | 228 static int max_assigned_score_for_non_inlineable_matches_; |
| 203 }; | 229 }; |
| 204 typedef std::vector<ScoredHistoryMatch> ScoredHistoryMatches; | 230 typedef std::vector<ScoredHistoryMatch> ScoredHistoryMatches; |
| 205 | 231 |
| 206 } // namespace history | 232 } // namespace history |
| 207 | 233 |
| 208 #endif // CHROME_BROWSER_HISTORY_SCORED_HISTORY_MATCH_H_ | 234 #endif // CHROME_BROWSER_HISTORY_SCORED_HISTORY_MATCH_H_ |
| OLD | NEW |