A Rust BK-tree implementation for fast fuzzy string matching in Python
Project description
fastbktree :deciduous_tree:
A Rust implementation of BK-trees for fast fuzzy string matching in Python.
Installation
uv add fastbktree
# pip install fastbktree
Quickstart
from fastbktree import BKTree
# Create a BK-tree from a list of strings
tree = BKTree(["hello", "help", "hell", "shell", "helper"])
results = tree.search("helo", max_distance=2)
Reference
BKTree(iterable)
Creates a new BK-tree from an iterable of strings.
tree = BKTree(["word1", "word2", "word3"])
tree.search(query: str, max_distance: int) -> List[Tuple[str, int]]
Searches for strings similar to query within max_distance Levenshtein distance.
Returns a list of (string, distance) tuples.
results = tree.search("query", max_distance=2)
# [('hello', 1), ('help', 1), ('shell', 2), ('hell', 1)]
levenshtein_distance(a: str, b: str) -> int
Pure Rust implementation of Levenshtein distance between two strings.
from fastbktree import levenshtein_distance
distance = levenshtein_distance("kitten", "sitting") # 3
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastbktree-0.1.1.tar.gz.
File metadata
- Download URL: fastbktree-0.1.1.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.8.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c088e117382c1f6897576fb11b2cba53f9ccab0e59ad22ef79a08e0b411259dd
|
|
| MD5 |
9784d984f169c4d18279915ab8b7a986
|
|
| BLAKE2b-256 |
867193bef8579334b20f9bfbe2d58d0220ca764267b5678bf12e25b1702878b1
|
File details
Details for the file fastbktree-0.1.1-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: fastbktree-0.1.1-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 233.0 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.8.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2397819729c85fa2eb6720ef824221e6c9cac98f58bbdf0de10fadabaec5c673
|
|
| MD5 |
42a0fbe7985a57ea34e2d24e1a45c345
|
|
| BLAKE2b-256 |
35b0eba046cd1af931b1e6d2b6182f6e5ebc4942ba970bc85d0914b41b9947e2
|