rapidfuzz
Rapid fuzzy string matching in Python using various string metrics
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (16.4%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
Rapid fuzzy string matching in Python using various string metrics
Basic Info
- Host: GitHub
- Owner: rapidfuzz
- License: mit
- Language: Python
- Default Branch: main
- Homepage: https://rapidfuzz.github.io/RapidFuzz/
- Size: 7.37 MB
Statistics
- Stars: 3,368
- Watchers: 23
- Forks: 138
- Open Issues: 34
- Releases: 134
Topics
Metadata Files
README.md
Rapid fuzzy string matching in Python and C++ using the Levenshtein Distance
Description • Installation • Usage • License
Description
RapidFuzz is a fast string matching library for Python and C++, which is using the string similarity calculations from FuzzyWuzzy. However there are a couple of 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 provides many stringmetrics like hamming or jarowinkler, which are not included in FuzzyWuzzy
3) 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. For detailed benchmarks check the documentation
4) Fixes multiple bugs in the partial_ratio implementation
5) It can be largely used as a drop in replacement for fuzzywuzzy. However there are a couple API differences described here
Requirements
- Python 3.10 or later
- On Windows the Visual C++ 2019 redistributable is required
Installation
There are several ways to install RapidFuzz, the recommended methods
are to either use pip(the Python package manager) or
conda (an open-source, cross-platform, package manager)
with pip
RapidFuzz can be installed with pip the following way:
bash
pip install rapidfuzz
There are pre-built binaries (wheels) of RapidFuzz for MacOS (10.9 and later), Linux x86_64 and Windows. Wheels for armv6l (Raspberry Pi Zero) and armv7l (Raspberry Pi) are available on piwheels.
:heavymultiplicationx: failure "ImportError: DLL load failed"
If you run into this error on Windows the reason is most likely, that the Visual C++ 2019 redistributable is not installed, which is required to find C++ Libraries (The C++ 2019 version includes the 2015, 2017 and 2019 version).
with conda
RapidFuzz can be installed with conda:
bash
conda install -c conda-forge rapidfuzz
from git
RapidFuzz can be installed directly from the source distribution by cloning the repository. This requires a C++17 capable compiler.
bash
git clone --recursive https://github.com/rapidfuzz/rapidfuzz.git
cd rapidfuzz
pip install .
Usage
Some simple functions are shown below. A complete documentation of all functions can be found here.
Note that from RapidFuzz 3.0.0, strings are not preprocessed(removing all non alphanumeric characters, trimming whitespaces, converting all characters to lower case) by default. Which means that when comparing two strings that have the same characters but different cases("this is a word", "THIS IS A WORD") their similarity score value might be different, so when comparing such strings you might see a difference in score value compared to previous versions. Some examples of string matching with preprocessing can be found here.
Scorers
Scorers in RapidFuzz can be found in the modules fuzz and distance.
Simple Ratio
```console
from rapidfuzz import fuzz fuzz.ratio("this is a test", "this is a test!") 96.55172413793103 ```
Partial Ratio
```console
from rapidfuzz import fuzz fuzz.partial_ratio("this is a test", "this is a test!") 100.0 ```
Token Sort Ratio
```console
from rapidfuzz import fuzz fuzz.ratio("fuzzy wuzzy was a bear", "wuzzy fuzzy was a bear") 90.9090909090909 fuzz.tokensortratio("fuzzy wuzzy was a bear", "wuzzy fuzzy was a bear") 100.0 ```
Token Set Ratio
```console
from rapidfuzz import fuzz fuzz.tokensortratio("fuzzy was a bear", "fuzzy fuzzy was a bear") 84.21052631578947 fuzz.tokensetratio("fuzzy was a bear", "fuzzy fuzzy was a bear") 100.0
Returns 100.0 if one string is a subset of the other, regardless of extra content in the longer string
fuzz.tokensetratio("fuzzy was a bear but not a dog", "fuzzy was a bear") 100.0
Score is reduced only when there is explicit disagreement in the two strings
fuzz.tokensetratio("fuzzy was a bear but not a dog", "fuzzy was a bear but not a cat") 92.3076923076923 ```
Weighted Ratio
```console
from rapidfuzz import fuzz fuzz.WRatio("this is a test", "this is a new test!!!") 85.5
from rapidfuzz import fuzz, utils
Removing non alpha numeric characters("!") from the string
fuzz.WRatio("this is a test", "this is a new test!!!", processor=utils.default_process) # here "this is a new test!!!" is converted to "this is a new test" 95.0 fuzz.WRatio("this is a test", "this is a new test") 95.0
Converting string to lower case
fuzz.WRatio("this is a word", "THIS IS A WORD") 21.42857142857143 fuzz.WRatio("this is a word", "THIS IS A WORD", processor=utils.default_process) # here "THIS IS A WORD" is converted to "this is a word" 100.0 ```
Quick Ratio
```console
from rapidfuzz import fuzz fuzz.QRatio("this is a test", "this is a new test!!!") 80.0
from rapidfuzz import fuzz, utils
Removing non alpha numeric characters("!") from the string
fuzz.QRatio("this is a test", "this is a new test!!!", processor=utils.default_process) 87.5 fuzz.QRatio("this is a test", "this is a new test") 87.5
Converting string to lower case
fuzz.QRatio("this is a word", "THIS IS A WORD") 21.42857142857143 fuzz.QRatio("this is a word", "THIS IS A WORD", processor=utils.default_process) 100.0 ```
Process
The process module makes it compare strings to lists of strings. This is generally more performant than using the scorers directly from Python. Here are some examples on the usage of processors in RapidFuzz:
```console
from rapidfuzz import process, fuzz choices = ["Atlanta Falcons", "New York Jets", "New York Giants", "Dallas Cowboys"] process.extract("new york jets", choices, scorer=fuzz.WRatio, limit=2) [('New York Jets', 76.92307692307692, 1), ('New York Giants', 64.28571428571428, 2)] process.extractOne("cowboys", choices, scorer=fuzz.WRatio) ('Dallas Cowboys', 83.07692307692308, 3)
With preprocessing
from rapidfuzz import process, fuzz, utils process.extract("new york jets", choices, scorer=fuzz.WRatio, limit=2, processor=utils.defaultprocess) [('New York Jets', 100.0, 1), ('New York Giants', 78.57142857142857, 2)] process.extractOne("cowboys", choices, scorer=fuzz.WRatio, processor=utils.defaultprocess) ('Dallas Cowboys', 90.0, 3) ```
The full documentation of processors can be found here
Benchmark
The following benchmark gives a quick performance comparison between RapidFuzz and FuzzyWuzzy.
More detailed benchmarks for the string metrics can be found in the documentation. For this simple comparison I generated a list of 10.000 strings with length 10, that is compared to a sample of 100 elements from this list:
python
words = [
"".join(random.choice(string.ascii_letters + string.digits) for _ in range(10))
for _ in range(10_000)
]
samples = words[:: len(words) // 100]
The first benchmark compares the performance of the scorers in FuzzyWuzzy and RapidFuzz when they are used directly
from Python in the following way:
python3
for sample in samples:
for word in words:
scorer(sample, word)
The following graph shows how many elements are processed per second with each of the scorers. There are big performance differences between the different scorers. However each of the scorers is faster in RapidFuzz
The second benchmark compares the performance when the scorers are used in combination with cdist in the following
way:
python3
cdist(samples, words, scorer=scorer)
The following graph shows how many elements are processed per second with each of the scorers. In RapidFuzz the usage of scorers through processors like cdist is a lot faster than directly using it. That's why they should be used whenever possible.
Support the project
If you are using RapidFuzz for your work and feel like giving a bit of your own benefit back to support the project, consider sending us money through GitHub Sponsors or PayPal that we can use to buy us free time for the maintenance of this great library, to fix bugs in the software, review and integrate code contributions, to improve its features and documentation, or to just take a deep breath and have a cup of tea every once in a while. Thank you for your support.
Support the project through GitHub Sponsors or via PayPal:
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. That's 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.
Owner
- Name: RapidFuzz
- Login: rapidfuzz
- Kind: organization
- Repositories: 13
- Profile: https://github.com/rapidfuzz
fuzzy string matching libraries for various programming languages
Citation (CITATION.bib)
@software{max_bachmann_2025_15133267,
author = {Max Bachmann},
title = {rapidfuzz/RapidFuzz: Release 3.13.0},
month = apr,
year = 2025,
publisher = {Zenodo},
version = {v3.13.0},
doi = {10.5281/zenodo.15133267},
url = {https://doi.org/10.5281/zenodo.15133267},
}
GitHub Events
Total
- Create event: 18
- Release event: 6
- Issues event: 27
- Watch event: 552
- Delete event: 17
- Issue comment event: 89
- Push event: 72
- Pull request review comment event: 7
- Pull request review event: 5
- Pull request event: 30
- Fork event: 14
Last Year
- Create event: 18
- Release event: 6
- Issues event: 27
- Watch event: 552
- Delete event: 17
- Issue comment event: 89
- Push event: 72
- Pull request review comment event: 7
- Pull request review event: 5
- Pull request event: 30
- Fork event: 14
Committers
Last synced: 7 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Max Bachmann | k****t@m****e | 752 |
| dependabot[bot] | 4****] | 15 |
| TrigonaMinima | s****5@y****n | 7 |
| layday | l****y@p****m | 5 |
| Thomas Ryde | t****e@g****m | 5 |
| dheeraj | d****8@g****m | 3 |
| Georgia Kokkinou | g****o@g****m | 3 |
| Henry Schreiner | H****I@g****m | 3 |
| Jeppe Fihl-Pearson | j****e@m****m | 3 |
| Julian Gilbey | j****g@d****g | 2 |
| Cristian Le | g****b@l****e | 2 |
| Jelomite | m****8@g****m | 2 |
| Michał Górny | m****y@g****g | 2 |
| Pekka Ristola | p****r@p****m | 2 |
| Vioshim | 6****m | 2 |
| Robert Schütz | g****b@d****e | 2 |
| Benjamin-1111 | 6****1 | 1 |
| Blake V. | 8****t | 1 |
| jlb52 | j****e@r****i | 1 |
| Pablo Marti | p****o@g****m | 1 |
| Christian Clauss | c****s@m****m | 1 |
| Dan Hess | p****1@g****m | 1 |
| Guy Rosin | g****n@g****m | 1 |
| Hugo Le Moine | 3****n | 1 |
| Kwuang Tang | 1****8 | 1 |
| Neo Lok Jun | 4****o | 1 |
| Nicolas Rnkmp | n****k | 1 |
| Thomas Ryde | tr@h****o | 1 |
| Trenton H | 7****g | 1 |
| Zash | z****h@f****e | 1 |
| and 2 more... | ||
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 49
- Total pull requests: 84
- Average time to close issues: about 1 month
- Average time to close pull requests: 7 days
- Total issue authors: 40
- Total pull request authors: 14
- Average comments per issue: 2.63
- Average comments per pull request: 1.65
- Merged pull requests: 52
- Bot issues: 1
- Bot pull requests: 48
Past Year
- Issues: 20
- Pull requests: 45
- Average time to close issues: 24 days
- Average time to close pull requests: 7 days
- Issue authors: 18
- Pull request authors: 8
- Average comments per issue: 2.35
- Average comments per pull request: 0.96
- Merged pull requests: 19
- Bot issues: 1
- Bot pull requests: 31
Top Authors
Issue Authors
- maxbachmann (6)
- juliangilbey (2)
- rocke2020 (2)
- silenceOfTheLambda (2)
- mdziezyc (2)
- yurivict (1)
- Scrxtchy (1)
- Vioshim (1)
- VaradDaniel (1)
- clin1234 (1)
- ZashIn (1)
- char101 (1)
- LecrisUT (1)
- dependabot[bot] (1)
- dwykat (1)
Pull Request Authors
- dependabot[bot] (48)
- dotlambda (4)
- henryiii (4)
- thomasryde (4)
- Vioshim (4)
- maxbachmann (4)
- cclauss (3)
- lokjunneo (2)
- LecrisUT (2)
- jlb52 (2)
- juliangilbey (2)
- philipp-horstenkamp (2)
- bvandercar-vt (2)
- ZashIn (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 95,756,989 last-month
- Total docker downloads: 1,564,720,316
- Total dependent packages: 299
- Total dependent repositories: 2,672
- Total versions: 169
- Total maintainers: 1
pypi.org: rapidfuzz
rapid fuzzy string matching
- Homepage: https://github.com/rapidfuzz/RapidFuzz
- Documentation: https://rapidfuzz.github.io/RapidFuzz/
- License: mit
-
Latest release: 3.14.0
published 6 months ago
Rankings
Maintainers (1)
Dependencies
- actions/checkout v2 composite
- actions/setup-python v2 composite
- actions/checkout v2 composite
- actions/deploy-pages v1 composite
- actions/setup-python v2 composite
- actions/upload-pages-artifact v1 composite
- actions/checkout v2 composite
- actions/download-artifact v2 composite
- actions/setup-python v2 composite
- actions/upload-artifact v2 composite
- docker/setup-qemu-action v1 composite
- pypa/cibuildwheel v2.9.0 composite
- pypa/gh-action-pypi-publish v1.5.1 composite
- editdistance *
- edlib *
- jellyfish *
- matplotlib *
- numpy *
- pandas *
- polyleven *
- pyxdameraulevenshtein *
- thefuzz *
- tqdm *
- Sphinx *
- docutils ==0.18.1
- furo *
- numpy *
- sphinxcontrib-bibtex *
