Count the number of char instead of counting bytes to assign the typo tolerance

This commit is contained in:
many 2021-09-28 12:10:43 +02:00
parent 1988416295
commit 8046ae4bd5
No known key found for this signature in database
GPG Key ID: 2CEF23B75189EACA

View File

@ -262,7 +262,7 @@ fn split_best_frequency(ctx: &impl Context, word: &str) -> heed::Result<Option<O
/// and the provided word length. /// and the provided word length.
fn typos(word: String, authorize_typos: bool) -> QueryKind { fn typos(word: String, authorize_typos: bool) -> QueryKind {
if authorize_typos { if authorize_typos {
match word.len() { match word.chars().count() {
0..=4 => QueryKind::exact(word), 0..=4 => QueryKind::exact(word),
5..=8 => QueryKind::tolerant(1, word), 5..=8 => QueryKind::tolerant(1, word),
_ => QueryKind::tolerant(2, word), _ => QueryKind::tolerant(2, word),