Find parts of long text or data, allowing for some changes/typos.
Go to file
Tal Einat 77398c3f6b made make clean-build-ext-inplace find all .so files to avoid future mishaps 2014-04-20 21:38:54 +03:00
benchmarks added substitutions_only_has_near_matches_byteslike to benchmarks 2014-04-12 19:48:04 +03:00
docs additional documentation improvements (mostly examples) 2014-03-12 15:59:37 +02:00
fuzzysearch improved use and testing of C implementation of substitutions_only_lp 2014-04-20 10:38:06 +03:00
tests skipping a few tests for Ngrams search which fail due to different expected output 2014-04-20 13:28:18 +03:00
.coveragerc TracisCI and Coveralls integration WIP 2014-04-19 17:35:47 +03:00
.gitignore updated .gitignore to ignore the generate MANIFEST file 2014-04-20 13:32:42 +03:00
.travis.yml added another coverage run with Python 3.3 to TravisCI 2014-04-20 13:31:15 +03:00
AUTHORS.rst initial commit (project framework) 2013-11-02 00:34:18 +02:00
CONTRIBUTING.rst initial commit (project framework) 2013-11-02 00:34:18 +02:00
HISTORY.rst version 0.2.2 2014-03-27 15:36:43 +02:00
LICENSE Initial commit 2013-11-01 15:12:11 -07:00
MANIFEST.in initial commit (project framework) 2013-11-02 00:34:18 +02:00
Makefile made make clean-build-ext-inplace find all .so files to avoid future mishaps 2014-04-20 21:38:54 +03:00
README.rst updated README 2014-04-20 10:37:18 +03:00
nose2.cfg added C extensions and changed to single-source code 2014-04-19 01:31:32 +03:00
requirements.txt fixed requirements and working on TracisCI and Coveralls integration 2014-04-19 02:13:16 +03:00
setup.py setup.py cleanup 2014-04-20 13:40:55 +03:00
test_requirements.txt fixed requirements and working on TracisCI and Coveralls integration 2014-04-19 02:13:16 +03:00
test_requirements_py26.txt added C extensions and changed to single-source code 2014-04-19 01:31:32 +03:00
tox.ini run coverage runs both with and without extension modules 2014-04-20 14:00:34 +03:00

README.rst

===============================
fuzzysearch
===============================

.. image:: https://badge.fury.io/py/fuzzysearch.png
    :target: http://badge.fury.io/py/fuzzysearch

.. image:: https://travis-ci.org/taleinat/fuzzysearch.png?branch=master
        :target: https://travis-ci.org/taleinat/fuzzysearch

.. image:: https://coveralls.io/repos/taleinat/fuzzysearch/badge.png
        :target: https://coveralls.io/r/taleinat/fuzzysearch

.. image:: https://pypip.in/d/fuzzysearch/badge.png
        :target: https://crate.io/packages/fuzzysearch?version=latest

fuzzysearch is useful for finding approximate subsequence matches

* Free software: MIT license
* Documentation: http://fuzzysearch.rtfd.org.

Features
--------

* Fuzzy sub-sequence search: Find parts of a sequence which match a given
  sub-sequence up to a given maximum Levenshtein distance.
* Set individual limits for the number of substitutions, insertions and/or
  deletions allowed for a near-match.
* Includes optimized implementations for specific use-cases, e.g. only allowing
  substitutions in near-matches.

Simple Example
--------------
You can usually just use the `find_near_matches()` utility function, which
chooses a suitable fuzzy search implementation according to the given
parameters:

.. code:: python

    >>> from fuzzysearch import find_near_matches
    >>> find_near_matches('PATTERN', 'aaaPATERNaaa', max_l_dist=1)
    [Match(start=3, end=9, dist=1)]

Advanced Example
----------------
If needed you can choose a specific search implementation, such as
`find_near_matches_with_ngrams()`:

.. code:: python

    >>> sequence = '''\
    GACTAGCACTGTAGGGATAACAATTTCACACAGGTGGACAATTACATTGAAAATCACAGATTGGTCACACACACA
    TTGGACATACATAGAAACACACACACATACATTAGATACGAACATAGAAACACACATTAGACGCGTACATAGACA
    CAAACACATTGACAGGCAGTTCAGATGATGACGCCCGACTGATACTCGCGTAGTCGTGGGAGGCAAGGCACACAG
    GGGATAGG'''
    >>> subsequence = 'TGCACTGTAGGGATAACAAT' #distance 1
    >>> max_distance = 2

    >>> from fuzzysearch import find_near_matches_with_ngrams
    >>> find_near_matches_with_ngrams(subsequence, sequence, max_distance)
    [Match(start=3, end=24, dist=1)]