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 #include "chrome/browser/history/scored_history_match.h" | 5 #include "chrome/browser/history/scored_history_match.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <iterator> | 9 #include <iterator> |
10 #include <numeric> | 10 #include <numeric> |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 if (term_score < 10) { | 385 if (term_score < 10) { |
386 // If the term scores less than 10 points (no full-credit hit, or | 386 // If the term scores less than 10 points (no full-credit hit, or |
387 // no combination of hits that score that well), then the topicality | 387 // no combination of hits that score that well), then the topicality |
388 // score is linear in the term score. | 388 // score is linear in the term score. |
389 topicality_score = 0.1 * term_score; | 389 topicality_score = 0.1 * term_score; |
390 } else { | 390 } else { |
391 // For term scores of at least ten points, pass them through a log | 391 // For term scores of at least ten points, pass them through a log |
392 // function so a score of 10 points gets a 1.0 (to meet up exactly | 392 // function so a score of 10 points gets a 1.0 (to meet up exactly |
393 // with the linear component) and increases logarithmically until | 393 // with the linear component) and increases logarithmically until |
394 // maxing out at 30 points, with computes to a score around 2.1. | 394 // maxing out at 30 points, with computes to a score around 2.1. |
395 topicality_score = (1.0 + 2.25 * log10(0.1 * | 395 topicality_score = (1.0 + 2.25 * log10(0.1 * term_score)); |
396 ((term_score <= 30) ? term_score : 30))); | |
397 } | 396 } |
398 raw_term_score_to_topicality_score[term_score] = topicality_score; | 397 raw_term_score_to_topicality_score[term_score] = topicality_score; |
399 } | 398 } |
400 } | 399 } |
401 | 400 |
402 // static | 401 // static |
403 float* ScoredHistoryMatch::days_ago_to_recency_score = NULL; | 402 float* ScoredHistoryMatch::days_ago_to_recency_score = NULL; |
404 | 403 |
405 // static | 404 // static |
406 float ScoredHistoryMatch::GetRecencyScore(int last_visit_days_ago) { | 405 float ScoredHistoryMatch::GetRecencyScore(int last_visit_days_ago) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 | 462 |
464 // static | 463 // static |
465 float ScoredHistoryMatch::GetPopularityScore(int typed_count, | 464 float ScoredHistoryMatch::GetPopularityScore(int typed_count, |
466 int visit_count) { | 465 int visit_count) { |
467 // The max()s are to guard against database corruption. | 466 // The max()s are to guard against database corruption. |
468 return (std::max(typed_count, 0) * 5.0 + std::max(visit_count, 0) * 3.0) / | 467 return (std::max(typed_count, 0) * 5.0 + std::max(visit_count, 0) * 3.0) / |
469 (5.0 + 3.0); | 468 (5.0 + 3.0); |
470 } | 469 } |
471 | 470 |
472 } // namespace history | 471 } // namespace history |
OLD | NEW |