Skip to main content

Matching a string with partial input

Project description

Tiny and blazing-fast fuzzy search in Python.

Fuzzy searching allows for flexibly matching a string with partial input, useful for filtering data very quickly based on lightweight user input.

Port of fuzzysearch in JavaScript into Python.

Install

Just install using pip:

$ pip install simple-fuzzysearch

fuzzysearch(needle, haystack)

Returns true if needle matches haystack using a fuzzy-searching algorithm. Note that this program doesn’t implement levenshtein distance, but rather a simplified version where there’s no approximation. The method will return true only if each character in the needle can be found in the haystack and occurs after the preceding matches.

from fuzzysearch import fuzzysearch

fuzzysearch('twl', 'cartwheel') # <- true
fuzzysearch('cart', 'cartwheel') # <- true
fuzzysearch('cw', 'cartwheel') # <- true
fuzzysearch('ee', 'cartwheel') # <- true
fuzzysearch('art', 'cartwheel') # <- true
fuzzysearch('eeel', 'cartwheel') # <- false
fuzzysearch('dog', 'cartwheel') #  <- false

License

MIT

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

simple_fuzzysearch-0.0.5-py2.py3-none-any.whl (3.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file simple_fuzzysearch-0.0.5-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for simple_fuzzysearch-0.0.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7b772ae4baf873aa5be468e01ba16af764be118c1fa135f6161b3d349f3ed0e3
MD5 558a56ebfea90c033add42c202e34fd9
BLAKE2b-256 56c97ba251409955fb21e868f6595e129b5c8b95a8be421c5d85bb36606509f6

See more details on using hashes here.

Supported by

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