Fast fuzzy string matching — Levenshtein, Jaro-Winkler, and trigram similarity. Written in Rust.
Project description
matchr
Fast fuzzy string matching — written in Rust, usable from Python.
Install
pip install matchr
Python quick start
from matchr import best_match, rank_matches, batch_best_match
# find the closest match
best_match("oatly oat drink", ["Oatly Oat Drink 1L", "Oat Milk", "Oatly Barista"])
# → ('Oatly Oat Drink 1L', 0.902)
# filter weak matches with a threshold
best_match("xyz gibberish", ["Oatly Oat Drink 1L"], threshold=0.7)
# → None
# match many queries at once
batch_best_match(["oatly oat drink", "felix cat food"], catalog, threshold=0.7)
# → [('Oatly Oat Drink 1L', 0.902), ('Felix Cat Food 400g', 0.843)]
Rust usage
use matchr::{levenshtein, jaro_winkler, trigram_similarity};
fn main() {
println!("{}", levenshtein("cat", "bat")); // 1
println!("{}", jaro_winkler("martha", "marhta")); // 0.961
println!("{}", trigram_similarity("hello", "helo")); // 0.4
}
Algorithms
- Levenshtein — minimum edit distance between two strings. Lower = more similar.
- Jaro-Winkler — similarity score from
0.0to1.0, optimised for names and short strings. Gives a bonus for shared prefixes. - Trigram — splits strings into overlapping 3-character chunks, scores overlap using the Dice coefficient. Good for longer strings and typo detection.
- Token sort / token set — order-invariant scorers built on top of
combined_score. Sorts (and optionally deduplicates) whitespace-separated tokens before comparing, so"Oat Drink Oatly 1L"and"Oatly Oat Drink 1L"come out equal. - Combined score — weighted blend of Levenshtein, Jaro-Winkler, and trigram. Used internally by
best_match,rank_matches, andbatch_best_match.
Benchmarks
See benchmarks/ for the criterion suite (cargo bench) and a Python comparison vs rapidfuzz. There's also a demo notebook that walks through deduping a synthetic 10k-product catalog end-to-end.
Notes
- All functions normalise input (trim + lowercase + strip diacritics) before comparing —
"Café"and"cafe"are treated as equal levenshteinreturnsusize(edit distance), all others returnf64(0.0–1.0)- Python functions accept an optional
thresholdparameter — results below it are filtered out batch_best_matchis parallelised via rayon and pre-normalises the candidate list once, so it scales with available cores
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file matchr-0.1.3-cp38-abi3-win_amd64.whl.
File metadata
- Download URL: matchr-0.1.3-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 261.8 kB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2827870bf7a560c666af518b6c363c5c79d03bcecc20e650e5ce08701be0ce15
|
|
| MD5 |
e7aa8e4e2952fcef0851ba679ed525c3
|
|
| BLAKE2b-256 |
ca2d9f3b0ba55faad029dadd1947faba6a2a2784e103cc24f617fb49d53e139b
|
Provenance
The following attestation bundles were made for matchr-0.1.3-cp38-abi3-win_amd64.whl:
Publisher:
release.yml on mommo-codes/matchr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
matchr-0.1.3-cp38-abi3-win_amd64.whl -
Subject digest:
2827870bf7a560c666af518b6c363c5c79d03bcecc20e650e5ce08701be0ce15 - Sigstore transparency entry: 1735891836
- Sigstore integration time:
-
Permalink:
mommo-codes/matchr@7195d952de3fbb8768cf1d343c454dccbc419b2d -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/mommo-codes
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7195d952de3fbb8768cf1d343c454dccbc419b2d -
Trigger Event:
push
-
Statement type:
File details
Details for the file matchr-0.1.3-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: matchr-0.1.3-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 419.3 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
420d34c05621b881e0a25f0e0735b413f46dbeba13109fd0c5fc99f8e704c54f
|
|
| MD5 |
50abac43586f43fc26ea32d0ccb7ac23
|
|
| BLAKE2b-256 |
b6bf331a2b2f176dc0ba323a6234227f27863fecce4e98b34ebd0a70cf15d980
|
Provenance
The following attestation bundles were made for matchr-0.1.3-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on mommo-codes/matchr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
matchr-0.1.3-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
420d34c05621b881e0a25f0e0735b413f46dbeba13109fd0c5fc99f8e704c54f - Sigstore transparency entry: 1735891864
- Sigstore integration time:
-
Permalink:
mommo-codes/matchr@7195d952de3fbb8768cf1d343c454dccbc419b2d -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/mommo-codes
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7195d952de3fbb8768cf1d343c454dccbc419b2d -
Trigger Event:
push
-
Statement type:
File details
Details for the file matchr-0.1.3-cp38-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: matchr-0.1.3-cp38-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 377.1 kB
- Tags: CPython 3.8+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28a3465c0a36a746a77a984fd84a5c8fd0911030ffb50a7becb16ef2b7e4c6ec
|
|
| MD5 |
f8a86096297731f7dff210075b6ef455
|
|
| BLAKE2b-256 |
b39d5a170d316d8e6ecb02cad5eb87fadb60b3ee5a5d5899c12a0eba410245ae
|
Provenance
The following attestation bundles were made for matchr-0.1.3-cp38-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on mommo-codes/matchr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
matchr-0.1.3-cp38-abi3-macosx_11_0_arm64.whl -
Subject digest:
28a3465c0a36a746a77a984fd84a5c8fd0911030ffb50a7becb16ef2b7e4c6ec - Sigstore transparency entry: 1735891855
- Sigstore integration time:
-
Permalink:
mommo-codes/matchr@7195d952de3fbb8768cf1d343c454dccbc419b2d -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/mommo-codes
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7195d952de3fbb8768cf1d343c454dccbc419b2d -
Trigger Event:
push
-
Statement type: