Improve HQP Title Scoring

I was not satisfied with how difficult it was to get reasonable scores for quite long page titles even when multiple words contained in the title were typed so I added a limit on how much of the title (and URL) string was required in order to have a decent match.

BUG=None
TITLE=Ran all unit tests.
Review URL: http://codereview.chromium.org/7040009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86192 0039d316-1c4b-4281-b951-d872f2087c98
parent a9259a58
...@@ -748,8 +748,7 @@ ScoredHistoryMatch InMemoryURLIndex::ScoredMatchForURL( ...@@ -748,8 +748,7 @@ ScoredHistoryMatch InMemoryURLIndex::ScoredMatchForURL(
match.url_matches.size() / terms.size(); match.url_matches.size() / terms.size();
int title_score = int title_score =
ScoreComponentForMatches(match.title_matches, title.size()) * ScoreComponentForMatches(match.title_matches, title.size()) *
static_cast<int>(match.title_matches.size()) / match.title_matches.size() / terms.size();
static_cast<int>(terms.size());
// Arbitrarily pick the best. // Arbitrarily pick the best.
// TODO(mrossetti): It might make sense that a term which appears in both the // TODO(mrossetti): It might make sense that a term which appears in both the
// URL and the Title should boost the score a bit. // URL and the Title should boost the score a bit.
...@@ -828,8 +827,12 @@ int InMemoryURLIndex::ScoreComponentForMatches(const TermMatches& matches, ...@@ -828,8 +827,12 @@ int InMemoryURLIndex::ScoreComponentForMatches(const TermMatches& matches,
// that was matched. // that was matched.
size_t term_length_total = std::accumulate(matches.begin(), matches.end(), size_t term_length_total = std::accumulate(matches.begin(), matches.end(),
0, AccumulateMatchLength); 0, AccumulateMatchLength);
const size_t kMaxSignificantLength = 50;
size_t max_significant_length =
std::min(max_length, std::max(term_length_total, kMaxSignificantLength));
const int kCompleteMaxValue = 500; const int kCompleteMaxValue = 500;
int complete_value = term_length_total * kCompleteMaxValue / max_length; int complete_value =
term_length_total * kCompleteMaxValue / max_significant_length;
int raw_score = order_value + start_value + complete_value; int raw_score = order_value + start_value + complete_value;
const int kTermScoreLevel[] = { 1000, 650, 500, 200 }; const int kTermScoreLevel[] = { 1000, 650, 500, 200 };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment