All Projects → maxbachmann → Rapidfuzz

maxbachmann / Rapidfuzz

Licence: mit
Rapid fuzzy string matching in Python using the Levenshtein Distance

Programming Languages

python
139335 projects - #7 most used programming language
cpp
1120 projects

Projects that are alternatives of or similar to Rapidfuzz

edit-distance-papers
A curated list of papers dedicated to edit-distance as objective function
Stars: ✭ 49 (-93.94%)
Mutual labels:  levenshtein
Levenshtein
The Levenshtein Python C extension module contains functions for fast computation of Levenshtein distance and string similarity
Stars: ✭ 38 (-95.3%)
Mutual labels:  levenshtein
Go Edlib
Golang string comparison and edit distance algorithms library, featuring : Levenshtein, LCS, Hamming, Damerau levenshtein (OSA and Adjacent transpositions algorithms), Jaro-Winkler, Cosine, etc...
Stars: ✭ 253 (-68.73%)
Mutual labels:  levenshtein
spellchecker-wasm
SpellcheckerWasm is an extrememly fast spellchecker for WebAssembly based on SymSpell
Stars: ✭ 46 (-94.31%)
Mutual labels:  levenshtein
levenshtein-rs
Levenshtein algorithm in Rust
Stars: ✭ 37 (-95.43%)
Mutual labels:  levenshtein
stringosim
String similarity functions, String distance's, Jaccard, Levenshtein, Hamming, Jaro-Winkler, Q-grams, N-grams, LCS - Longest Common Subsequence, Cosine similarity...
Stars: ✭ 47 (-94.19%)
Mutual labels:  levenshtein
eddie
No description or website provided.
Stars: ✭ 18 (-97.78%)
Mutual labels:  levenshtein
Symspellpy
Python port of SymSpell
Stars: ✭ 420 (-48.08%)
Mutual labels:  levenshtein
strutil
Golang metrics for calculating string similarity and other string utility functions
Stars: ✭ 114 (-85.91%)
Mutual labels:  levenshtein
similar-english-words
Give me a word and I’ll give you an array of words that differ by a single letter.
Stars: ✭ 25 (-96.91%)
Mutual labels:  levenshtein
LinSpell
Fast approximate strings search & spelling correction
Stars: ✭ 52 (-93.57%)
Mutual labels:  levenshtein
edits.cr
Edit distance algorithms inc. Jaro, Damerau-Levenshtein, and Optimal Alignment
Stars: ✭ 16 (-98.02%)
Mutual labels:  levenshtein
hubot-suggest
Suggest hubot commands when not found
Stars: ✭ 29 (-96.42%)
Mutual labels:  levenshtein
stringdistance
A fuzzy matching string distance library for Scala and Java that includes Levenshtein distance, Jaro distance, Jaro-Winkler distance, Dice coefficient, N-Gram similarity, Cosine similarity, Jaccard similarity, Longest common subsequence, Hamming distance, and more..
Stars: ✭ 60 (-92.58%)
Mutual labels:  levenshtein
Js Levenshtein
The most efficient JS implementation calculating the Levenshtein distance, i.e. the difference between two strings.
Stars: ✭ 269 (-66.75%)
Mutual labels:  levenshtein
Quickenshtein
Making the quickest and most memory efficient implementation of Levenshtein Distance with SIMD and Threading support
Stars: ✭ 204 (-74.78%)
Mutual labels:  levenshtein
simetric
String similarity metrics for Elixir
Stars: ✭ 59 (-92.71%)
Mutual labels:  levenshtein
Stringmetric
🎯 String metrics and phonetic algorithms for Scala (e.g. Dice/Sorensen, Hamming, Jaccard, Jaro, Jaro-Winkler, Levenshtein, Metaphone, N-Gram, NYSIIS, Overlap, Ratcliff/Obershelp, Refined NYSIIS, Refined Soundex, Soundex, Weighted Levenshtein).
Stars: ✭ 481 (-40.54%)
Mutual labels:  levenshtein
Closestmatch
Golang library for fuzzy matching within a set of strings 📃
Stars: ✭ 353 (-56.37%)
Mutual labels:  levenshtein
RepostCheckerBot
Bot for checking reposts on reddit
Stars: ✭ 36 (-95.55%)
Mutual labels:  levenshtein

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

Requirements

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:

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.

✖️   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:

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++14 capable compiler.

git clone https://github.com/maxbachmann/rapidfuzz.git
cd rapidfuzz
pip install .

Usage

Some simple functions are shown below. A complete documentation of all functions can be found here.

Scorers

Scorers in RapidFuzz can be found in the modules fuzz and string_metric.

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

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:

> 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', 100, 1), ('New York Giants', 78.57142639160156, 2)]
> process.extractOne("cowboys", choices, scorer=fuzz.WRatio)
("Dallas Cowboys", 90, 3)

The full documentation of processors can be found here

Benchmark

The following benchmark gives a quick performance comparision between RapidFuzz and FuzzyWuzzy. More detailed benchmarks for the string metrics can be found in the documentation. For this simple comparision I generated a list of 10.000 strings with length 10, that is compared to a sample of 100 elements from this list:

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:

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

scorer Benchmark

The second benchmark compares the performance when the scorers are used in combination with extractOne in the following way:

for sample in samples:
  extractOne(sample, word, 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 extractOne is a lot faster than directly using it. Thats why they should be used whenever possible.

extractOne Benchmark

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].