Metadata-Version: 2.4
Name: fastbktree
Version: 0.1.1
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Text Processing :: General
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Summary: A Rust BK-tree implementation for fast fuzzy string matching in Python
Keywords: bktree,levenshtein,fuzzy-matching,string-matching,rust
Author-email: Amrit Rau <amritrau@users.noreply.github.com>
License: MIT
Requires-Python: >=3.8
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM

# fastbktree :deciduous_tree:

A Rust implementation of [BK-trees](https://en.wikipedia.org/wiki/BK-tree) for fast fuzzy string matching in Python.


## Installation

```bash
uv add fastbktree
# pip install fastbktree
```

## Quickstart
```python
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.

```python
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.

```python
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.

```python
from fastbktree import levenshtein_distance

distance = levenshtein_distance("kitten", "sitting")  # 3
```


## License
MIT

