Skip to main content

No project description provided

Project description

FuzzyTrie

FuzzyTrie is a lightweight, fast, and dependency-free fuzzy search library for Python, written in Rust. It performs efficient string matching and correction using a Levenshtein automaton, as described in this paper

Usage

from fuzzytrie import FuzzyTrie

t = FuzzyTrie()

# Initialize automatons for edit distances of 1 and 2
t.init_automaton(d=1)
t.init_automaton(d=2)

for w in ["lavanshtain", "levanshtain", "levenshtain"]:
    t.add(w)

# Perform fuzzy searches with different maximum distances
print(t.search(query="levenshtein", d=2))
# Returns list of distances between query and element, and elements
# >> [(2, 'levanshtain'), (1, 'levenshtain')]
print(t.search(query="levenshtein", d=1))
# >> [(1, 'levenshtain')]

Limitations

  • The maximum supported Levenshtein distance is 15.
  • Automaton initialization time grows quickly with larger distances. For example:
    • d = 1–3: initialization completes in a fraction of a second.
    • d = 4: initialization takes about 14 seconds.

Benchmarks

Benchmarks were run on a dataset of ~460k words with 500 sample queries for each distance. Results were compared against a brute-force implementation (Levenshtein distance in C from rapidfuzz/Levenshtein)

Distance Automaton init time (s) Avg. FuzzyTrie search (s) Avg. brute force search (s) Speedup
1 ~3.29e-05 ~0.00046 ~0.14 306x
2 ~0.000608 ~0.00167 ~0.14 84x
3 ~0.053419 ~0.00502 ~0.14 27x

Theory of operation

Brief explaination of how this works internally can be found here

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fuzzytrie-0.3.0.tar.gz (6.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

fuzzytrie-0.3.0-cp313-cp313-macosx_11_0_arm64.whl (216.3 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

fuzzytrie-0.3.0-cp312-cp312-macosx_11_0_arm64.whl (216.3 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

fuzzytrie-0.3.0-cp311-cp311-macosx_11_0_arm64.whl (218.6 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

fuzzytrie-0.3.0-cp310-cp310-macosx_11_0_arm64.whl (218.6 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file fuzzytrie-0.3.0.tar.gz.

File metadata

  • Download URL: fuzzytrie-0.3.0.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.9.4

File hashes

Hashes for fuzzytrie-0.3.0.tar.gz
Algorithm Hash digest
SHA256 7503432b532cb454f973be0b8210de069b5ac5d38e2558281dfccf4d03423264
MD5 eeed5f99a93b3ecfc5319e44c49140bd
BLAKE2b-256 9e6828db0b2bcbc22045d3481758b33150b78b5016a7a2b470dabce76ad1c174

See more details on using hashes here.

File details

Details for the file fuzzytrie-0.3.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fuzzytrie-0.3.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ece57dcdd54ff3e39ded66e59c721e10494d3a1b0178ee59659678af48b2663c
MD5 c7c2da41b0e794bee61ca22fb2a2a82f
BLAKE2b-256 ae099473a0cb93f8f87e53785519dcbee48dd9f33187f65a210d912c61e85411

See more details on using hashes here.

File details

Details for the file fuzzytrie-0.3.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fuzzytrie-0.3.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4c1bba0c1d81f54929032e0c054f0e541649fb7817de612c246855d23bb9e4d1
MD5 0fbe57d41eb54572ca52327ccf1fe6b8
BLAKE2b-256 67647c9b3b3e022011be689c89af79d3afb0ecc992baab58448db66ffab34f53

See more details on using hashes here.

File details

Details for the file fuzzytrie-0.3.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fuzzytrie-0.3.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5d025cd738ce541a814e545ef41a65b82c00d54c56f8978640715f367a8f358a
MD5 f3101654345f42254f05eb037a0a3d54
BLAKE2b-256 452517a6b79adbda3b8582acd5efb803d2dc9d2b2aeef9dfc2b0fdd4468d0893

See more details on using hashes here.

File details

Details for the file fuzzytrie-0.3.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fuzzytrie-0.3.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3b83f76325673b75f3175682d770dc84998894d6513d38ba897527d449e38b77
MD5 8807c250923da991b6b4e6b70f06a2c4
BLAKE2b-256 88cc7ffc90b9aee48868f8ad836b1b5c4292fabf98c8893d947c519602107eee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page