Fuzzy Finder implemented in Python.
Project description
Fuzzy Finder implemented in Python. Matches partial string entries from a list of strings. Works similar to fuzzy finder in SublimeText and Vim’s Ctrl-P plugin.
Documentation: https://fuzzyfinder.readthedocs.org.
Quick Start
$ pip install fuzzyfinder or $ easy_install fuzzyfinder
Usage
>>> from fuzzyfinder import fuzzyfinder
>>> suggestions = fuzzyfinder('abc', ['defabca', 'abcd', 'aagbec', 'xyz', 'qux'])
>>> list(suggestions)
['abcd', 'defabca', 'aagbec']
>>> # Use a user-defined function to obtain the string against which fuzzy matching is done
>>> collection = ['aa bbb', 'aca xyz', 'qx ala', 'xza az', 'bc aa', 'xy abca']
>>> suggestions = fuzzyfinder('aa', collection, accessor=lambda x: x.split()[1])
>>> list(suggestions)
['bc aa', 'qx ala', 'xy abca']
>>> suggestions = fuzzyfinder('aa', ['aac', 'aaa', 'aab', 'xyz', 'ada'])
>>> list(suggestions)
['aaa', 'aab', 'aac', 'ada']
>>> # Preserve original order of elements if matches have same rank
>>> suggestions = fuzzyfinder('aa', ['aac', 'aaa', 'aab', 'xyz', 'ada'], sort_results=False)
>>> list(suggestions)
['aac', 'aaa', 'aab', 'ada']
Features
Simple, easy to understand code.
No external dependencies, just the python std lib.
How does it work
Blog post describing the algorithm: http://blog.amjith.com/fuzzyfinder-in-10-lines-of-python
Similar Projects
https://github.com/seatgeek/fuzzywuzzy - Fuzzy matching and auto-correction using levenshtein distance.
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
fuzzyfinder-2.2.0.tar.gz
(13.9 kB
view hashes)
Built Distribution
Close
Hashes for fuzzyfinder-2.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c60e5225bf435646e87eec3ef3d5bd094c5d5a4e4d069d0a4a07d515e990035 |
|
MD5 | 73b2a4e4687afb2cbfaf82e92af3f2b7 |
|
BLAKE2b-256 | 8cf9e38ecd7ac5bbfb175c6b6aec9ae2c893caede8dd6e21dd71b316b9005ee7 |