Commit 8b291630 authored by Thanh Nguyen's avatar Thanh Nguyen Committed by Commit Bot

[fuzzy-app-search] Fix fuzzy app search issue

Increase the relevance threshold and use simple fuzzy app search instead
of weighted ratio to filter unwanted search results.

Bug: 1065455
Change-Id: I1c59368eb8dd3a235b2fd723098ac42cffca3aee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2143096Reviewed-by: default avatarJia Meng <jiameng@chromium.org>
Commit-Queue: Thanh Nguyen <thanhdng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#757768}
parent 721c1d18
......@@ -60,9 +60,9 @@ constexpr double kCrostiniTerminalRelevanceThreshold = 0.8;
// Parameters for FuzzyTokenizedStringMatch.
constexpr bool kUsePrefixOnly = false;
constexpr bool kUseWeightedRatio = true;
constexpr bool kUseWeightedRatio = false;
constexpr bool kUseEditDistance = false;
constexpr double kRelevanceThreshold = 0.3;
constexpr double kRelevanceThreshold = 0.32;
constexpr double kPartialMatchPenaltyRate = 0.9;
// Adds |app_result| to |results| only in case no duplicate apps were already
......
......@@ -797,7 +797,7 @@ TEST_F(AppSearchProviderTest, FuzzyAppSearchTest) {
feature_list.InitAndEnableFeature(app_list_features::kEnableFuzzyAppSearch);
CreateSearch();
EXPECT_EQ("Packaged App 1,Packaged App 2", RunQuery("pa"));
std::string result = RunQuery("packahe");
std::string result = RunQuery("ackaged");
EXPECT_TRUE(result == "Packaged App 1,Packaged App 2" ||
result == "Packaged App 2,Packaged App 1");
EXPECT_EQ(kKeyboardShortcutHelperInternalName, RunQuery("Helper"));
......
......@@ -319,20 +319,10 @@ bool FuzzyTokenizedStringMatch::IsRelevant(const TokenizedString& query,
2;
} else {
// Use simple algorithm to calculate match ratio.
double partial_match = 0.0;
for (const auto& query_token : query.tokens()) {
for (const auto& text_token : text.tokens()) {
partial_match =
std::max(partial_match,
SequenceMatcher(query_token, text_token, use_edit_distance)
.Ratio());
}
}
const double partial_scale = 0.9;
relevance_ =
(std::max(
SequenceMatcher(query_text, text_text, use_edit_distance).Ratio(),
partial_match * partial_scale) +
(SequenceMatcher(base::i18n::ToLower(query_text),
base::i18n::ToLower(text_text), use_edit_distance)
.Ratio() +
prefix_score) /
2;
}
......
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