Skip to main content

Fast fuzzy string matching — Levenshtein, Jaro-Winkler, and trigram similarity. Written in Rust.

Project description

matchr

PyPI

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.0 to 1.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, and batch_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
  • levenshtein returns usize (edit distance), all others return f64 (0.0–1.0)
  • Python functions accept an optional threshold parameter — results below it are filtered out
  • batch_best_match is parallelised via rayon and pre-normalises the candidate list once, so it scales with available cores

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

matchr-0.1.3-cp38-abi3-win_amd64.whl (261.8 kB view details)

Uploaded CPython 3.8+Windows x86-64

matchr-0.1.3-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (419.3 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

matchr-0.1.3-cp38-abi3-macosx_11_0_arm64.whl (377.1 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

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

Hashes for matchr-0.1.3-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 2827870bf7a560c666af518b6c363c5c79d03bcecc20e650e5ce08701be0ce15
MD5 e7aa8e4e2952fcef0851ba679ed525c3
BLAKE2b-256 ca2d9f3b0ba55faad029dadd1947faba6a2a2784e103cc24f617fb49d53e139b

See more details on using hashes here.

Provenance

The following attestation bundles were made for matchr-0.1.3-cp38-abi3-win_amd64.whl:

Publisher: release.yml on mommo-codes/matchr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file matchr-0.1.3-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for matchr-0.1.3-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 420d34c05621b881e0a25f0e0735b413f46dbeba13109fd0c5fc99f8e704c54f
MD5 50abac43586f43fc26ea32d0ccb7ac23
BLAKE2b-256 b6bf331a2b2f176dc0ba323a6234227f27863fecce4e98b34ebd0a70cf15d980

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file matchr-0.1.3-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for matchr-0.1.3-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 28a3465c0a36a746a77a984fd84a5c8fd0911030ffb50a7becb16ef2b7e4c6ec
MD5 f8a86096297731f7dff210075b6ef455
BLAKE2b-256 b39d5a170d316d8e6ecb02cad5eb87fadb60b3ee5a5d5899c12a0eba410245ae

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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