Skip to main content

Python bindings for the Rust fuzzy-aho-corasick crate.

Project description

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 fuzzy search, split, and text segmentation helpers
  • Build a fuzzy replacer from (pattern, replacement) pairs

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)

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!"

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

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.

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.

Project details


Download files

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

Source Distribution

fuzzy_aho_corasick_rs-0.1.0.tar.gz (2.2 MB view details)

Uploaded Source

Built Distributions

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

fuzzy_aho_corasick_rs-0.1.0-cp39-abi3-win_amd64.whl (255.8 kB view details)

Uploaded CPython 3.9+Windows x86-64

fuzzy_aho_corasick_rs-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (404.6 kB view details)

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

fuzzy_aho_corasick_rs-0.1.0-cp39-abi3-macosx_11_0_arm64.whl (374.7 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: fuzzy_aho_corasick_rs-0.1.0.tar.gz
  • Upload date:
  • Size: 2.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for fuzzy_aho_corasick_rs-0.1.0.tar.gz
Algorithm Hash digest
SHA256 47f67011de4c0c9e951ce4b8485eb0d0ce5bb425ec7e965210133b86b04bafa8
MD5 2b9eecb520e4e5c6779e90de8f7deaf4
BLAKE2b-256 c7c82ed844be61b8aea6b680a3e60416c713e5fa4e831616db8134f6aa0c72c8

See more details on using hashes here.

Provenance

The following attestation bundles were made for fuzzy_aho_corasick_rs-0.1.0.tar.gz:

Publisher: release.yml on vineel7871/fuzzy-aho-corasick-rs

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

File details

Details for the file fuzzy_aho_corasick_rs-0.1.0-cp39-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for fuzzy_aho_corasick_rs-0.1.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 8b467a35137cf74c790cb0ed935cdbe1c0e8efa91e220a81fc87d80ee29c42a1
MD5 b78215ebeec7245520e8f211609fb04d
BLAKE2b-256 e9d74acb83354fb9daba1438f0af46cb3446267c88dd1a5b33d5b0eae884eb55

See more details on using hashes here.

Provenance

The following attestation bundles were made for fuzzy_aho_corasick_rs-0.1.0-cp39-abi3-win_amd64.whl:

Publisher: release.yml on vineel7871/fuzzy-aho-corasick-rs

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

File details

Details for the file fuzzy_aho_corasick_rs-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fuzzy_aho_corasick_rs-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d98cfd307ec01771fda406169704db4f184e4030d1c70fe41efa9baa9636a8ad
MD5 23905015a63ae32bab0df554cf0dc432
BLAKE2b-256 14ee462f24db1e63f1d8048bc10e39d1f60436645c37e10bf2dc184dcb5ed084

See more details on using hashes here.

Provenance

The following attestation bundles were made for fuzzy_aho_corasick_rs-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on vineel7871/fuzzy-aho-corasick-rs

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

File details

Details for the file fuzzy_aho_corasick_rs-0.1.0-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fuzzy_aho_corasick_rs-0.1.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2127e8890e1979cff8c78c9aba12d0ad8f15b6b321d6f05c631768376a08a9e3
MD5 f362ea286eb6f7623d7fc6875ea070dd
BLAKE2b-256 1feefc384c5cad72ac07cf3dc982ec6813606f053215f167368004a45ab1d83d

See more details on using hashes here.

Provenance

The following attestation bundles were made for fuzzy_aho_corasick_rs-0.1.0-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on vineel7871/fuzzy-aho-corasick-rs

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