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..dec472f0a77a4e19b99efadbcb949639d23b66b3 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(const size_t num_matching_pages) const; |
Peter Kasting
2016/12/06 05:19:30
I'd avoid declaring the parameter here const.
Mark P
2016/12/08 00:21:31
Done.
|
+ |
+ // 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_| |
@@ -171,6 +181,11 @@ struct ScoredHistoryMatch : public history::HistoryMatch { |
// sum of visit scores instead of the weighted average. |
static bool frequency_uses_sum_; |
+ // A mapping from the number of matching pages to their associated document |
+ // specificity scores. See omnibox_field_trial.h for more details. |
+ static OmniboxFieldTrial::NumMatchesScores* |
+ num_matches_to_document_specificity_score_; |
+ |
// The maximum number of recent visits to examine in GetFrequency(). |
static size_t max_visits_to_score_; |