joke tools
Project description
ha
A medley of joke datasets and tools.
To install: pip install ha
Examples
Joke datasets
List the datasets (keys):
import ha
list(ha.joke_datasets)
# ['reddit_jokes', 'stupidstuff', 'wocka']
Get a dataset. The datasets are lists of dicts.
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:
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.
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.
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:
jokes['wocka', 18199]
Joke (vendorized) tools
pyjokes
Install: pip install ha[pyjokes]
(or independently, doing pip install pyjokes
).
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
import laugh
thor_joke = laugh.NamedJokes(name='Thor')
thor_joke() # random joke
'The stock market monitors Thor.'
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!'
Project details
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 ha-0.0.8.tar.gz
.
File metadata
- Download URL: ha-0.0.8.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46319eac5477317bc492f412e095dcbc139bcc6c21b53077aa99c03d526d77b9 |
|
MD5 | cd8aa39b65ca3fc1a3326d6a0ef5be76 |
|
BLAKE2b-256 | 31c2dbea7572705cc68ffa0c389f6a306e83aa58eefaadea6411f8d8606b1001 |
File details
Details for the file ha-0.0.8-py3-none-any.whl
.
File metadata
- Download URL: ha-0.0.8-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7ecd32d5d1b821df4df780583c5e32937e8295940dbfd3fa0fea4a3495c03c2 |
|
MD5 | 53f8435442dc07a95ff41ea5aa781000 |
|
BLAKE2b-256 | ac5d0ccc5689f19bb9e859b7b8a73f9c81135f29dff4e8bdaa733aba32e9b456 |