Skip to main content

fuzzy-aho-corasick

Python bindings for the Rust fuzzy-aho-corasick crate using PyO3 and maturin.

The wrapper currently exposes the upstream crate's main global builder options and a Python-side Pattern type for per-pattern configuration:

  • Build a fuzzy matcher from a list of patterns
  • Configure per-pattern weights
  • Configure per-pattern custom unique IDs
  • Configure per-pattern fuzzy limits
  • Configure global edit limits
  • Configure global penalty weights
  • Run non-overlapping and overlapping fuzzy search, split, and text segmentation helpers
  • Build a fuzzy replacer from (pattern, replacement) pairs
  • Ship py.typed metadata and .pyi stubs for editor type hints

Python API

from fuzzy_aho_corasick import FuzzyMatcher, FuzzyReplacer, Pattern

matcher = FuzzyMatcher(
    [
        Pattern("hello", edits=1, weight=1.5, custom_unique_id=7),
        Pattern("world", substitutions=1),
    ],
    case_insensitive=True,
)

matches = matcher.search("H3llo W0rld!", threshold=0.7)
for match in matches:
    print(match.pattern, match.text, match.similarity, match.pattern_custom_unique_id)

overlap_matcher = FuzzyMatcher(["saddam", "ddamhu"], edits=1)
overlapping = overlap_matcher.search_overlapping("saddamddamhu", threshold=0.5)
assert len(overlapping) > len(overlap_matcher.search("saddamddamhu", threshold=0.5))

split_matcher = FuzzyMatcher(
    ["FOO", "BAR"],
    edits=1,
    case_insensitive=True,
)

assert matcher.search("H3llo W0rld!", threshold=0.7)[0].pattern == "hello"
assert split_matcher.split("xxFo0yyBAARzz", threshold=0.8) == ["xx", "yy", "zz"]
assert matcher.pattern_specs[0].custom_unique_id == 7

replacer = FuzzyReplacer(
    [
        (Pattern("foo", substitutions=1), "bar"),
        (Pattern("baz", custom_unique_id=2), "qux"),
    ],
    case_insensitive=True,
)

assert replacer.replace("fo0 and BAZ!", threshold=0.7) == "bar and qux!"

matcher.save("matcher.json")
loaded = FuzzyMatcher.load("matcher.json")
assert loaded.search("H3llo W0rld!", threshold=0.7)[0].pattern == "hello"

Search Modes

FuzzyMatcher.search() keeps the existing default behavior and returns non-overlapping matches unless you ask for a different strategy.

matches = matcher.search("H3llo W0rld!", threshold=0.7)

When you want overlapping matches, use the dedicated method instead of passing a string strategy:

overlapping = matcher.search_overlapping("saddamddamhu", threshold=0.5)

Overlap mode returns the full sorted upstream search result set. That means you can see additional nearby fuzzy candidates for the same pattern when they pass the threshold, not just one match per pattern.

For advanced control, search() still accepts these typed strategies:

  • "search": sorted matches with overlaps preserved
  • "non_overlapping": sorted matches with overlaps removed
  • "non_overlapping_unique": non-overlapping matches with one result per pattern or custom unique ID

The package now ships .pyi stubs together with py.typed, so editors such as Pylance can show method signatures, accepted strategy values, and return types.

Saving And Loading

FuzzyMatcher can persist its configuration to JSON with save() / load() or to_json() / from_json().

from fuzzy_aho_corasick import FuzzyMatcher, Pattern

matcher = FuzzyMatcher(
    [Pattern("invoice", edits=1), Pattern("receipt", custom_unique_id=9)],
    case_insensitive=True,
    edits=2,
)

matcher.save("matcher.json")
loaded = FuzzyMatcher.load("matcher.json")

The saved form captures the matcher configuration and recreates the Rust engine when loaded. The upstream Rust crate does not currently expose a stable serialized form for the built automaton itself.

Local development

  1. Install Rust using rustup.

  2. Install maturin: py -m pip install --upgrade maturin.

  3. Build and install the extension into your active environment:

    maturin develop
    
  4. Run tests:

    pytest
    

Build distributions

Build wheels and an sdist locally:

maturin build --release
maturin sdist

Artifacts will land under target/wheels/ or the --out directory if you set one.

Publish to PyPI

Manual publish

maturin publish --release

GitHub Actions publish

This repository includes a workflow at .github/workflows/release.yml that:

  • builds wheels on Linux, macOS, and Windows
  • builds a source distribution
  • uploads them to PyPI on tag pushes like v0.1.0
  • skips files that were already uploaded if the same workflow is rerun for the same tag

Recommended setup:

  1. Create the project on PyPI.
  2. Enable trusted publishing for your GitHub repository on PyPI.
  3. Replace the placeholder GitHub URLs in pyproject.toml.
  4. Push a version tag such as v0.1.0.

PyPI does not allow reusing the same filename for a different upload. If 0.1.0 has already been published, make the next real release a new version such as 0.1.1. The workflow only skips already-existing files so reruns do not fail after a partial publish.

Notes

  • The Python wrapper is intentionally small and focused on the upstream crate's core operations.
  • Before publishing, update the author and project URLs in pyproject.toml.

Metadata

Release files for fuzzy-aho-corasick-rs 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fuzzy-aho-corasick-rs 0.1.4
File Size Uploaded Provenance Actions
fuzzy_aho_corasick_rs-0.1.4.tar.gz 2.7 MB With provenance Details for fuzzy_aho_corasick_rs-0.1.4.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for fuzzy-aho-corasick-rs 0.1.4
File Interpreter ABI Platform Actions
fuzzy_aho_corasick_rs-0.1.4-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for fuzzy_aho_corasick_rs-0.1.4-cp39-abi3-win_amd64.whl
fuzzy_aho_corasick_rs-0.1.4-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details for fuzzy_aho_corasick_rs-0.1.4-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
fuzzy_aho_corasick_rs-0.1.4-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for fuzzy_aho_corasick_rs-0.1.4-cp39-abi3-macosx_11_0_arm64.whl

Total release size: 3.9 MB

Release files / fuzzy_aho_corasick_rs-0.1.4.tar.gz

Download URL fuzzy_aho_corasick_rs-0.1.4.tar.gz
Size 2.7 MB
Tags Source
SHA-256 checksum
How to use checksums
0caef456d1fbf2cb00607db55c349a3701e2d1fd053fe13b15f40be4eb312165
BLAKE2b-256 checksum
How to use checksums
6153742e53a55604354616353b145065c9a707d7e98d36b9a190bffb90413f35
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 7, 2026.

Transparency log

Release files / fuzzy_aho_corasick_rs-0.1.4-cp39-abi3-win_amd64.whl

Download URL fuzzy_aho_corasick_rs-0.1.4-cp39-abi3-win_amd64.whl
Size 317.9 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
db7c639ff0f521a077f0f84d55d068528093ae87404e04c125b6086648468cc8
BLAKE2b-256 checksum
How to use checksums
ad497894808508df101158b91c898ba67e6c7a653e30b16f408da0fe50b6adc3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 7, 2026.

Transparency log

Release files / fuzzy_aho_corasick_rs-0.1.4-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL fuzzy_aho_corasick_rs-0.1.4-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 470.7 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
dfc4fd811f30f11c567255a1602a918e616f5529956db6e3f6b3e8fdd10f67f4
BLAKE2b-256 checksum
How to use checksums
a631d190597ee8555524fb0281457e5ab17510320257c25a434e160bc12536f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 7, 2026.

Transparency log

Release files / fuzzy_aho_corasick_rs-0.1.4-cp39-abi3-macosx_11_0_arm64.whl

Download URL fuzzy_aho_corasick_rs-0.1.4-cp39-abi3-macosx_11_0_arm64.whl
Size 433.0 kB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
aae32c6fdeb8edbd82217696dcdc441da66b1b7596cf1102485d1e8e3ee979fb
BLAKE2b-256 checksum
How to use checksums
059180ed2d4a35eb0ae99000da021df221a37660b3c9347f292000b81d57bfcc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 7, 2026.

Transparency log

Security for fuzzy-aho-corasick-rs 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 4 files in this release have been uploaded with provenance metadata.

Select from 4 files

Attestation for fuzzy_aho_corasick_rs-0.1.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 7, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.4 This release

4 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page