Fix of #5202 - Fuzzy Search engine is too fuzzy

* changed evaluation coefficients inside fuzzy_match_recursive
 * don't add markers to the labels before it's used in fuzzy_match_recursive
 + follow-up 78a3d8b63e - added missed fix for one more line (use std::towlower instead of std::tolower for wchar_t) Problem was appearance on Cyrillic languages
This commit is contained in:
YuSanka 2021-01-26 21:32:44 +01:00
parent 5700f4396f
commit 67500f13b1
2 changed files with 16 additions and 13 deletions

View file

@ -113,7 +113,7 @@ namespace fts {
bool first_match = true;
while (*pattern != '\0' && *str != '\0') {
int num_matched = std::tolower(*pattern) == std::tolower(*str) ? 1 : 0;
int num_matched = std::towlower(*pattern) == std::towlower(*str) ? 1 : 0;
bool folded_match = false;
if (! num_matched) {
wchar_t tmp[4];
@ -168,11 +168,11 @@ namespace fts {
// Calculate score
if (matched) {
static constexpr int sequential_bonus = 15; // bonus for adjacent matches
static constexpr int separator_bonus = 30; // bonus if match occurs after a separator
static constexpr int separator_bonus = 10/*30*/; // bonus if match occurs after a separator
static constexpr int camel_bonus = 30; // bonus if match is uppercase and prev is lower
static constexpr int first_letter_bonus = 15; // bonus if the first letter is matched
static constexpr int leading_letter_penalty = -5; // penalty applied for every letter in str before the first match
static constexpr int leading_letter_penalty = -1/*-5*/; // penalty applied for every letter in str before the first match
static constexpr int max_leading_letter_penalty = -15; // maximum penalty for leading letters
static constexpr int unmatched_letter_penalty = -1; // penalty for every letter that doesn't matter