Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(698)

Unified Diff: chrome/browser/history/scored_history_match_unittest.cc

Issue 905023003: Adding knobs on HQP provider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing bart comments. PTAL. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/history/scored_history_match_unittest.cc
diff --git a/chrome/browser/history/scored_history_match_unittest.cc b/chrome/browser/history/scored_history_match_unittest.cc
index 4989966eda6eb271a3c5cc935a26e39dae626d98..ef1f9bb44c1cf603f5274367ba389f26a2e5e5da 100644
--- a/chrome/browser/history/scored_history_match_unittest.cc
+++ b/chrome/browser/history/scored_history_match_unittest.cc
@@ -344,6 +344,57 @@ TEST_F(ScoredHistoryMatchTest, GetTopicalityScoreTrailingSlash) {
EXPECT_EQ(hostname_no_slash, hostname);
}
+// This function tests the final-relevancy score.
+TEST_F(ScoredHistoryMatchTest, GetFinalRelevancyScore) {
+ ScoredHistoryMatch scored_match;
+ // Checking the scores at maximum range.
+ float topicality_score = 1.0;
+ float frequency_score = 15.0;
+ // hqp_relevance_buckets = "1.5:600,12.0:1300,20.0:1399";
+ std::vector<ScoredHistoryMatch::ScoreMaxRelevance> hqp_buckets;
+ hqp_buckets.push_back(std::make_pair(1.5, 600));
+ hqp_buckets.push_back(std::make_pair(12.0, 1300));
+ hqp_buckets.push_back(std::make_pair(20.0, 1399));
+ EXPECT_EQ(1337,
+ scored_match.GetFinalRelevancyScore(topicality_score,
+ frequency_score,
+ hqp_buckets));
+ // Checking the scores at border line.
+ topicality_score = 0.5;
+ frequency_score = 10.0;
+ // hqp_relevance_buckets = "1:200,4:500,5:900,10:1000";
+ hqp_buckets.clear();
+ hqp_buckets.push_back(std::make_pair(1, 200));
+ hqp_buckets.push_back(std::make_pair(4, 500));
+ hqp_buckets.push_back(std::make_pair(5, 900));
+ hqp_buckets.push_back(std::make_pair(10, 1000));
+ EXPECT_EQ(900,
+ scored_match.GetFinalRelevancyScore(topicality_score,
+ frequency_score,
+ hqp_buckets));
+ // Checking the score of intermediate.
+ topicality_score = 0.5;
+ frequency_score = 10.0;
+ // hqp_relevance_buckets = "1:200,4:500,8:900,10:1000";
+ hqp_buckets.clear();
+ hqp_buckets.push_back(std::make_pair(1, 200));
+ hqp_buckets.push_back(std::make_pair(4, 500));
+ hqp_buckets.push_back(std::make_pair(8, 900));
+ hqp_buckets.push_back(std::make_pair(10, 1000));
+ EXPECT_EQ(600, // 500 + (((900 - 500)/(8 -4)) * 1) = 600.
+ scored_match.GetFinalRelevancyScore(topicality_score,
+ frequency_score,
+ hqp_buckets));
+ // Never give the score greater than maximum specified.
+ topicality_score = 0.5;
+ frequency_score = 22.0;
+ // hqp_relevance_buckets unchanged.
+ EXPECT_EQ(1000,
+ scored_match.GetFinalRelevancyScore(topicality_score,
+ frequency_score,
+ hqp_buckets));
+}
+
// This function only tests scoring of single terms that match exactly
// once somewhere in the URL or title.
TEST_F(ScoredHistoryMatchTest, GetTopicalityScore) {

Powered by Google App Engine
This is Rietveld 408576698