diff options
author | Canop <cano.petrole@gmail.com> | 2019-02-12 17:12:16 +0100 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2019-02-12 17:12:16 +0100 |
commit | 67990e9db0940941087113983fd82ca310f8cc77 (patch) | |
tree | 565eed6ad630b15ee1ccc785a08b4c4a88557c8a /src/fuzzy_patterns.rs | |
parent | ea80e9f6b15fd3e0bd653b1190253514b9b71899 (diff) |
fuzzy pattern: increase score of match starting after word separator
Diffstat (limited to 'src/fuzzy_patterns.rs')
-rw-r--r-- | src/fuzzy_patterns.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/fuzzy_patterns.rs b/src/fuzzy_patterns.rs index e2781b9..a5c5164 100644 --- a/src/fuzzy_patterns.rs +++ b/src/fuzzy_patterns.rs @@ -8,7 +8,8 @@ use std::fmt::{self, Write}; // weights used in match score computing const BONUS_MATCH: i32 = 50_000; const BONUS_EXACT: i32 = 1_000; -const BONUS_START: i32 = 0; // disabled +const BONUS_START: i32 = 20; +const BONUS_START_WORD: i32 = 5; const BONUS_CANDIDATE_LENGTH: i32 = -1; // per char const BONUS_LENGTH: i32 = -10; // per char of length of the match const BONUS_NB_HOLES: i32 = -30; // there's also a max on that number @@ -92,6 +93,11 @@ impl FuzzyPattern { if cand_chars.len() == self.lc_chars.len() { score += BONUS_EXACT; } + } else { + let previous = cand_chars[start_idx - 1]; + if previous == '_' || previous == ' ' || previous == '-' { + score += BONUS_START_WORD; + } } Some(Match { score, pos }) } |