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))
# >> ['levanshtain', 'levenshtain']
print(t.search(query="levenshtein", d=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.2.0.tar.gz (6.5 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.2.0-cp313-cp313-macosx_11_0_arm64.whl (213.9 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

fuzzytrie-0.2.0-cp312-cp312-macosx_11_0_arm64.whl (213.9 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

fuzzytrie-0.2.0-cp311-cp311-macosx_11_0_arm64.whl (216.2 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

fuzzytrie-0.2.0-cp310-cp310-macosx_11_0_arm64.whl (216.1 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for fuzzytrie-0.2.0.tar.gz
Algorithm Hash digest
SHA256 7c66fcf1ac13b80e51c7412f8ee2c3de51142a54f713c26ca9d8be13e5f6bca3
MD5 f010fc709127b4ff33bcd54607650433
BLAKE2b-256 3754ff701e82c1d17f0eb9f00733c3fd29faf78894a02cbe45906566bbd3fac0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fuzzytrie-0.2.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9f134306dab8b308d52c855d1397cd93cc8bb22100b907549383d9792522ff93
MD5 2b303991acd05c3fb98116bcc28acb1d
BLAKE2b-256 b98d702c6bd3c172f2aea61144aff0881ce1a02685a87873b7145654a7bcb4b4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fuzzytrie-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6b946798f3967fa8273b4488d7db81edbe00ccbdaa31f8f5acd9ac09f9d91a97
MD5 6e014a2f8a6b50d8d499c81bcfd69dcb
BLAKE2b-256 868359ebde2152f3940a48b275cfacf15942b354531bc73245ec653b0347109a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fuzzytrie-0.2.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 647152abbae92d842d0c0c448996b04c3119b832c3362cd2430f0b3359a0ef31
MD5 f1e052d8ee8ba051e9f53267098885da
BLAKE2b-256 0bf9f3c5dad6677dab12605c86efd5b6d7e53b81027b5ddc73275fbc5ab37aa3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fuzzytrie-0.2.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 61415af2b2894cf0d81f69707137a83701d49defc71b1f9814aed1fa1df717c9
MD5 b1f0a4b722a336d81be5f70d44cc6cfd
BLAKE2b-256 fc7ef40a79a5cb4267fb631fa46e4f8cedd8c189588ebcc12b41cc35d2664b04

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