Skip to main content

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, and extract/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. extract lowercases before scoring (override with a processor), 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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

larzfuzzy-0.1.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

larzfuzzy-0.1.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file larzfuzzy-0.1.0.tar.gz.

File metadata

  • Download URL: larzfuzzy-0.1.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for larzfuzzy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ed5c2b8e173ac88db4acbf929ea531f6c8d5c0e91f7c5bda2a31d9275c5a03ae
MD5 930768a4a60ea793f87761082fc34a27
BLAKE2b-256 eb30ca15db079cc3b6caee1830fa898b70237d2ae6857c0ea95405333a40a4ab

See more details on using hashes here.

File details

Details for the file larzfuzzy-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: larzfuzzy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for larzfuzzy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 566276f31c22b5a3d499099395eb4bd64dd41e96b875ebb97cc928fb8ab03f45
MD5 51561e9a295b7926ded55f7ed432eae5
BLAKE2b-256 f5575ae41c97c6448022feee6b01c2d049ec28a7f63c4d79f3d0558c5ab4ee55

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page