added least common sequence and levenshtein with no substitution
All checks were successful
CI / build (push) Successful in 9s
All checks were successful
CI / build (push) Successful in 9s
This commit is contained in:
@@ -7,16 +7,6 @@ use levtree::LevTrie;
|
||||
use std::io::BufRead;
|
||||
use std::io::BufReader;
|
||||
|
||||
trait IntoCharSlice {
|
||||
fn into_char_slice(&self) -> Vec<char>;
|
||||
}
|
||||
|
||||
impl IntoCharSlice for str {
|
||||
fn into_char_slice(&self) -> Vec<char> {
|
||||
self.chars().into_iter().collect::<Vec<_>>()
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let bytes = include_bytes!("cracklib-small");
|
||||
let reader = BufReader::new(&bytes[..]);
|
||||
@@ -28,26 +18,29 @@ fn main() {
|
||||
trie.add(word.chars());
|
||||
});
|
||||
|
||||
let keys = [
|
||||
let keys: Vec<Vec<char>> = [
|
||||
"camel",
|
||||
"coriolis",
|
||||
"mattel",
|
||||
"cruzer",
|
||||
"cpoper",
|
||||
"roublesoot",
|
||||
];
|
||||
]
|
||||
.into_iter()
|
||||
.map(|it| it.chars().collect())
|
||||
.collect();
|
||||
|
||||
for _ in 0..50 {
|
||||
for key in keys {
|
||||
let word = &key.into_char_slice()[..];
|
||||
for key in &keys {
|
||||
let word = &key;
|
||||
trie.fuzzy_search::<DamerauLevenshteinDistanceCalculator>(word, 6);
|
||||
}
|
||||
}
|
||||
|
||||
for key in keys {
|
||||
let word = &key.into_char_slice()[..];
|
||||
let word = &key;
|
||||
let results = trie.fuzzy_search::<DamerauLevenshteinDistanceCalculator>(word, 6);
|
||||
println!("needle: {}", key);
|
||||
println!("needle: {}", key.iter().collect::<String>());
|
||||
for result in results {
|
||||
let word: String = trie.lineal_descendant(result.word).into_iter().collect();
|
||||
println!("distance: {}, wordkey: {}", result.distance, word);
|
||||
|
Reference in New Issue
Block a user