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 #include "components/omnibox/browser/scored_history_match.h" | 5 #include "components/omnibox/browser/scored_history_match.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 | 105 |
| 106 // static | 106 // static |
| 107 const size_t ScoredHistoryMatch::kMaxVisitsToScore = 10; | 107 const size_t ScoredHistoryMatch::kMaxVisitsToScore = 10; |
| 108 bool ScoredHistoryMatch::also_do_hup_like_scoring_ = false; | 108 bool ScoredHistoryMatch::also_do_hup_like_scoring_ = false; |
| 109 int ScoredHistoryMatch::bookmark_value_ = 1; | 109 int ScoredHistoryMatch::bookmark_value_ = 1; |
| 110 bool ScoredHistoryMatch::fix_frequency_bugs_ = false; | 110 bool ScoredHistoryMatch::fix_frequency_bugs_ = false; |
| 111 bool ScoredHistoryMatch::allow_tld_matches_ = false; | 111 bool ScoredHistoryMatch::allow_tld_matches_ = false; |
| 112 bool ScoredHistoryMatch::allow_scheme_matches_ = false; | 112 bool ScoredHistoryMatch::allow_scheme_matches_ = false; |
| 113 size_t ScoredHistoryMatch::num_title_words_to_allow_ = 10u; | 113 size_t ScoredHistoryMatch::num_title_words_to_allow_ = 10u; |
| 114 bool ScoredHistoryMatch::hqp_experimental_scoring_enabled_ = false; | 114 bool ScoredHistoryMatch::hqp_experimental_scoring_enabled_ = false; |
| 115 float ScoredHistoryMatch::topicality_threshold_ = -1; | 115 float ScoredHistoryMatch::topicality_threshold_ = 0.8; |
| 116 // Default HQP relevance buckets. URLs with relevance score > 20.0 | |
| 117 // are capped at 1399, score > 15 capped at 1300 etc. See | |
| 118 // GetFinalRelevancyScore() for more details. | |
|
Peter Kasting
2015/08/27 19:21:40
Again, I'm not so much interested in a comment res
Ashok vardhan
2015/08/27 19:51:38
Done.
| |
| 119 char ScoredHistoryMatch::hqp_relevance_buckets_str_[] = | |
| 120 "0.0:400,1.5:600,5.0:900,10.5:1203,15.0:1300,20.0:1399"; | |
| 116 std::vector<ScoredHistoryMatch::ScoreMaxRelevance>* | 121 std::vector<ScoredHistoryMatch::ScoreMaxRelevance>* |
| 117 ScoredHistoryMatch::hqp_relevance_buckets_ = nullptr; | 122 ScoredHistoryMatch::hqp_relevance_buckets_ = nullptr; |
| 118 | 123 |
| 119 ScoredHistoryMatch::ScoredHistoryMatch() | 124 ScoredHistoryMatch::ScoredHistoryMatch() |
| 120 : ScoredHistoryMatch(history::URLRow(), | 125 : ScoredHistoryMatch(history::URLRow(), |
| 121 VisitInfoVector(), | 126 VisitInfoVector(), |
| 122 std::string(), | 127 std::string(), |
| 123 base::string16(), | 128 base::string16(), |
| 124 String16Vector(), | 129 String16Vector(), |
| 125 WordStarts(), | 130 WordStarts(), |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 533 return 0; | 538 return 0; |
| 534 topicality_score += raw_term_score_to_topicality_score[std::min( | 539 topicality_score += raw_term_score_to_topicality_score[std::min( |
| 535 term_score, kMaxRawTermScore - 1)]; | 540 term_score, kMaxRawTermScore - 1)]; |
| 536 } | 541 } |
| 537 // TODO(mpearson): If there are multiple terms, consider taking the | 542 // TODO(mpearson): If there are multiple terms, consider taking the |
| 538 // geometric mean of per-term scores rather than the arithmetic mean. | 543 // geometric mean of per-term scores rather than the arithmetic mean. |
| 539 | 544 |
| 540 const float final_topicality_score = topicality_score / num_terms; | 545 const float final_topicality_score = topicality_score / num_terms; |
| 541 | 546 |
| 542 // Demote the URL if the topicality score is less than threshold. | 547 // Demote the URL if the topicality score is less than threshold. |
| 543 if (hqp_experimental_scoring_enabled_ && | 548 if (final_topicality_score < topicality_threshold_) { |
| 544 (final_topicality_score < topicality_threshold_)) { | |
| 545 return 0.0; | 549 return 0.0; |
| 546 } | 550 } |
| 547 | 551 |
| 548 return final_topicality_score; | 552 return final_topicality_score; |
| 549 } | 553 } |
| 550 | 554 |
| 551 float ScoredHistoryMatch::GetRecencyScore(int last_visit_days_ago) const { | 555 float ScoredHistoryMatch::GetRecencyScore(int last_visit_days_ago) const { |
| 552 // Lookup the score in days_ago_to_recency_score, treating | 556 // Lookup the score in days_ago_to_recency_score, treating |
| 553 // everything older than what we've precomputed as the oldest thing | 557 // everything older than what we've precomputed as the oldest thing |
| 554 // we've precomputed. The std::max is to protect against corruption | 558 // we've precomputed. The std::max is to protect against corruption |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 638 } | 642 } |
| 639 // It will reach this stage when the score is > highest bucket score. | 643 // It will reach this stage when the score is > highest bucket score. |
| 640 // Return the highest bucket score. | 644 // Return the highest bucket score. |
| 641 return hqp_relevance_buckets[i - 1].second; | 645 return hqp_relevance_buckets[i - 1].second; |
| 642 } | 646 } |
| 643 | 647 |
| 644 // static | 648 // static |
| 645 void ScoredHistoryMatch::InitHQPExperimentalParams() { | 649 void ScoredHistoryMatch::InitHQPExperimentalParams() { |
| 646 // These are default HQP relevance scoring buckets. | 650 // These are default HQP relevance scoring buckets. |
| 647 // See GetFinalRelevancyScore() for details. | 651 // See GetFinalRelevancyScore() for details. |
| 648 std::string hqp_relevance_buckets_str = "0.0:400,1.5:600,12.0:1300,20.0:1399"; | 652 std::string hqp_relevance_buckets_str = std::string( |
| 653 hqp_relevance_buckets_str_); | |
| 649 | 654 |
| 650 // Fetch the experiment params if they are any. | 655 // Fetch the experiment params if they are any. |
| 651 hqp_experimental_scoring_enabled_ = | 656 hqp_experimental_scoring_enabled_ = |
| 652 OmniboxFieldTrial::HQPExperimentalScoringEnabled(); | 657 OmniboxFieldTrial::HQPExperimentalScoringEnabled(); |
| 653 | 658 |
| 654 if (hqp_experimental_scoring_enabled_) { | 659 if (hqp_experimental_scoring_enabled_) { |
| 655 // Add the topicality threshold from experiment params. | 660 // Add the topicality threshold from experiment params. |
| 656 float hqp_experimental_topicality_threhold = | 661 float hqp_experimental_topicality_threhold = |
| 657 OmniboxFieldTrial::HQPExperimentalTopicalityThreshold(); | 662 OmniboxFieldTrial::HQPExperimentalTopicalityThreshold(); |
| 658 topicality_threshold_ = hqp_experimental_topicality_threhold; | 663 topicality_threshold_ = hqp_experimental_topicality_threhold; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 690 base::StringToDouble(it->first, &bucket.first); | 695 base::StringToDouble(it->first, &bucket.first); |
| 691 DCHECK(is_valid_intermediate_score); | 696 DCHECK(is_valid_intermediate_score); |
| 692 bool is_valid_hqp_score = base::StringToInt(it->second, &bucket.second); | 697 bool is_valid_hqp_score = base::StringToInt(it->second, &bucket.second); |
| 693 DCHECK(is_valid_hqp_score); | 698 DCHECK(is_valid_hqp_score); |
| 694 hqp_buckets->push_back(bucket); | 699 hqp_buckets->push_back(bucket); |
| 695 } | 700 } |
| 696 return true; | 701 return true; |
| 697 } | 702 } |
| 698 return false; | 703 return false; |
| 699 } | 704 } |
| OLD | NEW |