mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-23 10:37:41 +08:00
Merge pull request #227 from meilisearch/damerau-distance-cost-1
Make the levenshtein algorithm consider transpositions to cost 1
This commit is contained in:
commit
2d7db2a80f
@ -19,21 +19,21 @@ fn build_dfa_with_setting(query: &str, setting: PrefixSetting) -> DFA {
|
|||||||
|
|
||||||
match query.len() {
|
match query.len() {
|
||||||
0 ..= 4 => {
|
0 ..= 4 => {
|
||||||
let builder = LEVDIST0.get_or_init(|| LevBuilder::new(0, false));
|
let builder = LEVDIST0.get_or_init(|| LevBuilder::new(0, true));
|
||||||
match setting {
|
match setting {
|
||||||
Prefix => builder.build_prefix_dfa(query),
|
Prefix => builder.build_prefix_dfa(query),
|
||||||
NoPrefix => builder.build_dfa(query),
|
NoPrefix => builder.build_dfa(query),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
5 ..= 8 => {
|
5 ..= 8 => {
|
||||||
let builder = LEVDIST1.get_or_init(|| LevBuilder::new(1, false));
|
let builder = LEVDIST1.get_or_init(|| LevBuilder::new(1, true));
|
||||||
match setting {
|
match setting {
|
||||||
Prefix => builder.build_prefix_dfa(query),
|
Prefix => builder.build_prefix_dfa(query),
|
||||||
NoPrefix => builder.build_dfa(query),
|
NoPrefix => builder.build_dfa(query),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
let builder = LEVDIST2.get_or_init(|| LevBuilder::new(2, false));
|
let builder = LEVDIST2.get_or_init(|| LevBuilder::new(2, true));
|
||||||
match setting {
|
match setting {
|
||||||
Prefix => builder.build_prefix_dfa(query),
|
Prefix => builder.build_prefix_dfa(query),
|
||||||
NoPrefix => builder.build_dfa(query),
|
NoPrefix => builder.build_dfa(query),
|
||||||
|
Loading…
Reference in New Issue
Block a user