Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/poyea/bk-tree
🌴 Header-only Burkhard-Keller tree (BK-Tree) library, with different metrics supported
https://github.com/poyea/bk-tree
bktree cpp cpp11 cpp14 cpp17 cpp20 data-structures string tree
Last synced: about 2 months ago
JSON representation
🌴 Header-only Burkhard-Keller tree (BK-Tree) library, with different metrics supported
- Host: GitHub
- URL: https://github.com/poyea/bk-tree
- Owner: poyea
- License: gpl-3.0
- Created: 2020-11-12T15:16:31.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-07-25T08:39:09.000Z (over 2 years ago)
- Last Synced: 2023-03-04T01:43:20.797Z (almost 2 years ago)
- Topics: bktree, cpp, cpp11, cpp14, cpp17, cpp20, data-structures, string, tree
- Language: C++
- Homepage: https://poyea.github.io/bk-tree/
- Size: 271 KB
- Stars: 8
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# bk-tree ![CMake](https://github.com/poyea/bk-tree/workflows/CMake/badge.svg)
Header-only [Burkhard-Keller tree](https://en.wikipedia.org/wiki/BK-tree) implementation in C++, with different metrics and a few useful interfaces supported. Documentation can be found [here](https://poyea.github.io/bk-tree/).
## An Example
```cpp
#include "bktree.hpp"
#includeint main() {
using metric_t = bk_tree::metrics::DamerauLevenshteinDistance;
using tree_t = bk_tree::BKTree;// 🌟 Initializer list syntax
tree_t temp{"tall", "tell", "teel"};
temp.insert("feel");tree_t tree(temp);
// 🌟 Loop like a STL container (e.g. range-based)
for (auto const &node : tree) {
std::cout << *node << ' '; // tall tell teel feel
std::cout << node->word() << ' '; // tall tell teel feel
}
std::cout << std::endl;std::cout << "Tree size: " << tree.size() << std::endl; // Tree size: 4
// 🌟 Find all possible results
auto result = tree.find("tale", 1);
for (auto &p : result) {
std::cout << p.first << " " << p.second << std::endl; // tall 1
}// 🌟 Erase a node by word
tree.erase("tall");
result = tree.find("tale", 1);
std::cout << result.size() << std::endl; // 0
}
```## Contributing
See [Contribution Guidelines](CONTRIBUTING.md).## License
This repository is licensed under The GNU General Public License v3.0. See also [LICENSE](LICENSE) for details.## References
Fred J. Damerau. 1964. A technique for computer detection and correction of spelling errors. Communications of the ACM 7, 3 (1964), 171–176. DOI:http://dx.doi.org/10.1145/363958.363994
Vladimir I. Levenshtein. 1966. Binary codes capable of correcting deletions, insertions, and reversals. Soviet physics doklady 10, 8 (1966), 845-848.
W.A. Burkhard and R.M. Keller. 1973. Some approaches to best-match file searching. Communications of the ACM 16, 4 (1973), 230–236. DOI:http://dx.doi.org/10.1145/362003.362025