Merge pull request #227 from meilisearch/damerau-distance-cost-1

Make the levenshtein algorithm consider transpositions to cost 1
This commit is contained in:
Clément Renault 2019-10-18 10:46:42 +02:00 committed by GitHub
commit 2d7db2a80f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,21 +19,21 @@ fn build_dfa_with_setting(query: &str, setting: PrefixSetting) -> DFA {
match query.len() {
0 ..= 4 => {
let builder = LEVDIST0.get_or_init(|| LevBuilder::new(0, false));
let builder = LEVDIST0.get_or_init(|| LevBuilder::new(0, true));
match setting {
Prefix => builder.build_prefix_dfa(query),
NoPrefix => builder.build_dfa(query),
}
},
5 ..= 8 => {
let builder = LEVDIST1.get_or_init(|| LevBuilder::new(1, false));
let builder = LEVDIST1.get_or_init(|| LevBuilder::new(1, true));
match setting {
Prefix => builder.build_prefix_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 {
Prefix => builder.build_prefix_dfa(query),
NoPrefix => builder.build_dfa(query),