Skip to content

Commit

Permalink
Omnibox: HQP - Allow Changing Number of Words in the Title to Match
Browse files Browse the repository at this point in the history
Currently HistoryQuick provider has a fixed limit of considering 10
words in the title of a web page for matching.  This change makes
that limit controlled by a field trial.

BUG=291294

Review URL: https://codereview.chromium.org/1025833002

Cr-Commit-Position: refs/heads/master@{#321682}
  • Loading branch information
mpearson authored and Commit bot committed Mar 21, 2015
1 parent 3790c6c commit 6c5716b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
6 changes: 4 additions & 2 deletions chrome/browser/autocomplete/scored_history_match.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ int ScoredHistoryMatch::bookmark_value_ = 1;
bool ScoredHistoryMatch::fix_frequency_bugs_ = false;
bool ScoredHistoryMatch::allow_tld_matches_ = false;
bool ScoredHistoryMatch::allow_scheme_matches_ = false;
size_t ScoredHistoryMatch::num_title_words_to_allow_ = 10u;
bool ScoredHistoryMatch::hqp_experimental_scoring_enabled_ = false;
float ScoredHistoryMatch::topicality_threshold_ = -1;
std::vector<ScoredHistoryMatch::ScoreMaxRelevance>*
Expand Down Expand Up @@ -408,6 +409,7 @@ void ScoredHistoryMatch::Init() {
fix_frequency_bugs_ = OmniboxFieldTrial::HQPFixFrequencyScoringBugs();
allow_tld_matches_ = OmniboxFieldTrial::HQPAllowMatchInTLDValue();
allow_scheme_matches_ = OmniboxFieldTrial::HQPAllowMatchInSchemeValue();
num_title_words_to_allow_ = OmniboxFieldTrial::HQPNumTitleWordsToAllow();

InitRawTermScoreToTopicalityScoreArray();
InitDaysAgoToRecencyScoreArray();
Expand Down Expand Up @@ -505,7 +507,7 @@ float ScoredHistoryMatch::GetTopicalityScore(
// Now do the analogous loop over all matches in the title.
next_word_starts = word_starts.title_word_starts_.begin();
end_word_starts = word_starts.title_word_starts_.end();
int word_num = 0;
size_t word_num = 0;
title_matches = FilterTermMatchesByWordStarts(
title_matches, terms_to_word_starts_offsets,
word_starts.title_word_starts_, 0, std::string::npos);
Expand All @@ -519,7 +521,7 @@ float ScoredHistoryMatch::GetTopicalityScore(
++next_word_starts;
++word_num;
}
if (word_num >= 10)
if (word_num >= num_title_words_to_allow_)
break; // only count the first ten words
DCHECK(next_word_starts != end_word_starts);
DCHECK_EQ(*next_word_starts, title_match.offset + term_offset)
Expand Down
4 changes: 4 additions & 0 deletions chrome/browser/autocomplete/scored_history_match.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ struct ScoredHistoryMatch : public history::HistoryMatch {
// If true, we allow input terms to match in the scheme (e.g., "http://").
static bool allow_scheme_matches_;

// The number of title words examined when computing topicality scores.
// Words beyond this number are ignored.
static size_t num_title_words_to_allow_;

// True, if hqp experimental scoring is enabled.
static bool hqp_experimental_scoring_enabled_;

Expand Down
13 changes: 13 additions & 0 deletions components/omnibox/omnibox_field_trial.cc
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,18 @@ bool OmniboxFieldTrial::HQPFixFrequencyScoringBugs() {
kHQPFixFrequencyScoringBugsRule) == "true";
}

size_t OmniboxFieldTrial::HQPNumTitleWordsToAllow() {
// The value of the rule is a string that encodes an integer (actually
// size_t) containing the number of words.
size_t num_title_words;
if (!base::StringToSizeT(
variations::GetVariationParamValue(kBundledExperimentFieldTrialName,
kHQPNumTitleWordsRule),
&num_title_words))
return 10;
return num_title_words;
}

const char OmniboxFieldTrial::kBundledExperimentFieldTrialName[] =
"OmniboxBundledExperimentV1";
const char OmniboxFieldTrial::kDisableProvidersRule[] = "DisableProviders";
Expand All @@ -404,6 +416,7 @@ const char OmniboxFieldTrial::kSuggestPollingDelayMsRule[] =
"SuggestPollingDelayMs";
const char OmniboxFieldTrial::kHQPFixFrequencyScoringBugsRule[] =
"HQPFixFrequencyScoringBugs";
const char OmniboxFieldTrial::kHQPNumTitleWordsRule[] = "HQPNumTitleWords";

const char OmniboxFieldTrial::kHUPNewScoringEnabledParam[] =
"HUPExperimentalScoringEnabled";
Expand Down
10 changes: 10 additions & 0 deletions components/omnibox/omnibox_field_trial.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,15 @@ class OmniboxFieldTrial {
// function.
static bool HQPFixFrequencyScoringBugs();

// ---------------------------------------------------------
// For the HQPNumTitleWords experiment that's part of the
// bundled omnibox field trial.

// Returns the number of title words that are allowed to contribute
// to the topicality score. Words later in the title are ignored.
// Returns 10 as a default if the experiment isn't active.
static size_t HQPNumTitleWordsToAllow();

// ---------------------------------------------------------
// Exposed publicly for the sake of unittests.
static const char kBundledExperimentFieldTrialName[];
Expand All @@ -319,6 +328,7 @@ class OmniboxFieldTrial {
static const char kMeasureSuggestPollingDelayFromLastKeystrokeRule[];
static const char kSuggestPollingDelayMsRule[];
static const char kHQPFixFrequencyScoringBugsRule[];
static const char kHQPNumTitleWordsRule[];

// Parameter names used by the HUP new scoring experiments.
static const char kHUPNewScoringEnabledParam[];
Expand Down

0 comments on commit 6c5716b

Please sign in to comment.