Rapid fuzzy string matching in Python using various string metrics
Go to file
maxbachmann 303fcd1118
separate documentation for fuzz and process
2020-05-30 22:41:35 +02:00
.github/workflows add documentation 2020-05-27 14:16:12 +02:00
bench update submodule and benchmark results 2020-05-12 21:59:14 +02:00
docs separate documentation for fuzz and process 2020-05-30 22:41:35 +02:00
extern/variant reduce string copies and tarball size 2020-05-22 13:28:38 +02:00
src document: default processor in fuzz.*ratio functions 2020-05-31 00:52:42 +05:30
tests add unit tests 2020-05-24 10:42:36 +02:00
.gitattributes add documentation 2020-05-27 14:16:12 +02:00
.gitignore add documentation 2020-05-27 14:16:12 +02:00
.gitmodules move cpp into submodule 2020-04-13 08:50:35 +02:00
Benchmarks.md add documentation 2020-05-27 14:16:12 +02:00
LICENSE add license preamble 2020-04-10 15:06:57 +02:00
MANIFEST.in do not include boost 2020-05-22 18:26:43 +02:00
README.md add newline 2020-05-27 14:18:54 +02:00
VERSION fix inconsistency from #32 2020-05-24 08:19:28 +02:00
mkdocs.yml separate documentation for fuzz and process 2020-05-30 22:41:35 +02:00
setup.py reduce string copies and tarball size 2020-05-22 13:28:38 +02:00

README.md

RapidFuzz

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

Continous Integration PyPI package version Conda Version Python versions
Gitter chat Documentation 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 you're forced to adopt the GPL 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. More details on these performance improvements in form of benchmarks can be found here

Installation

RapidFuzz can be installed using pip

$ pip install rapidfuzz

There are pre-built binaries (wheels) for RapidFuzz and its dependencies for MacOS (10.9 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++14 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 I believe that everyone should be able to use it without being forced to adopt the GPL license. Thats why the library is based on an older version of fuzzywuzzy that was MIT licensed as well. This old version of fuzzywuzzy can be found here.