Fuzzysearch

0.8.1 · active · verified Sun Apr 12

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.

Warnings

Install

Imports

Quickstart

This example demonstrates how to find approximate matches of a subsequence ('PATTERN') within a larger string, allowing for a maximum Levenshtein distance of 1.

from fuzzysearch import find_near_matches

# Search for 'PATTERN' with a maximum Levenshtein Distance of 1
matches = find_near_matches('PATTERN', '---PATERN---', max_l_dist=1)

for match in matches:
    print(f"Found match: '{match.matched}' at index {match.start}-{match.end} with distance {match.dist}")

view raw JSON →