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; ...@@ -60,9 +60,9 @@ constexpr double kCrostiniTerminalRelevanceThreshold = 0.8;
// Parameters for FuzzyTokenizedStringMatch. // Parameters for FuzzyTokenizedStringMatch.
constexpr bool kUsePrefixOnly = false; constexpr bool kUsePrefixOnly = false;
constexpr bool kUseWeightedRatio = true; constexpr bool kUseWeightedRatio = false;
constexpr bool kUseEditDistance = false; constexpr bool kUseEditDistance = false;
constexpr double kRelevanceThreshold = 0.3; constexpr double kRelevanceThreshold = 0.32;
constexpr double kPartialMatchPenaltyRate = 0.9; constexpr double kPartialMatchPenaltyRate = 0.9;
// Adds |app_result| to |results| only in case no duplicate apps were already // Adds |app_result| to |results| only in case no duplicate apps were already
......
...@@ -797,7 +797,7 @@ TEST_F(AppSearchProviderTest, FuzzyAppSearchTest) { ...@@ -797,7 +797,7 @@ TEST_F(AppSearchProviderTest, FuzzyAppSearchTest) {
feature_list.InitAndEnableFeature(app_list_features::kEnableFuzzyAppSearch); feature_list.InitAndEnableFeature(app_list_features::kEnableFuzzyAppSearch);
CreateSearch(); CreateSearch();
EXPECT_EQ("Packaged App 1,Packaged App 2", RunQuery("pa")); 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" || EXPECT_TRUE(result == "Packaged App 1,Packaged App 2" ||
result == "Packaged App 2,Packaged App 1"); result == "Packaged App 2,Packaged App 1");
EXPECT_EQ(kKeyboardShortcutHelperInternalName, RunQuery("Helper")); EXPECT_EQ(kKeyboardShortcutHelperInternalName, RunQuery("Helper"));
......
...@@ -319,20 +319,10 @@ bool FuzzyTokenizedStringMatch::IsRelevant(const TokenizedString& query, ...@@ -319,20 +319,10 @@ bool FuzzyTokenizedStringMatch::IsRelevant(const TokenizedString& query,
2; 2;
} else { } else {
// Use simple algorithm to calculate match ratio. // 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_ = relevance_ =
(std::max( (SequenceMatcher(base::i18n::ToLower(query_text),
SequenceMatcher(query_text, text_text, use_edit_distance).Ratio(), base::i18n::ToLower(text_text), use_edit_distance)
partial_match * partial_scale) + .Ratio() +
prefix_score) / prefix_score) /
2; 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