<img width="350" alt="image" src="https://github.com/thorwhalen/uu/assets/1906276/9bbcee19-c28e-44d8-8769-b04fbd98efcf">
# ha
A medley of joke datasets and tools.
To install: ```pip install ha```
# Examples
## Joke datasets
List the datasets (keys):
```python
import ha
list(ha.joke_datasets)
# ['reddit_jokes', 'stupidstuff', 'wocka']
```
Get a dataset. The datasets are lists of dicts.
```python
reddit_jokes = ha.joke_datasets['reddit_jokes']
reddit_jokes[1000:1003]
```
[{'body': 'Why did the chicken cross the road? ...',
'id': '5tdwk4',
'score': 1,
'title': 'Why did the chicken cross the road?'},
{'body': 'A little boy goes to his dad and asks, ..."',
'id': '5tdssi',
'score': 123,
'title': 'What is Politics?'},
{'body': 'A teacher asked her 4th grade students a ...',
'id': '5tdsmb',
'score': 40,
'title': 'A teacher asked her students...'}]
The values of the `joke_datasets` mapping are lists of dicts containing the joke
data. For example, to list the datasets and their sizes, you'd do:
```python
print({k: len(v) for k, v in ha.joke_datasets.items()})
# {'reddit_jokes': 194553, 'stupidstuff': 3773, 'wocka': 10019}
```
Get an aggregate of all the datasets.
```python
len(jokes)
```
208345
The keys of the aggregate come as `(dataset_name, id)` pairs.
Let's look at the first two and the first last keys.
```python
print(list(jokes)[:2])
print(list(jokes)[-2:])
```
[('reddit_jokes', '5tz52q'), ('reddit_jokes', '5tz4dd')]
[('wocka', 18199), ('wocka', 18200)]
Get a joke (data) by using it's key:
```python
jokes['wocka', 18199]
```
## Joke (vendorized) tools
### pyjokes
Install: `pip install ha[pyjokes]` (or independently, doing `pip install pyjokes`).
```python
from ha.pyjokes import get_joke
get_joke() # gets a random joke, with default characteristics
```
"Two bytes meet. The first byte asks, 'Are you ill?' The second byte replies, 'No, just feeling a bit off.'"
### laugh
```python
import laugh
thor_joke = laugh.NamedJokes(name='Thor')
thor_joke() # random joke
```
'The stock market monitors Thor.'
```python
thor_joke('god') # random joke containing the word "god" (or None if none found)
```
'The guy that God prays to goes to Thor for forgiveness!'
Raw data
{
"_id": null,
"home_page": "https://github.com/thorwhalen/uu/tree/master/ha",
"name": "ha",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Thor Whalen",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/31/c2/dbea7572705cc68ffa0c389f6a306e83aa58eefaadea6411f8d8606b1001/ha-0.0.8.tar.gz",
"platform": "any",
"description": "<img width=\"350\" alt=\"image\" src=\"https://github.com/thorwhalen/uu/assets/1906276/9bbcee19-c28e-44d8-8769-b04fbd98efcf\">\n\n# ha\n\nA medley of joke datasets and tools.\n\nTo install:\t```pip install ha```\n\n# Examples\n\n## Joke datasets\n\nList the datasets (keys):\n\n```python\nimport ha\nlist(ha.joke_datasets)\n# ['reddit_jokes', 'stupidstuff', 'wocka']\n```\n\n\nGet a dataset. The datasets are lists of dicts. \n\n```python\nreddit_jokes = ha.joke_datasets['reddit_jokes']\nreddit_jokes[1000:1003]\n```\n\n [{'body': 'Why did the chicken cross the road? ...',\n 'id': '5tdwk4',\n 'score': 1,\n 'title': 'Why did the chicken cross the road?'},\n {'body': 'A little boy goes to his dad and asks, ...\"',\n 'id': '5tdssi',\n 'score': 123,\n 'title': 'What is Politics?'},\n {'body': 'A teacher asked her 4th grade students a ...',\n 'id': '5tdsmb',\n 'score': 40,\n 'title': 'A teacher asked her students...'}]\n\nThe values of the `joke_datasets` mapping are lists of dicts containing the joke \ndata. For example, to list the datasets and their sizes, you'd do:\n\n```python\nprint({k: len(v) for k, v in ha.joke_datasets.items()})\n# {'reddit_jokes': 194553, 'stupidstuff': 3773, 'wocka': 10019}\n```\n\nGet an aggregate of all the datasets.\n\n```python\nlen(jokes)\n```\n\n 208345\n\n\nThe keys of the aggregate come as `(dataset_name, id)` pairs. \nLet's look at the first two and the first last keys.\n\n```python\nprint(list(jokes)[:2])\nprint(list(jokes)[-2:])\n```\n\n [('reddit_jokes', '5tz52q'), ('reddit_jokes', '5tz4dd')]\n [('wocka', 18199), ('wocka', 18200)]\n\n\nGet a joke (data) by using it's key:\n\n```python\njokes['wocka', 18199]\n```\n\n\n## Joke (vendorized) tools\n\n### pyjokes\n\nInstall: `pip install ha[pyjokes]` (or independently, doing `pip install pyjokes`).\n\n```python\nfrom ha.pyjokes import get_joke\nget_joke() # gets a random joke, with default characteristics\n```\n\n\"Two bytes meet. The first byte asks, 'Are you ill?' The second byte replies, 'No, just feeling a bit off.'\"\n\n\n### laugh\n\n\n```python\nimport laugh\nthor_joke = laugh.NamedJokes(name='Thor')\nthor_joke() # random joke\n```\n\n 'The stock market monitors Thor.'\n\n\n```python\nthor_joke('god') # random joke containing the word \"god\" (or None if none found)\n```\n\n 'The guy that God prays to goes to Thor for forgiveness!'\n\n\n\n",
"bugtrack_url": null,
"license": "mit",
"summary": "joke tools",
"version": "0.0.8",
"project_urls": {
"Homepage": "https://github.com/thorwhalen/uu/tree/master/ha"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ac5d0ccc5689f19bb9e859b7b8a73f9c81135f29dff4e8bdaa733aba32e9b456",
"md5": "53f8435442dc07a95ff41ea5aa781000",
"sha256": "d7ecd32d5d1b821df4df780583c5e32937e8295940dbfd3fa0fea4a3495c03c2"
},
"downloads": -1,
"filename": "ha-0.0.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "53f8435442dc07a95ff41ea5aa781000",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 4684,
"upload_time": "2024-02-12T10:50:09",
"upload_time_iso_8601": "2024-02-12T10:50:09.858853Z",
"url": "https://files.pythonhosted.org/packages/ac/5d/0ccc5689f19bb9e859b7b8a73f9c81135f29dff4e8bdaa733aba32e9b456/ha-0.0.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "31c2dbea7572705cc68ffa0c389f6a306e83aa58eefaadea6411f8d8606b1001",
"md5": "cd8aa39b65ca3fc1a3326d6a0ef5be76",
"sha256": "46319eac5477317bc492f412e095dcbc139bcc6c21b53077aa99c03d526d77b9"
},
"downloads": -1,
"filename": "ha-0.0.8.tar.gz",
"has_sig": false,
"md5_digest": "cd8aa39b65ca3fc1a3326d6a0ef5be76",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4346,
"upload_time": "2024-02-12T10:50:11",
"upload_time_iso_8601": "2024-02-12T10:50:11.053277Z",
"url": "https://files.pythonhosted.org/packages/31/c2/dbea7572705cc68ffa0c389f6a306e83aa58eefaadea6411f8d8606b1001/ha-0.0.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-02-12 10:50:11",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "thorwhalen",
"github_project": "uu",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "ha"
}