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 std::string ScoredHistoryMatch::hqp_relevance_buckets_str_ = | |
117 "0.0:400,1.5:600,5.0:900,10.5:1203,15.0:1300,20.0:1399"; | |
Peter Kasting
2015/08/27 00:50:45
Another cryptically-magic string.
Ashok vardhan
2015/08/27 19:09:27
Done.
| |
116 std::vector<ScoredHistoryMatch::ScoreMaxRelevance>* | 118 std::vector<ScoredHistoryMatch::ScoreMaxRelevance>* |
117 ScoredHistoryMatch::hqp_relevance_buckets_ = nullptr; | 119 ScoredHistoryMatch::hqp_relevance_buckets_ = nullptr; |
118 | 120 |
119 ScoredHistoryMatch::ScoredHistoryMatch() | 121 ScoredHistoryMatch::ScoredHistoryMatch() |
120 : ScoredHistoryMatch(history::URLRow(), | 122 : ScoredHistoryMatch(history::URLRow(), |
121 VisitInfoVector(), | 123 VisitInfoVector(), |
122 std::string(), | 124 std::string(), |
123 base::string16(), | 125 base::string16(), |
124 String16Vector(), | 126 String16Vector(), |
125 WordStarts(), | 127 WordStarts(), |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
533 return 0; | 535 return 0; |
534 topicality_score += raw_term_score_to_topicality_score[std::min( | 536 topicality_score += raw_term_score_to_topicality_score[std::min( |
535 term_score, kMaxRawTermScore - 1)]; | 537 term_score, kMaxRawTermScore - 1)]; |
536 } | 538 } |
537 // TODO(mpearson): If there are multiple terms, consider taking the | 539 // TODO(mpearson): If there are multiple terms, consider taking the |
538 // geometric mean of per-term scores rather than the arithmetic mean. | 540 // geometric mean of per-term scores rather than the arithmetic mean. |
539 | 541 |
540 const float final_topicality_score = topicality_score / num_terms; | 542 const float final_topicality_score = topicality_score / num_terms; |
541 | 543 |
542 // Demote the URL if the topicality score is less than threshold. | 544 // Demote the URL if the topicality score is less than threshold. |
543 if (hqp_experimental_scoring_enabled_ && | 545 if (final_topicality_score < topicality_threshold_) { |
544 (final_topicality_score < topicality_threshold_)) { | |
545 return 0.0; | 546 return 0.0; |
546 } | 547 } |
547 | 548 |
548 return final_topicality_score; | 549 return final_topicality_score; |
549 } | 550 } |
550 | 551 |
551 float ScoredHistoryMatch::GetRecencyScore(int last_visit_days_ago) const { | 552 float ScoredHistoryMatch::GetRecencyScore(int last_visit_days_ago) const { |
552 // Lookup the score in days_ago_to_recency_score, treating | 553 // Lookup the score in days_ago_to_recency_score, treating |
553 // everything older than what we've precomputed as the oldest thing | 554 // everything older than what we've precomputed as the oldest thing |
554 // we've precomputed. The std::max is to protect against corruption | 555 // 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 } | 639 } |
639 // It will reach this stage when the score is > highest bucket score. | 640 // It will reach this stage when the score is > highest bucket score. |
640 // Return the highest bucket score. | 641 // Return the highest bucket score. |
641 return hqp_relevance_buckets[i - 1].second; | 642 return hqp_relevance_buckets[i - 1].second; |
642 } | 643 } |
643 | 644 |
644 // static | 645 // static |
645 void ScoredHistoryMatch::InitHQPExperimentalParams() { | 646 void ScoredHistoryMatch::InitHQPExperimentalParams() { |
646 // These are default HQP relevance scoring buckets. | 647 // These are default HQP relevance scoring buckets. |
647 // See GetFinalRelevancyScore() for details. | 648 // See GetFinalRelevancyScore() for details. |
648 std::string hqp_relevance_buckets_str = "0.0:400,1.5:600,12.0:1300,20.0:1399"; | 649 std::string hqp_relevance_buckets_str = hqp_relevance_buckets_str_; |
649 | 650 |
650 // Fetch the experiment params if they are any. | 651 // Fetch the experiment params if they are any. |
651 hqp_experimental_scoring_enabled_ = | 652 hqp_experimental_scoring_enabled_ = |
652 OmniboxFieldTrial::HQPExperimentalScoringEnabled(); | 653 OmniboxFieldTrial::HQPExperimentalScoringEnabled(); |
653 | 654 |
654 if (hqp_experimental_scoring_enabled_) { | 655 if (hqp_experimental_scoring_enabled_) { |
655 // Add the topicality threshold from experiment params. | 656 // Add the topicality threshold from experiment params. |
656 float hqp_experimental_topicality_threhold = | 657 float hqp_experimental_topicality_threhold = |
657 OmniboxFieldTrial::HQPExperimentalTopicalityThreshold(); | 658 OmniboxFieldTrial::HQPExperimentalTopicalityThreshold(); |
658 topicality_threshold_ = hqp_experimental_topicality_threhold; | 659 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); | 691 base::StringToDouble(it->first, &bucket.first); |
691 DCHECK(is_valid_intermediate_score); | 692 DCHECK(is_valid_intermediate_score); |
692 bool is_valid_hqp_score = base::StringToInt(it->second, &bucket.second); | 693 bool is_valid_hqp_score = base::StringToInt(it->second, &bucket.second); |
693 DCHECK(is_valid_hqp_score); | 694 DCHECK(is_valid_hqp_score); |
694 hqp_buckets->push_back(bucket); | 695 hqp_buckets->push_back(bucket); |
695 } | 696 } |
696 return true; | 697 return true; |
697 } | 698 } |
698 return false; | 699 return false; |
699 } | 700 } |
OLD | NEW |