Skip to main content

rapid fuzzy string matching

Project description

RapidFuzz

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

Continous Integration PyPI package version Conda 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 you're 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 2-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.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 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 as well. A Fork of this old version of fuzzywuzzy can be found here.

Project details


Release history Release notifications | RSS feed

This version

0.6.4

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rapidfuzz-0.6.4.tar.gz (102.8 kB view details)

Uploaded Source

File details

Details for the file rapidfuzz-0.6.4.tar.gz.

File metadata

  • Download URL: rapidfuzz-0.6.4.tar.gz
  • Upload date:
  • Size: 102.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.7.6

File hashes

Hashes for rapidfuzz-0.6.4.tar.gz
Algorithm Hash digest
SHA256 6f9922a47b3a602c909b03b2c2ea20c6749d69a7f09316f563e0fc6c70d005d2
MD5 f242c1cc05146d0dcd6ac9619af3192a
BLAKE2b-256 3fe4d29e1378034cb51f5c602d779a918be9e50acbbfd3a96d835b3c92e49697

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