Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/IGI-111/bktree
Rust implementation of a BK-tree datastructure
https://github.com/IGI-111/bktree
bk-tree bk-trees rust
Last synced: about 11 hours ago
JSON representation
Rust implementation of a BK-tree datastructure
- Host: GitHub
- URL: https://github.com/IGI-111/bktree
- Owner: IGI-111
- License: mit
- Created: 2021-05-18T19:52:14.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-03-23T14:44:25.000Z (over 1 year ago)
- Last Synced: 2024-11-01T05:02:25.993Z (9 days ago)
- Topics: bk-tree, bk-trees, rust
- Language: Rust
- Homepage:
- Size: 11.7 KB
- Stars: 7
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bktree
[![Crates.io](https://img.shields.io/crates/v/bktree.svg)](https://crates.io/crates/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.
```rust
use bktree::*;let mut bk = BkTree::new(hamming_distance);
bk.insert_all(vec![0, 4, 5, 14, 15]);let (words, dists): (Vec, Vec) = bk.find(13, 1).into_iter().unzip();
assert_eq!(words, [5, 15]);
assert_eq!(dists, [1, 1]);
``````rust
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) = bk.find("bo", 2).into_iter().unzip();
assert_eq!(words, ["book", "boo", "boon"]);
assert_eq!(dists, [2, 1, 2]);
```