bktree 1.0.1

BK-tree datastructure
Documentation
  • Coverage
  • 84.62%
    11 out of 13 items documented1 out of 12 items with examples
  • Size
  • Source code size: 10.79 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 713.76 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 17s Average build duration of successful builds.
  • all releases: 17s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • IGI-111/bktree
    8 3 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • IGI-111

bktree

A crate implementing a Brukhard Keller tree datastructure which allows for fast querying of "close" matches on discrete distances.

Useful for spell checking based on edit distance and other typical applications.

use bktree::*;

let mut bk = BkTree::new(hamming_distance);
bk.insert_all(vec![0, 4, 5, 14, 15]);

let (words, dists): (Vec<i32>, Vec<isize>) = bk.find(13, 1).into_iter().unzip();
assert_eq!(words, [5, 15]);
assert_eq!(dists, [1, 1]);
use bktree::*;

let mut bk = BkTree::new(levenshtein_distance);
bk.insert_all(vec![
    "book", "books", "boo", "boon", "cook", "cake", "cape", "cart",
]);
let (words, dists): (Vec<&str>, Vec<isize>) = bk.find("bo", 2).into_iter().unzip();
assert_eq!(words, ["book", "boo", "boon"]);
assert_eq!(dists, [2, 1, 2]);