Python bindings for the Rust `fst` crate, providing sets and maps backed by finite state transducers.
Project description
tl;dr:
Work with larger-than-memory sets
Perform fuzzy search using Levenshtein automata
Installation
You will need:
Python >= 3.3, Python or PyPy >= 2.7 with development headers installed
Rust nightly (install via rustup)
Clone the repository. Installation with pip install git+... does not work currently
Run rustup override add nightly to add an override for rustup to use the nightly channel for the repository
Run python setup.py bdist_wheel to generate a wheel
Install the wheel with pip install dist/rust_fst-0.1-py3-none-any.whl
Status
The package exposes almost all functionality of the fst crate, except for:
Combining the results of slicing, search and search_re with set operations
Using raw transducers
Examples
from rust_fst import Map, Set
# Building a set in memory
keys = ["fa", "fo", "fob", "focus", "foo", "food", "foul"]
s = Set.from_iter(keys)
# Fuzzy searches on the set
matches = list(s.search(term="foo", max_dist=1))
assert matches == ["fo", "fob", "foo", "food"]
# Searching with a regular expression
matches = list(s.search_re(r'f\w{2}'))
assert matches == ["fob", "foo"]
# Store map on disk, requiring only constant memory for querying
items = [("bruce", 1), ("clarence", 2), ("stevie", 3)]
m = Map.from_iter(items, path="/tmp/map.fst")
# Find all items whose key is greater or equal (in lexicographical sense) to
# 'clarence'
matches = dict(m['clarence':])
assert matches == {'clarence': 2, 'stevie': 3}
Documentation
Head over to readthedocs.org for the API documentation.
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 Distributions
Hashes for rust_fst-0.1.2-py2.py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04c3bcd57ed20688d885e220c0e83df69b956c929b3e1c12ed8431effa3a1e52 |
|
MD5 | 472fd4fab195a7e2ea81c665014d74a7 |
|
BLAKE2b-256 | c09da116a1eb984c4798d8386f8366147b0a2e8562d7386f23db6327a0b007ee |
Hashes for rust_fst-0.1.2-py2.py3-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ea0461726d0f044a32ae39620ab93762a0cefd0c7a825a36eff59f9d3c4f508 |
|
MD5 | 9c9b5711635164b4ece93766cb6744f1 |
|
BLAKE2b-256 | cd243e47451113ab401be513e8ed64023d7c96c2203a4e1493155e9cf44b4fc4 |
Hashes for rust_fst-0.1.2-py2.py3-none-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ee2261e89264709d8ef040965c12538bb3b7db89ee00e22f8816d19c86295ce |
|
MD5 | 3fbbad58a6af001dd674df77973bf808 |
|
BLAKE2b-256 | f264d8aba6d4bc2193377359086062af8367afb3d8726774fe4750f00c07653a |
Hashes for rust_fst-0.1.2-py2.py3-none-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb4107866472df3ed878e714726e59764867c8262b353206c812ef38c1ebb0ad |
|
MD5 | 0db7410521722f2602ca166e669fde3c |
|
BLAKE2b-256 | 231242db4ee067877f1a9be3f4f2c1c70499036c45ab2dd0abb44b329ee66756 |