Rapid fuzzy string matching in Python using various string metrics
Go to file
maxbachmann 0b81415484
release version 0.3.0
- When using score_cutoff there is now a guarantee that it returns 0 when result < score_cutoff
- each function has now a preprocess argument to specify whether strings should be preprocessed
- the default preprocessing does now lower case and trim
- extract and extractOne accept a custom processor method instead of utils.default_processor now

- QRatio was removed since it does now exactly the same as normal ratio
2020-03-26 17:23:06 +01:00
.github automatically build python Wheels (#5) 2020-03-22 23:12:51 +01:00
cpp release version 0.3.0 2020-03-26 17:23:06 +01:00
python/src release version 0.3.0 2020-03-26 17:23:06 +01:00
.gitattributes complete basic implementation of rapidfuzz 2020-03-18 21:34:32 +01:00
.gitignore complete basic implementation of rapidfuzz 2020-03-18 21:34:32 +01:00
Benchmarks.md lowercase strings before processing 2020-03-22 14:45:08 +01:00
CHANGELOG release version 0.3.0 2020-03-26 17:23:06 +01:00
LICENSE initialise c++ version 2020-02-29 15:45:15 +01:00
MANIFEST.in add license to package 2020-03-23 13:10:37 +01:00
README.md release version 0.3.0 2020-03-26 17:23:06 +01:00
VERSION release version 0.3.0 2020-03-26 17:23:06 +01:00
setup.py automatically build python Wheels (#5) 2020-03-22 23:12:51 +01:00

README.md

RapidFuzz

Rapid fuzzy string matching in Python and C++ using the Levenshtein Distance

Continous Integration PyPI package version Python versions GitHub license

DescriptionInstallationUsageLicense


Description

RapidFuzz is a fast string matching library for Python and C++, which is using the string similarity calculations from FuzzyWuzzy. However there are two aspects that set RapidFuzz apart from FuzzyWuzzy:

  1. It is MIT licensed so it can be used whichever License you might want to choose for your project, while your forced to adopt the GPLv2 license when using FuzzyWuzzy
  2. It is mostly written in C++ and on top of this comes with a lot of Algorithmic improvements to make string matching even faster, while still providing the same results. These changes result in a 5-100x Speedup in String Matching. More details on benchmark results can be found here

Installation

RapidFuzz can be installed using pip

$ pip install rapidfuzz

We currently have pre-built binaries (wheels) for RapidFuzz and its dependencies for MacOS (10.14 and later), Linux x86_64 and Windows.

For any other architecture/os RapidFuzz can be installed from the source distribution. To do so, a C++17 capable compiler must be installed before running the pip install rapidfuzz command. While Linux and MacOs usually come with a compiler it is required to install C++-Buildtools on Windows.

Usage

> from rapidfuzz import fuzz
> from rapidfuzz import process

Simple Ratio

> fuzz.ratio("this is a test", "this is a test!")
96.55171966552734

Partial Ratio

> fuzz.partial_ratio("this is a test", "this is a test!")
100.0

Token Sort Ratio

> fuzz.ratio("fuzzy wuzzy was a bear", "wuzzy fuzzy was a bear")
90.90908813476562
> fuzz.token_sort_ratio("fuzzy wuzzy was a bear", "wuzzy fuzzy was a bear")
100.0

Token Set Ratio

> fuzz.token_sort_ratio("fuzzy was a bear", "fuzzy fuzzy was a bear")
83.8709716796875
> fuzz.token_set_ratio("fuzzy was a bear", "fuzzy fuzzy was a bear")
100.0

Process

> choices = ["Atlanta Falcons", "New York Jets", "New York Giants", "Dallas Cowboys"]
> process.extract("new york jets", choices, limit=2)
[('new york jets', 100), ('new york giants', 78.57142639160156)]
> process.extractOne("cowboys", choices)
("dallas cowboys", 90)

License

RapidFuzz is licensed under the MIT license since we believe that everyone should be able to use it without being forced to adopt our license. Thats why the library is based on an older version of fuzzywuzzy that was MIT licensed aswell. A Fork of this old version of fuzzywuzzy can be found here.