Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_OMNIBOX_BROWSER_OMNIBOX_FIELD_TRIAL_H_ | 5 #ifndef COMPONENTS_OMNIBOX_BROWSER_OMNIBOX_FIELD_TRIAL_H_ |
| 6 #define COMPONENTS_OMNIBOX_BROWSER_OMNIBOX_FIELD_TRIAL_H_ | 6 #define COMPONENTS_OMNIBOX_BROWSER_OMNIBOX_FIELD_TRIAL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
| 14 #include "components/metrics/proto/omnibox_event.pb.h" | 14 #include "components/metrics/proto/omnibox_event.pb.h" |
| 15 #include "components/omnibox/browser/autocomplete_match_type.h" | 15 #include "components/omnibox/browser/autocomplete_match_type.h" |
| 16 | 16 |
| 17 namespace base { | 17 namespace base { |
| 18 class TimeDelta; | 18 class TimeDelta; |
| 19 } | 19 } |
| 20 | 20 |
| 21 // The set of parameters customizing the HUP scoring. | 21 // The set of parameters customizing the HUP scoring. |
| 22 struct HUPScoringParams { | 22 struct HUPScoringParams { |
| 23 // A set of parameters describing how to cap a given count score. First, | 23 // A set of parameters describing how to cap a given count score. First, |
| 24 // we apply a half-life based decay of the given count and then find the | 24 // we apply a half-life based decay of the given count and then find the |
| 25 // maximum relevance score in the corresponding bucket list. | 25 // maximum relevance score based on the decay factor or counts specified |
| 26 // in the corresponding bucket list. See comment on |buckets_| for details. | |
| 26 class ScoreBuckets { | 27 class ScoreBuckets { |
| 27 public: | 28 public: |
| 28 // (decayed_count, max_relevance) pair. | 29 // Stores the count/decay-factor and corresponding score. |
| 30 // <decayed_count/decay-factor,max_relevance) pair. | |
|
Peter Kasting
2015/08/27 19:21:40
Nit: How about just:
Stores the max relevance at
Ashok vardhan
2015/08/27 19:51:38
Done.
| |
| 29 typedef std::pair<double, int> CountMaxRelevance; | 31 typedef std::pair<double, int> CountMaxRelevance; |
| 30 | 32 |
| 31 ScoreBuckets(); | 33 ScoreBuckets(); |
| 32 ~ScoreBuckets(); | 34 ~ScoreBuckets(); |
| 33 | 35 |
| 34 // Computes a half-life time decay given the |elapsed_time|. | 36 // Computes a half-life time decay given the |elapsed_time|. |
| 35 double HalfLifeTimeDecay(const base::TimeDelta& elapsed_time) const; | 37 double HalfLifeTimeDecay(const base::TimeDelta& elapsed_time) const; |
| 36 | 38 |
| 37 int relevance_cap() const { return relevance_cap_; } | 39 int relevance_cap() const { return relevance_cap_; } |
| 38 void set_relevance_cap(int relevance_cap) { | 40 void set_relevance_cap(int relevance_cap) { |
| 39 relevance_cap_ = relevance_cap; | 41 relevance_cap_ = relevance_cap; |
| 40 } | 42 } |
| 41 | 43 |
| 42 int half_life_days() const { return half_life_days_; } | 44 int half_life_days() const { return half_life_days_; } |
| 43 void set_half_life_days(int half_life_days) { | 45 void set_half_life_days(int half_life_days) { |
| 44 half_life_days_ = half_life_days; | 46 half_life_days_ = half_life_days; |
| 45 } | 47 } |
| 46 | 48 |
| 49 bool use_decay_factor() const { return use_decay_factor_; } | |
| 50 void set_use_decay_factor(bool use_decay_factor) { | |
| 51 use_decay_factor_ = use_decay_factor; | |
| 52 } | |
| 53 | |
| 47 std::vector<CountMaxRelevance>& buckets() { return buckets_; } | 54 std::vector<CountMaxRelevance>& buckets() { return buckets_; } |
| 48 const std::vector<CountMaxRelevance>& buckets() const { return buckets_; } | 55 const std::vector<CountMaxRelevance>& buckets() const { return buckets_; } |
| 49 | 56 |
| 50 private: | 57 private: |
| 51 // History matches with relevance score greater or equal to |relevance_cap_| | 58 // History matches with relevance score greater or equal to |relevance_cap_| |
| 52 // are not affected by this experiment. | 59 // are not affected by this experiment. |
| 53 // Set to -1, if there is no relevance cap in place and all matches are | 60 // Set to -1, if there is no relevance cap in place and all matches are |
| 54 // subject to demotion. | 61 // subject to demotion. |
| 55 int relevance_cap_; | 62 int relevance_cap_; |
| 56 | 63 |
| 57 // Half life time for a decayed count as measured since the last visit. | 64 // Half life time for a decayed count as measured since the last visit. |
| 58 // Set to -1 if not used. | 65 // Set to -1 if not used. |
| 59 int half_life_days_; | 66 int half_life_days_; |
| 60 | 67 |
| 61 // The relevance score caps for given decayed count values. | 68 // The relevance score caps for given decayed count values or decay factor |
| 62 // Each pair (decayed_count, max_score) indicates what the maximum relevance | 69 // values. If you are using decay factors, one has to set |
| 63 // score is of a decayed count equal or greater than decayed_count. | 70 // <use_decay_factor_> to true. |
| 71 // Each pair (decayed_count/decay-factor, max_score) indicates what the | |
| 72 // maximum relevance score is of a decayed count equal or greater than | |
| 73 // decayed_count. | |
|
Peter Kasting
2015/08/27 19:21:40
Nit: How about just:
The relevance score caps at
Ashok vardhan
2015/08/27 19:51:38
Done.
| |
| 64 // | 74 // |
| 65 // Consider this example: | 75 // Consider this example specifying the decayed counts: |
| 66 // [(1, 1000), (0.5, 500), (0, 100)] | 76 // [(1, 1000), (0.5, 500), (0, 100)] |
| 67 // If decayed count is 2 (which is >= 1), the corresponding match's maximum | 77 // If decayed count is 2 (which is >= 1), the corresponding match's maximum |
| 68 // relevance will be capped at 1000. In case of 0.5, the score is capped | 78 // relevance will be capped at 1000. In case of 0.5, the score is capped |
| 69 // at 500. Anything below 0.5 is capped at 100. | 79 // at 500. Anything below 0.5 is capped at 100. |
| 70 // | 80 // |
| 71 // This list is sorted by the pair's first element in descending order. | 81 // This list is sorted by the pair's first element in descending order. |
| 72 std::vector<CountMaxRelevance> buckets_; | 82 std::vector<CountMaxRelevance> buckets_; |
| 83 | |
| 84 // Specify decay factor in buckets rather than actual score. | |
|
Peter Kasting
2015/08/27 19:21:40
Nit: How about:
True when the bucket thresholds a
Ashok vardhan
2015/08/27 19:51:38
Done.
| |
| 85 bool use_decay_factor_; | |
| 73 }; | 86 }; |
| 74 | 87 |
| 75 HUPScoringParams() : experimental_scoring_enabled(false) {} | 88 HUPScoringParams() : experimental_scoring_enabled(false) {} |
| 76 | 89 |
| 77 bool experimental_scoring_enabled; | 90 bool experimental_scoring_enabled; |
| 78 | 91 |
| 79 ScoreBuckets typed_count_buckets; | 92 ScoreBuckets typed_count_buckets; |
| 80 | 93 |
| 81 // Used only when the typed count is 0. | 94 // Used only when the typed count is 0. |
| 82 ScoreBuckets visited_count_buckets; | 95 ScoreBuckets visited_count_buckets; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 203 current_page_classification, | 216 current_page_classification, |
| 204 DemotionMultipliers* demotions_by_type); | 217 DemotionMultipliers* demotions_by_type); |
| 205 | 218 |
| 206 // --------------------------------------------------------- | 219 // --------------------------------------------------------- |
| 207 // For the HistoryURL provider new scoring experiment that is part of the | 220 // For the HistoryURL provider new scoring experiment that is part of the |
| 208 // bundled omnibox field trial. | 221 // bundled omnibox field trial. |
| 209 | 222 |
| 210 // Initializes the HUP |scoring_params| based on the active HUP scoring | 223 // Initializes the HUP |scoring_params| based on the active HUP scoring |
| 211 // experiment. If there is no such experiment, this function simply sets | 224 // experiment. If there is no such experiment, this function simply sets |
| 212 // |scoring_params|->experimental_scoring_enabled to false. | 225 // |scoring_params|->experimental_scoring_enabled to false. |
| 226 static void GetDefaultHUPScoringParams(HUPScoringParams* scoring_params); | |
| 213 static void GetExperimentalHUPScoringParams(HUPScoringParams* scoring_params); | 227 static void GetExperimentalHUPScoringParams(HUPScoringParams* scoring_params); |
| 214 | 228 |
| 215 // For the HQPBookmarkValue experiment that's part of the | 229 // For the HQPBookmarkValue experiment that's part of the |
| 216 // bundled omnibox field trial. | 230 // bundled omnibox field trial. |
| 217 | 231 |
| 218 // Returns the value an untyped visit to a bookmark should receive. | 232 // Returns the value an untyped visit to a bookmark should receive. |
| 219 // Compare this value with the default of 1 for non-bookmarked untyped | 233 // Compare this value with the default of 1 for non-bookmarked untyped |
| 220 // visits to pages and the default of 20 for typed visits. Returns | 234 // visits to pages and the default of 20 for typed visits. Returns |
| 221 // 10 if the bookmark value experiment isn't active. | 235 // 10 if the bookmark value experiment isn't active. |
| 222 static int HQPBookmarkValue(); | 236 static int HQPBookmarkValue(); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 331 static const char kHQPFixFrequencyScoringBugsRule[]; | 345 static const char kHQPFixFrequencyScoringBugsRule[]; |
| 332 static const char kHQPNumTitleWordsRule[]; | 346 static const char kHQPNumTitleWordsRule[]; |
| 333 static const char kHQPAlsoDoHUPLikeScoringRule[]; | 347 static const char kHQPAlsoDoHUPLikeScoringRule[]; |
| 334 static const char kPreventUWYTDefaultForNonURLInputsRule[]; | 348 static const char kPreventUWYTDefaultForNonURLInputsRule[]; |
| 335 | 349 |
| 336 // Parameter names used by the HUP new scoring experiments. | 350 // Parameter names used by the HUP new scoring experiments. |
| 337 static const char kHUPNewScoringEnabledParam[]; | 351 static const char kHUPNewScoringEnabledParam[]; |
| 338 static const char kHUPNewScoringTypedCountRelevanceCapParam[]; | 352 static const char kHUPNewScoringTypedCountRelevanceCapParam[]; |
| 339 static const char kHUPNewScoringTypedCountHalfLifeTimeParam[]; | 353 static const char kHUPNewScoringTypedCountHalfLifeTimeParam[]; |
| 340 static const char kHUPNewScoringTypedCountScoreBucketsParam[]; | 354 static const char kHUPNewScoringTypedCountScoreBucketsParam[]; |
| 355 static const char kHUPNewScoringTypedCountUseDecayFactorParam[]; | |
| 341 static const char kHUPNewScoringVisitedCountRelevanceCapParam[]; | 356 static const char kHUPNewScoringVisitedCountRelevanceCapParam[]; |
| 342 static const char kHUPNewScoringVisitedCountHalfLifeTimeParam[]; | 357 static const char kHUPNewScoringVisitedCountHalfLifeTimeParam[]; |
| 343 static const char kHUPNewScoringVisitedCountScoreBucketsParam[]; | 358 static const char kHUPNewScoringVisitedCountScoreBucketsParam[]; |
| 359 static const char kHUPNewScoringVisitedCountUseDecayFactorParam[]; | |
| 344 | 360 |
| 345 // Parameter names used by the HQP experimental scoring experiments. | 361 // Parameter names used by the HQP experimental scoring experiments. |
| 346 static const char kHQPExperimentalScoringEnabledParam[]; | 362 static const char kHQPExperimentalScoringEnabledParam[]; |
| 347 static const char kHQPExperimentalScoringBucketsParam[]; | 363 static const char kHQPExperimentalScoringBucketsParam[]; |
| 348 static const char kHQPExperimentalScoringTopicalityThresholdParam[]; | 364 static const char kHQPExperimentalScoringTopicalityThresholdParam[]; |
| 349 | 365 |
| 350 // The amount of time to wait before sending a new suggest request after the | 366 // The amount of time to wait before sending a new suggest request after the |
| 351 // previous one unless overridden by a field trial parameter. | 367 // previous one unless overridden by a field trial parameter. |
| 352 // Non-const because some unittests modify this value. | 368 // Non-const because some unittests modify this value. |
| 353 static int kDefaultMinimumTimeBetweenSuggestQueriesMs; | 369 static int kDefaultMinimumTimeBetweenSuggestQueriesMs; |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 371 // prioritize different wildcard contexts, see the implementation. How to | 387 // prioritize different wildcard contexts, see the implementation. How to |
| 372 // interpret the value is left to the caller; this is rule-dependent. | 388 // interpret the value is left to the caller; this is rule-dependent. |
| 373 static std::string GetValueForRuleInContext( | 389 static std::string GetValueForRuleInContext( |
| 374 const std::string& rule, | 390 const std::string& rule, |
| 375 metrics::OmniboxEventProto::PageClassification page_classification); | 391 metrics::OmniboxEventProto::PageClassification page_classification); |
| 376 | 392 |
| 377 DISALLOW_IMPLICIT_CONSTRUCTORS(OmniboxFieldTrial); | 393 DISALLOW_IMPLICIT_CONSTRUCTORS(OmniboxFieldTrial); |
| 378 }; | 394 }; |
| 379 | 395 |
| 380 #endif // COMPONENTS_OMNIBOX_BROWSER_OMNIBOX_FIELD_TRIAL_H_ | 396 #endif // COMPONENTS_OMNIBOX_BROWSER_OMNIBOX_FIELD_TRIAL_H_ |
| OLD | NEW |