Skip to main content

Python port of the fzy fuzzy string matching algorithm

Project description

pfzy

CI Docs Build Coverage Version PyPi License

Python port of the fzy fuzzy string matching algorithm.

Requirements

python >= 3.7

Installation

pip install pfzy

Quick Start

Full documentation: https://pfzy.readthedocs.io/

import asyncio

from pfzy import fuzzy_match

result = asyncio.run(fuzzy_match("ab", ["acb", "acbabc"]))
>>> print(result)
[{'value': 'acbabc', 'indices': [3, 4]}, {'value': 'acb', 'indices': [0, 2]}]

Background

fuzzywuzzy is a famous python package for performing fuzzy matching between strings powered by python-Levenshtein. While it does its job well it doesn't calculate/provide the matching indices which is essential in a fuzzy finder applications.

The fzy fuzzy matching algorithm can calculate the matching score while also providing the matching indices which fuzzy finder applications can use to provide extra highlights.

The initial implementation of this algorithm can be found at sweep.py which is a python implementation of the terminal fuzzy finder. The code snippet is later used by the project vim-clap.

I found myself needing this logic across multiple projects hence decided to strip out the logic and publish a dedicated package with detailed documentation and unittest.

Credit

LICENSE

All 3 projects mentioned in Credit are all licensed under MIT.

This project is licensed under MIT. Copyright (c) 2021 Kevin Zhuang

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

pfzy-0.3.4.tar.gz (8.4 kB view hashes)

Uploaded Source

Built Distribution

pfzy-0.3.4-py3-none-any.whl (8.5 kB view hashes)

Uploaded Python 3

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