Fuzzy Finder implemented in Python.
Project description
fuzzyfinder is a fuzzy finder implemented in Python. It matches partial string entries from a list of strings, and works similar to the fuzzy finder in SublimeText and Vim’s Ctrl-P plugin.
Some notable features of fuzzyfinder are:
Simple, easy to understand code.
No external dependencies, just the Python standard library.
An in-depth overview of the algorithm behind fuzzyfinder is available in this blog post.
Quick Start
Installation
$ pip install fuzzyfinder
Usage
>>> from fuzzyfinder import fuzzyfinder
>>> suggestions = fuzzyfinder('abc', ['acb', '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']
>>> # With the appropriate accessor you can pass non-string collections, too
>>> collection = [1234, 5678, 7537, 888, 57, 77]
>>> suggestions = fuzzyfinder('57', collection, accessor=str)
>>> list(suggestions)
[57, 5678, 7537]
>>> # Make filtering case-sensitive
>>> collection = ['bAB', 'aaB', 'Aab', 'xyz', 'adb', 'aAb']
>>> suggestions = fuzzyfinder('Ab', collection, ignore_case=False)
>>> list(suggestions)
['aAb', 'Aab']
>>> # By default, elements with matches of same rank are sorted alpha-numerically
>>> 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']
>>> # Highlight matching substrings when printing to the terminal
>>> collection = ['apple', 'banana', 'grape', 'orange', 'pineapple']
>>> suggestions = fuzzyfinder('ape', collection, highlight=True)
>>> list(suggestions)
['gr\x1b[42mape\x1b[0m', '\x1b[42map\x1b[0mpl\x1b[42me\x1b[0m', 'pine\x1b[42map\x1b[0mpl\x1b[42me\x1b[0m']
>>> # Custom highlighting (use with ANSI, HTML, etc.)
>>> parentheses = '(', ')'
>>> suggestions = fuzzyfinder('ape', collection, highlight=parentheses)
>>> list(suggestions)
['gr(ape)', '(ap)pl(e)', 'pine(ap)pl(e)']
Similar Projects
https://github.com/seatgeek/thefuzz - Fuzzy matching and auto-correction using levenshtein distance.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fuzzyfinder-2.3.0.tar.gz.
File metadata
- Download URL: fuzzyfinder-2.3.0.tar.gz
- Upload date:
- Size: 78.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d2de6650852fdf3da896917b2fe88550d854dda590de5f239c2899f7eaf20df
|
|
| MD5 |
329b6588a00485ed97d6cec7dc0f1847
|
|
| BLAKE2b-256 |
3c1627e312d2b4bdb9f5101b68031048d790edd348a31ee80c3f77066c04d311
|
Provenance
The following attestation bundles were made for fuzzyfinder-2.3.0.tar.gz:
Publisher:
publish.yml on amjith/fuzzyfinder
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fuzzyfinder-2.3.0.tar.gz -
Subject digest:
3d2de6650852fdf3da896917b2fe88550d854dda590de5f239c2899f7eaf20df - Sigstore transparency entry: 199960622
- Sigstore integration time:
-
Permalink:
amjith/fuzzyfinder@ff29abb6150e37deb8a9087df7057c27b55ac381 -
Branch / Tag:
refs/tags/v2.3.0 - Owner: https://github.com/amjith
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ff29abb6150e37deb8a9087df7057c27b55ac381 -
Trigger Event:
release
-
Statement type:
File details
Details for the file fuzzyfinder-2.3.0-py3-none-any.whl.
File metadata
- Download URL: fuzzyfinder-2.3.0-py3-none-any.whl
- Upload date:
- Size: 19.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ee35618ca6e1562a235d0f40f594b36ae374e55650a251d52add353b7e3f215
|
|
| MD5 |
a0e7ab5155c0f4819cfbfd2df7773cbe
|
|
| BLAKE2b-256 |
8cc3e64d5e277373e93b75d9711e46dd7903887e8efa8ecc033e2c5df760e309
|
Provenance
The following attestation bundles were made for fuzzyfinder-2.3.0-py3-none-any.whl:
Publisher:
publish.yml on amjith/fuzzyfinder
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fuzzyfinder-2.3.0-py3-none-any.whl -
Subject digest:
4ee35618ca6e1562a235d0f40f594b36ae374e55650a251d52add353b7e3f215 - Sigstore transparency entry: 199960623
- Sigstore integration time:
-
Permalink:
amjith/fuzzyfinder@ff29abb6150e37deb8a9087df7057c27b55ac381 -
Branch / Tag:
refs/tags/v2.3.0 - Owner: https://github.com/amjith
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ff29abb6150e37deb8a9087df7057c27b55ac381 -
Trigger Event:
release
-
Statement type: