added least common sequence and levenshtein with no substitution
All checks were successful
CI / build (push) Successful in 9s

This commit is contained in:
2025-07-31 14:35:30 +08:00
parent 1ac5c8fcdf
commit d14c907bf8
10 changed files with 467090 additions and 40 deletions

View File

@@ -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);