API
Note
A version of this documentation can also be viewed via python’s built-in
helpfunction.To simplify this documentation,
Iteris being used as an alias oflist|tuple|set. There is no explicit reference toIterin thefuzzquerypackage.
fuzzquery consists of 3 generator functions for performing searches.
- finditer -> Iterator
yields all matches of 1
query- findall -> Iterator
joins an
Iterof queries by OR, and yields consecutivematches- iterall -> Iterator
loops over an
Iterofqueries, callingfinditeron them, and yielding all results
finditer
Yield all (
span,match) of a single query.
arg |
description |
type |
|---|---|---|
text |
the text to search |
str |
query |
the |
str |
skip |
|
Iter|None |
ci |
case-insensitive matching (default: False) |
bool |
import fuzzquery as fq
...
# skip and ci are shown as their default value
for span, match in fq.finditer(text, query, skip=None, ci=False):
...
findall
Join
queriesby OR, and yield all (span,match) of “whatever-is-next”.
arg |
description |
type |
|---|---|---|
text |
the text to search |
str |
queries |
queries to combine for “whatever-is-next” search |
Iter |
skip |
|
Iter|None |
ci |
case-insensitive matching (default: False) |
bool |
import fuzzquery as fq
...
# skip and ci are shown as their default value
for span, match in fq.findall(text, queries, skip=None, ci=False):
...
iterall
Yield all (
query,span,match) of 1 or morequeries.
arg |
description |
type |
|---|---|---|
text |
the text to search |
str |
queries |
queries to combine for “whatever-is-next” search |
Iter |
skip |
|
Iter|None |
ci |
case-insensitive matching (default: False) |
bool |
import fuzzquery as fq
...
# skip and ci are shown as their default value
for query, span, match in fq.iterall(text, queries, skip=None, ci=False):
if query:
print(query)
Note
It could take numerous iterations to complete a single query. To indicate that query has changed, every new query only has a value on it’s first match.