Huntela
Huntela is a savvy search module that's an alternative to the default filter method. It offers a range of powerful search functions, including fuzzy search, binary search, and searches for least/most frequent items in a list.
>>> import huntela
>>>
>>> huntela.fuzzy_search(term='app', items=['app', 'paper', 'hello', 'world'])
[
{'confidence': 1, 'index': 0, 'value': 'app'},
{'confidence': 0.6, 'index': 1, 'value': 'paper'}
]
>>>
>>> huntela.binary_search(term='a', items=['a', 'b', 'c'])
{'confidence': 1, 'index': 0, 'value': 'a'}
>>>
>>> huntela.search_for_least_frequent_items(size=1, ['a', 'b', 'a', 'e', 'a', 'e'])
[
{'confidence': 1, 'index': [1], 'value': 'b'}
]
>>>
>>> huntela.search_for_most_frequent_items(size=2, ['a', 'b', 'a', 'e', 'a', 'e'])
[
{'confidence': 1, 'value': 'a', 'index': [0, 2, 4]},
{'confidence': 1, 'value': 'e', 'index': [3, 5]}
]
With a variety of algorithms to choose from, finding what you're looking for has never been easier.
From binary search to linear search and more, Huntela has everything you need to quickly and efficiently search through your data. With a simple, intuitive interface and lightning-fast performance, Huntela is the go-to package for anyone who needs to search through data.
Whether you're a data scientist, engineer, or developer, Huntela will help you find what you need.
Installation
Huntela officially supports Python 3.9 upwards.
Huntela is available on PyPi and it can be installed using pip
python -m pip install huntela
Reference
Parameters
Each of the search methods take in three (3) parameters.
term: The term being searched for.items: The items parameter could then be a iterable of the supported term types.key(Optional): Only to be specified if thetermis adict. In which case, thekeywill be used to pick the corresponding values from the list ofitems.
Supported Types
Term
The term being searched for could be one of the following supported types:
intfloatstrdict[str, Any]
Items
The items parameter could then be a iterable of the supported term types. That is,
List[int]List[float]List[str]List[Dict[str, str]]
Results
Each search result is a dict which contains the following item:
confidence: A number from0.0to1.0that indicates the degree of relevance of the search match.value: The specific item that matched the search criteria.index: The position, or a list of positions where the search term was found.
Methods
fuzzy_search(term, items, key=None) -> List[Result]: Searches a list of items for a given search term and returns a list of results which exactly or closely match the search term.
>>> huntela.fuzzy_search(term='app', items=['app', 'paper', 'hello', 'world'])
[
{'confidence': 1, 'index': 0, 'value': 'app'},
{'confidence': 0.6, 'index': 1, 'value': 'paper'}
]
binary_search(term, items, key=None) -> List[Result]: Performs a binary search on a list to find a target value.
>>> huntela.binary_search(
term='Alex',
items=[{'name': 'Alex'}, {'name': 'Mike'}, {'name': 'John'}],
key='name'
)
{'confidence': 1, 'index': 0, 'value': 'Ade'}
search_for_least_frequent_items: Finds the k least frequent item(s) in a list.
>>> search_for_least_frequent_items(size, items)
[
{'confidence': 1, 'index': [0], 'value': 1},
{'confidence': 1, 'index': [2, 3], 'value': 3}
]
search_for_most_frequent_items: Finds the k most frequent item(s) in a list.
>>> search_for_most_frequent_items(2, [1, 2, 2, 3, 3, 3])
[
{'confidence': 1, 'index': [3, 4, 5], 'value': 3},
{'confidence': 1, 'index': [1, 2], 'value': 2}
]
Metadata
Release files for huntela 0.0.18
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| huntela-0.0.18.tar.gz | 7.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| huntela-0.0.18-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.2 kB
Release files / huntela-0.0.18.tar.gz
| Download URL | huntela-0.0.18.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ac4ba40bbdcb819fb88f881a16c040a1234ad8104073b027c2f69e5cc2640949
|
|
BLAKE2b-256 checksum How to use checksums |
59b6d242b647df7a41b4f896ed3c7cb503efe3b7b19316e521c10364a3eac93b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.13
|
Release files / huntela-0.0.18-py3-none-any.whl
| Download URL | huntela-0.0.18-py3-none-any.whl |
|---|---|
| Size | 8.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
252c617c97cdc792f4a17fdb69749de533071f24914fdc823cab3131ff3fa43e
|
|
BLAKE2b-256 checksum How to use checksums |
d42067936556351b1f6d8024988ecb54efb258f10bd7958d563a6037ce5df85f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.13
|