# 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.
```python
>>> 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`
```bash
python -m pip install huntela
```
## Reference
### Parameters
Each of the search methods take in three (3) parameters.
1. `term`: The term being searched for.
2. `items`: The items parameter could then be a iterable of the supported term types.
3. `key` (Optional): Only to be specified if the `term` is a `dict`. In which case, the `key` will be used to pick the corresponding values from the list of `items`.
### Supported Types
#### Term
The term being searched for could be one of the following supported types:
1. `int`
2. `float`
3. `str`
4. `dict[str, Any]`
#### Items
The items parameter could then be a iterable of the supported term types. That is,
1. `List[int]`
2. `List[float]`
3. `List[str]`
4. `List[Dict[str, str]]`
#### Results
Each search result is a `dict` which contains the following item:
1. `confidence`: A number from `0.0` to `1.0` that indicates the degree of relevance of the search match.
2. `value`: The specific item that matched the search criteria.
3. `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.
```python
>>> 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.
```python
>>> 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.
```python
>>> 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.
```python
>>> 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}
]
```
Raw data
{
"_id": null,
"home_page": "https://github.com/CodeLexis/huntela",
"name": "huntela",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.9, <4",
"maintainer_email": "",
"keywords": "python,search,query",
"author": "Tomisin Abiodun",
"author_email": "decave.12357@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/59/b6/d242b647df7a41b4f896ed3c7cb503efe3b7b19316e521c10364a3eac93b/huntela-0.0.18.tar.gz",
"platform": null,
"description": "# Huntela\n**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.\n\n```python\n>>> import huntela\n>>> \n>>> huntela.fuzzy_search(term='app', items=['app', 'paper', 'hello', 'world'])\n[\n {'confidence': 1, 'index': 0, 'value': 'app'},\n {'confidence': 0.6, 'index': 1, 'value': 'paper'}\n]\n>>> \n>>> huntela.binary_search(term='a', items=['a', 'b', 'c'])\n{'confidence': 1, 'index': 0, 'value': 'a'}\n>>> \n>>> huntela.search_for_least_frequent_items(size=1, ['a', 'b', 'a', 'e', 'a', 'e'])\n[\n {'confidence': 1, 'index': [1], 'value': 'b'}\n]\n>>> \n>>> huntela.search_for_most_frequent_items(size=2, ['a', 'b', 'a', 'e', 'a', 'e'])\n[\n {'confidence': 1, 'value': 'a', 'index': [0, 2, 4]},\n {'confidence': 1, 'value': 'e', 'index': [3, 5]}\n]\n```\n\nWith a variety of algorithms to choose from, finding what you're looking for has never been easier.\n\nFrom binary search to linear search and more, Huntela has everything you need to \nquickly and efficiently search through your data. With a simple, intuitive interface\nand lightning-fast performance, Huntela is the go-to package for anyone who needs to search through data.\n\nWhether you're a data scientist, engineer, or developer, Huntela will help you find what you need.\n\n## Installation\n\n> Huntela officially supports Python 3.9 upwards. \n\nHuntela is available on PyPi and it can be installed using `pip`\n\n```bash\npython -m pip install huntela\n```\n\n## Reference\n\n### Parameters\n\nEach of the search methods take in three (3) parameters.\n1. `term`: The term being searched for.\n2. `items`: The items parameter could then be a iterable of the supported term types.\n3. `key` (Optional): Only to be specified if the `term` is a `dict`. In which case, the `key` will be used to pick the corresponding values from the list of `items`.\n\n### Supported Types\n\n#### Term\n\nThe term being searched for could be one of the following supported types:\n\n1. `int`\n2. `float`\n3. `str`\n4. `dict[str, Any]`\n\n#### Items\n\nThe items parameter could then be a iterable of the supported term types. That is,\n\n1. `List[int]`\n2. `List[float]`\n3. `List[str]`\n4. `List[Dict[str, str]]`\n\n#### Results\n\nEach search result is a `dict` which contains the following item:\n\n1. `confidence`: A number from `0.0` to `1.0` that indicates the degree of relevance of the search match.\n2. `value`: The specific item that matched the search criteria.\n3. `index`: The position, or a list of positions where the search term was found.\n\n### Methods\n\n`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.\n\n```python\n>>> huntela.fuzzy_search(term='app', items=['app', 'paper', 'hello', 'world'])\n[\n {'confidence': 1, 'index': 0, 'value': 'app'},\n {'confidence': 0.6, 'index': 1, 'value': 'paper'}\n]\n```\n\n`binary_search(term, items, key=None) -> List[Result]`: Performs a binary search on a list to find a target value.\n\n```python\n>>> huntela.binary_search(\n term='Alex',\n items=[{'name': 'Alex'}, {'name': 'Mike'}, {'name': 'John'}],\n key='name'\n)\n{'confidence': 1, 'index': 0, 'value': 'Ade'}\n```\n\n`search_for_least_frequent_items`: Finds the k least frequent item(s) in a list.\n\n```python\n>>> search_for_least_frequent_items(size, items)\n[\n {'confidence': 1, 'index': [0], 'value': 1},\n {'confidence': 1, 'index': [2, 3], 'value': 3}\n]\n```\n\n`search_for_most_frequent_items`: Finds the k most frequent item(s) in a list.\n\n```python\n>>> search_for_most_frequent_items(2, [1, 2, 2, 3, 3, 3])\n[\n {'confidence': 1, 'index': [3, 4, 5], 'value': 3},\n {'confidence': 1, 'index': [1, 2], 'value': 2}\n]\n```\n\n\n",
"bugtrack_url": null,
"license": "",
"summary": "Find what you're looking for in a flash with Huntela.",
"version": "0.0.18",
"split_keywords": [
"python",
"search",
"query"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d42067936556351b1f6d8024988ecb54efb258f10bd7958d563a6037ce5df85f",
"md5": "7cd23c666c6bcc9953893648e3737ce1",
"sha256": "252c617c97cdc792f4a17fdb69749de533071f24914fdc823cab3131ff3fa43e"
},
"downloads": -1,
"filename": "huntela-0.0.18-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7cd23c666c6bcc9953893648e3737ce1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9, <4",
"size": 8304,
"upload_time": "2023-03-26T19:09:38",
"upload_time_iso_8601": "2023-03-26T19:09:38.718866Z",
"url": "https://files.pythonhosted.org/packages/d4/20/67936556351b1f6d8024988ecb54efb258f10bd7958d563a6037ce5df85f/huntela-0.0.18-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "59b6d242b647df7a41b4f896ed3c7cb503efe3b7b19316e521c10364a3eac93b",
"md5": "e54ba08d07c5cdb580573df22ebfa794",
"sha256": "ac4ba40bbdcb819fb88f881a16c040a1234ad8104073b027c2f69e5cc2640949"
},
"downloads": -1,
"filename": "huntela-0.0.18.tar.gz",
"has_sig": false,
"md5_digest": "e54ba08d07c5cdb580573df22ebfa794",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9, <4",
"size": 7939,
"upload_time": "2023-03-26T19:09:41",
"upload_time_iso_8601": "2023-03-26T19:09:41.034377Z",
"url": "https://files.pythonhosted.org/packages/59/b6/d242b647df7a41b4f896ed3c7cb503efe3b7b19316e521c10364a3eac93b/huntela-0.0.18.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-03-26 19:09:41",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "CodeLexis",
"github_project": "huntela",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "huntela"
}