puilp0502 / fzypy

A fuzzy finder in Python, based on fzy

Home Page:https://pypi.org/project/fzypy/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fzypy

A fuzzy finder in Python, based on fzy

Installation

pip install fzypy

To build manually:

git clone --recurse-submodules https://github.com/puilp0502/fzypy.git
cd fzypy
python setup.py install

Usage

Fuzzy searching:

from fzy import search
entries = [
    "src/choices.c",
    "src/choices.h",
    "src/match.c",
    "src/match.h",
]
search("s/c.c", entries)
# [('src/choices.c', 2.82), ('src/match.c', 1.8399999999999999)]

Search results are ordered in descending order, by score.

When running multiple searches against same set of candidates, use Choice object:

from fzy import Choice

entries = [
    "src/choices.c",
    "src/choices.h",
    "src/match.c",
    "src/match.h",
]
choicer = Choice()
for entry in entries:
    choicer.add(entry)

choicer.search("s/c.c")
# [('src/choices.c', 2.82), ('src/match.c', 1.8399999999999999)]
choicer.search("s/m.c")
# [('src/match.c', 2.84)]

Calculating score:

from fzy import match
match("s/c", "src/choices.c")
# 1.8400000000000007

About

A fuzzy finder in Python, based on fzy

https://pypi.org/project/fzypy/

License:MIT License


Languages

Language:Python 95.3%Language:Shell 4.7%