larzfuzzy
Fuzzy string matching in pure Python. Zero dependencies.
Compare strings that aren't exactly equal — edit distance, a 0-100 similarity
ratio, Jaro-Winkler (great for names), and, most usefully, pick the best match
for a query from a list of choices. The fuzzywuzzy/thefuzz surface, standard
library only (no python-Levenshtein C build).
from larzfuzzy import ratio, extract_one, jaro_winkler
ratio("apple", "aple") # 89
extract_one("new yrok", ["New York", "New Jersey", "Newark"]) # ('New York', 88)
jaro_winkler("MARTHA", "MARHTA") # 0.961
Why
- The functions you reach for.
ratio,partial_ratio,token_sort_ratio,levenshtein,jaro,jaro_winkler, andextract/extract_one. - Best-match extraction ranks a list of choices against a query — the actual job most fuzzy matching is for (autocomplete, dedupe, "did you mean…").
- Sensible defaults.
extractlowercases before scoring (override with aprocessor), and any scorer can be plugged in. - Zero dependencies. Pure stdlib — no C extension to compile.
Install
pip install larzfuzzy
Usage
from larzfuzzy import ratio, partial_ratio, token_sort_ratio, extract, extract_one, jaro_winkler
ratio("hello", "hallo") # 80
partial_ratio("york", "new york city") # 100
token_sort_ratio("new york", "york new")# 100
extract("aple", ["apple", "maple", "grape"], limit=2) # [('apple', 89), ('maple', 67)]
extract_one("marhta", names, scorer=lambda a, b: int(jaro_winkler(a, b) * 100))
Tests
python -m unittest discover -s tests -v # 13 tests
The Larz stack
One of 30+ pure-Python, zero-dependency libraries at github.com/larz-scripter — pairs with larzsearch.
License
MIT © larz-scripter
Metadata
Release files for larzfuzzy 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| larzfuzzy-0.1.0.tar.gz | 5.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| larzfuzzy-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.7 kB
Release files / larzfuzzy-0.1.0.tar.gz
| Download URL | larzfuzzy-0.1.0.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ed5c2b8e173ac88db4acbf929ea531f6c8d5c0e91f7c5bda2a31d9275c5a03ae
|
|
BLAKE2b-256 checksum How to use checksums |
eb30ca15db079cc3b6caee1830fa898b70237d2ae6857c0ea95405333a40a4ab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Release files / larzfuzzy-0.1.0-py3-none-any.whl
| Download URL | larzfuzzy-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
566276f31c22b5a3d499099395eb4bd64dd41e96b875ebb97cc928fb8ab03f45
|
|
BLAKE2b-256 checksum How to use checksums |
f5575ae41c97c6448022feee6b01c2d049ec28a7f63c4d79f3d0558c5ab4ee55
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|