A lightweight package for fuzzy word/phrase searches in a body of text.
Project description
fuzzquery is a lightweight package for fuzzy word/phrase searches in a body of text. Tokens are used to determine the number and type of approximations that can be made at a token’s position, within your query.
Installation
To install fuzzquery and it’s regex dependency, use the following command-line:
pip install fuzzquery
Documentation
The official documents can be viewed at readthedocs. A version of documents can be viewed by calling python’s built-in help function on any part of the fuzzquery package.
Examples
finditer
import fuzzquery as fq
data = """
I would classify music as one of my favorite hobbies.
I love classical music played by classy musicians for a classic musical.
Beethoven can not be out-classed, music-wise - a man of class, musically gifted.
"""
query = 'class{4} music{5}'
print(f'\n{query.upper()}')
for span, match in fq.finditer(data, query, ci=True):
print(f' {match}')
print(f'\n{query.upper()} with skip')
for span, match in fq.finditer(data, query, skip=('classify', ','), ci=True):
print(f' {match}')
output:
CLASS{4} MUSIC{5}
classify music
classical music
classy musicians
classic musical
classed, music-wise
class, musically
CLASS{4} MUSIC{5} with skip
classical music
classy musicians
classic musical
iterall
import fuzzquery as fq
data = """
I headed homeward to meet with the Wardens.
When I arrived, I was greeted by a homely man that told me the homestead was awarded 5 million dollars.
We intend to use some of the homage to create a homeless ward.
The first piece of furniture will be my late-friend Homer's wardrobe.
"""
queries = ('home{5}',
'home{4} ward{4}',
'{1}ward{!2}{2}',
'hom{5} {?} wa{!1}{5}')
for query, span, match in fq.iterall(data, queries, ci=True):
if query: print(f'\n{query.upper()}')
print(f' {match}')
output:
HOME{5}
homeward
homely
homestead
homeless
Homer's
HOME{4} WARD{4}
homeless ward
Homer's wardrobe
{1}WARD{!2}{2}
Wardens
awarded
wardrobe
HOM{5} {?} WA{!1}{5}
homeward to meet with the Wardens
homely man that told me the homestead was
homage to create a homeless ward
Homer's wardrobe
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file fuzzquery-24.5.26.tar.gz
.
File metadata
- Download URL: fuzzquery-24.5.26.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e167403b13bd81ca9574b5b302ad22ca39dff75787a7ece8990d7d400480af30 |
|
MD5 | ae7e8030dc7fe0929edaea81804da915 |
|
BLAKE2b-256 | 0a09b8c5e87e4bd62ca79f0e977a5362ad2e593d862ef945f4ea14101d673b62 |
File details
Details for the file fuzzquery-24.5.26-py3-none-any.whl
.
File metadata
- Download URL: fuzzquery-24.5.26-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b97986ceac422581d5ddf6deaff2cd49cce23b40d67bfcab06b16a01768df58e |
|
MD5 | 652cde3aec67836d18c8806323c07baa |
|
BLAKE2b-256 | 2bf94512e28c4c808ce9bc74a536e5092f41435c6d6e3efbadd5ab2226d2aa52 |