Skip to main content

Fuzzy Finder implemented in Python.

Project description

https://img.shields.io/travis/amjith/fuzzyfinder.svg https://img.shields.io/pypi/v/fuzzyfinder.svg

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.

https://raw.githubusercontent.com/amjith/fuzzyfinder/master/screenshots/pgcli-fuzzy.gif

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

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 details)

Uploaded Source

Built Distribution

fuzzyfinder-2.2.0-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file fuzzyfinder-2.2.0.tar.gz.

File metadata

  • Download URL: fuzzyfinder-2.2.0.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for fuzzyfinder-2.2.0.tar.gz
Algorithm Hash digest
SHA256 b7699fca41230241c5312dff624029a10e40cc7f695e44290b8f2e8e070c4bb4
MD5 4d8ab346a7b5550d4c62fbfcc3afa24e
BLAKE2b-256 e12b653ded7c1b2110eb576b692ae619ea1b29d7e3446e513685968a5f3b2bec

See more details on using hashes here.

File details

Details for the file fuzzyfinder-2.2.0-py3-none-any.whl.

File metadata

  • Download URL: fuzzyfinder-2.2.0-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for fuzzyfinder-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1c60e5225bf435646e87eec3ef3d5bd094c5d5a4e4d069d0a4a07d515e990035
MD5 73b2a4e4687afb2cbfaf82e92af3f2b7
BLAKE2b-256 8cf9e38ecd7ac5bbfb175c6b6aec9ae2c893caede8dd6e21dd71b316b9005ee7

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