FuzzyWuzzy

0.18.0 · active · verified Wed Apr 08

FuzzyWuzzy is a Python library that implements fuzzy string matching, often used for comparing the similarity between two strings. It leverages Levenshtein distance to calculate ratios between strings. The current version is 0.18.0. Its release cadence has been infrequent in recent years.

Warnings

Install

Imports

Quickstart

Demonstrates basic usage of `fuzz` for various ratio calculations and `process` for extracting best matches from a list of choices.

from fuzzywuzzy import fuzz
from fuzzywuzzy import process

# Simple Ratio
print(fuzz.ratio("this is a test", "this is a test!"))

# Partial Ratio
print(fuzz.partial_ratio("this is a test", "this is a test!"))

# Token Sort Ratio
print(fuzz.token_sort_ratio("fuzzy wuzzy was a bear", "wuzzy fuzzy was a bear"))

# Token Set Ratio
print(fuzz.token_set_ratio("fuzzy wuzzy was a bear", "wuzzy fuzzy was a bear"))

choices = ["apple jack", "apple mac", "apple sauce", "orange juice"]
print(process.extract("apple", choices, scorer=fuzz.ratio))
print(process.extractOne("apple goop", choices))

view raw JSON →