Fuzzysearch is a Python library for finding approximate subsequence matches within long texts or data. It uses Levenshtein distance with configurable parameters to efficiently locate patterns even with typos or minor variations. The library is highly optimized, offering C and Cython extensions for performance while providing pure-Python fallbacks. It is currently at version 0.8.1.
pip install fuzzysearchVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to find approximate matches of a subsequence ('PATTERN') within a larger string, allowing for a maximum Levenshtein distance of 1.
Upgrade to a supported Python version (3.8+).
Understand the library's primary use case. For string comparison, use dedicated fuzzy matching libraries.
Ensure you are on version 0.7.3 or newer. Always provide appropriate string or bytes-like inputs as expected by the functions.
Pre-process your input strings (e.g., remove unwanted characters, normalize case) or use more specific matching parameters (e.g., `max_substitutions`, `max_deletions`, `max_insertions`) to control the match criteria more tightly.
Rename your local Python file or directory from 'fuzzysearch.py' or 'fuzzysearch' to something else (e.g., 'my_fuzzy_app.py') to avoid conflicting with the installed library's module name.
Always provide a limit for at least one of the Levenshtein distance components. For example: `find_near_matches('pattern', 'sequence', max_l_dist=1)` or `find_near_matches('pattern', 'sequence', max_insertions=1, max_deletions=1)`.Ensure that both the `subsequence` and `sequence` arguments passed to `find_near_matches` are non-empty. If you are on an older version, upgrading to `fuzzysearch` 0.8.1 or newer also addresses this specific issue.