rapid fuzzy string matching
Project description
Rapid fuzzy string matching in Python and C++ using the Levenshtein Distance
Why Should You Care? • Installation • Usage • License
Why Should You Care?
Since there is already FuzzyWuzzy that implements the same string similarity calculations you might wonder why you would want to use RapidFuzz. There are mainly two reasons:
- It is MIT licensed so in contrast to FuzzyWuzzy it can be used in projects where you do not want to adopt the GPL License
- While FuzzyWuzzy only uses python-Levenshtein for the levenshtein calculations and implements the other functionalities in Python, RapidFuzz's implementation is mostly written in C++ and on Top of this comes with a lot of Algorithmic improvements. This results in a 5-100x Speedup in String Matching.
Installation
RapidFuzz can be installed using pip
$ pip install rapidfuzz
it requires Python 3.5 or later and a C++ Compiler with C++17 support, which should be given on all current systems
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
currently no string preprocessing is done so your responsible for removing unwanted characters and to lowercase the strings if thats what you want
> 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.
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
File details
Details for the file rapidfuzz-0.1.1.tar.gz
.
File metadata
- Download URL: rapidfuzz-0.1.1.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61316202307d9f7a4d1a839a040194d4aa69d5ef955f5885072af29ddeec9115 |
|
MD5 | 1b4dd7aed708670a7311e7147822acc1 |
|
BLAKE2b-256 | 5687a8197854d77c6f0bf27f3ccd817bf05d769afd10fcb41846cc9fd90fdf8b |