Skip to main content

joke tools

Project description

image

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

ha-0.0.9.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ha-0.0.9-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file ha-0.0.9.tar.gz.

File metadata

  • Download URL: ha-0.0.9.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.13

File hashes

Hashes for ha-0.0.9.tar.gz
Algorithm Hash digest
SHA256 96fd8b4d85899470c03a351bff257ab654fcd324d320834eecb5f9e7974876c2
MD5 48126027f69b457066cc0e795b66c0c9
BLAKE2b-256 2653fae8f2a2971443f67b5dfbaeac3dca94cedbd533061d5e3ee0c40c10cd9e

See more details on using hashes here.

File details

Details for the file ha-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: ha-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.13

File hashes

Hashes for ha-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 9d0e4d189d75ab261dab202fdadf31dea8c23f30a01a3267647123faa72ead9d
MD5 837a7cb14a46059a15edc7a56cba8280
BLAKE2b-256 ce497c9b96b465587b2cb749b4642458f915b6caa514aea800837f6ec038ceca

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page