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 #ifndef CHROME_BROWSER_HISTORY_SCORED_HISTORY_MATCH_H_ | 5 #ifndef CHROME_BROWSER_HISTORY_SCORED_HISTORY_MATCH_H_ |
6 #define CHROME_BROWSER_HISTORY_SCORED_HISTORY_MATCH_H_ | 6 #define CHROME_BROWSER_HISTORY_SCORED_HISTORY_MATCH_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 // with url_info to make tie-breaking a bit smarter. | 56 // with url_info to make tie-breaking a bit smarter. |
57 static bool MatchScoreGreater(const ScoredHistoryMatch& m1, | 57 static bool MatchScoreGreater(const ScoredHistoryMatch& m1, |
58 const ScoredHistoryMatch& m2); | 58 const ScoredHistoryMatch& m2); |
59 | 59 |
60 // Accessors: | 60 // Accessors: |
61 int raw_score() const { return raw_score_; } | 61 int raw_score() const { return raw_score_; } |
62 const TermMatches& url_matches() const { return url_matches_; } | 62 const TermMatches& url_matches() const { return url_matches_; } |
63 const TermMatches& title_matches() const { return title_matches_; } | 63 const TermMatches& title_matches() const { return title_matches_; } |
64 bool can_inline() const { return can_inline_; } | 64 bool can_inline() const { return can_inline_; } |
65 | 65 |
66 // Returns |term_matches| after removing all matches that are not at a | |
Mark P
2013/11/22 02:26:32
This is a simple move of this function from privat
| |
67 // word break that starts after position |start_pos|. If |start_pos| is | |
68 // string::npos, does no filtering and simply returns |term_matches|. | |
69 static TermMatches FilterTermMatchesByWordStarts( | |
70 const TermMatches& term_matches, | |
71 const WordStarts& word_starts, | |
72 const size_t start_pos); | |
73 | |
66 private: | 74 private: |
67 friend class ScoredHistoryMatchTest; | 75 friend class ScoredHistoryMatchTest; |
68 | 76 |
69 // The number of days of recency scores to precompute. | 77 // The number of days of recency scores to precompute. |
70 static const int kDaysToPrecomputeRecencyScoresFor; | 78 static const int kDaysToPrecomputeRecencyScoresFor; |
71 | 79 |
72 // The number of raw term score buckets use; raw term scores | 80 // The number of raw term score buckets use; raw term scores |
73 // greater this are capped at the score of the largest bucket. | 81 // greater this are capped at the score of the largest bucket. |
74 static const int kMaxRawTermScore; | 82 static const int kMaxRawTermScore; |
75 | 83 |
76 // Return a topicality score based on how many matches appear in the | 84 // Return a topicality score based on how many matches appear in the |
77 // url and the page's title and where they are (e.g., at word | 85 // url and the page's title and where they are (e.g., at word |
78 // boundaries). Revises |url_matches_| and |title_matches_| in the | 86 // boundaries). Revises |url_matches_| and |title_matches_| in the |
79 // process so they only reflect matches used for scoring. (For | 87 // process so they only reflect matches used for scoring. (For |
80 // instance, some mid-word matches are not given credit in scoring.) | 88 // instance, some mid-word matches are not given credit in scoring.) |
81 float GetTopicalityScore(const int num_terms, | 89 float GetTopicalityScore(const int num_terms, |
82 const string16& cleaned_up_url, | 90 const string16& cleaned_up_url, |
83 const RowWordStarts& word_starts); | 91 const RowWordStarts& word_starts); |
84 | 92 |
85 // Helper function for GetTopicalityScore(). | |
86 // Returns |term_matches| after removing all matches that are not at a | |
87 // word break that starts after position |start_pos|. If |start_pos| is | |
88 // string::npos, does no filtering and simply returns |term_matches|. | |
89 static TermMatches FilterTermMatchesByWordStarts( | |
90 const TermMatches& term_matches, | |
91 const WordStarts& word_starts, | |
92 const size_t start_pos); | |
93 | |
94 // Precalculates raw_term_score_to_topicality_score, used in | 93 // Precalculates raw_term_score_to_topicality_score, used in |
95 // GetTopicalityScore(). | 94 // GetTopicalityScore(). |
96 static void FillInTermScoreToTopicalityScoreArray(); | 95 static void FillInTermScoreToTopicalityScoreArray(); |
97 | 96 |
98 // Returns a recency score based on |last_visit_days_ago|, which is | 97 // Returns a recency score based on |last_visit_days_ago|, which is |
99 // how many days ago the page was last visited. | 98 // how many days ago the page was last visited. |
100 static float GetRecencyScore(int last_visit_days_ago); | 99 static float GetRecencyScore(int last_visit_days_ago); |
101 | 100 |
102 // Pre-calculates days_ago_to_recency_numerator_, used in | 101 // Pre-calculates days_ago_to_recency_numerator_, used in |
103 // GetRecencyScore(). | 102 // GetRecencyScore(). |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
172 // matches) because if a non-inlineable match comes first than all matches | 171 // matches) because if a non-inlineable match comes first than all matches |
173 // will get demoted later in HistoryQuickProvider to non-inlineable scores. | 172 // will get demoted later in HistoryQuickProvider to non-inlineable scores. |
174 // Set to -1 to indicate no maximum score. | 173 // Set to -1 to indicate no maximum score. |
175 static int max_assigned_score_for_non_inlineable_matches_; | 174 static int max_assigned_score_for_non_inlineable_matches_; |
176 }; | 175 }; |
177 typedef std::vector<ScoredHistoryMatch> ScoredHistoryMatches; | 176 typedef std::vector<ScoredHistoryMatch> ScoredHistoryMatches; |
178 | 177 |
179 } // namespace history | 178 } // namespace history |
180 | 179 |
181 #endif // CHROME_BROWSER_HISTORY_SCORED_HISTORY_MATCH_H_ | 180 #endif // CHROME_BROWSER_HISTORY_SCORED_HISTORY_MATCH_H_ |
OLD | NEW |