Index: components/omnibox/browser/scored_history_match.h |
diff --git a/components/omnibox/browser/scored_history_match.h b/components/omnibox/browser/scored_history_match.h |
index dacd31cec537b30c501c35a6410bca55cbe20d96..dd6c36a9f1ef9dd877e438075da2822adb5561b2 100644 |
--- a/components/omnibox/browser/scored_history_match.h |
+++ b/components/omnibox/browser/scored_history_match.h |
@@ -16,6 +16,7 @@ |
#include "components/history/core/browser/history_match.h" |
#include "components/history/core/browser/history_types.h" |
#include "components/omnibox/browser/in_memory_url_index_types.h" |
+#include "components/omnibox/browser/omnibox_field_trial.h" |
class ScoredHistoryMatchTest; |
@@ -43,9 +44,11 @@ struct ScoredHistoryMatch : public history::HistoryMatch { |
// These offsets (".net" should have an offset of 1) come from |
// |terms_to_word_starts_offsets|. |is_url_bookmarked| indicates whether the |
// match's URL is referenced by any bookmarks, which can also affect the raw |
- // score. The raw score allows the matches to be ordered and can be used to |
- // influence the final score calculated by the client of this index. If the |
- // row does not qualify the raw score will be 0. |
+ // score. |num_matching_pages| indicates how many URLs in the eligible URL |
+ // database match the user's input; it can also affect the raw score. The raw |
+ // score allows the matches to be ordered and can be used to influence the |
+ // final score calculated by the client of this index. If the row does not |
+ // qualify the raw score will be 0. |
ScoredHistoryMatch(const history::URLRow& row, |
const VisitInfoVector& visits, |
const base::string16& lower_string, |
@@ -53,6 +56,7 @@ struct ScoredHistoryMatch : public history::HistoryMatch { |
const WordStarts& terms_to_word_starts_offsets, |
const RowWordStarts& word_starts, |
bool is_url_bookmarked, |
+ size_t num_matching_pages, |
base::Time now); |
~ScoredHistoryMatch(); |
@@ -93,6 +97,7 @@ struct ScoredHistoryMatch : public history::HistoryMatch { |
private: |
friend class ScoredHistoryMatchTest; |
+ FRIEND_TEST_ALL_PREFIXES(ScoredHistoryMatchTest, GetDocumentSpecificityScore); |
FRIEND_TEST_ALL_PREFIXES(ScoredHistoryMatchTest, GetFinalRelevancyScore); |
FRIEND_TEST_ALL_PREFIXES(ScoredHistoryMatchTest, GetFrequency); |
FRIEND_TEST_ALL_PREFIXES(ScoredHistoryMatchTest, GetHQPBucketsFromString); |
@@ -128,13 +133,18 @@ struct ScoredHistoryMatch : public history::HistoryMatch { |
const bool bookmarked, |
const VisitInfoVector& visits) const; |
- // Combines the two component scores into a final score that's |
+ // Returns a document specificity score based on how many pages matched the |
+ // user's input. |
+ float GetDocumentSpecificityScore(size_t num_matching_pages) const; |
+ |
+ // Combines the three component scores into a final score that's |
// an appropriate value to use as a relevancy score. Scoring buckets are |
// specified through |hqp_relevance_buckets|. Please see the function |
// implementation for more details. |
static float GetFinalRelevancyScore( |
float topicality_score, |
float frequency_score, |
+ float specificity_score, |
const std::vector<ScoreMaxRelevance>& hqp_relevance_buckets); |
// Initializes the HQP experimental params: |hqp_relevance_buckets_| |
@@ -200,6 +210,12 @@ struct ScoredHistoryMatch : public history::HistoryMatch { |
// to the final relevance scoring. Please see GetFinalRelevancyScore() |
// for more details and scoring method. |
static std::vector<ScoreMaxRelevance>* hqp_relevance_buckets_; |
+ |
+ // Used for testing. If this point is not null, it overrides the static |
Peter Kasting
2016/12/10 02:22:26
Nit: pointer
Mark P
2016/12/11 05:11:37
Done.
|
+ // local variable |default_num_matches_to_document_specificity_score| |
+ // declared in GetDocumentSpecificityScore(). |
+ static OmniboxFieldTrial::NumMatchesScores* |
+ num_matches_to_document_specificity_score_override_; |
}; |
typedef std::vector<ScoredHistoryMatch> ScoredHistoryMatches; |