Skip to main content

PyJoke is a package for fetching the perfect joke in a database. You give a sentence, you get a joke. Isn’t that great? Common usage is:

#!/usr/bin/python
# -*- coding: utf-8 -*-

from pyjoke.PyJoke import *

s = "Sentence with keywords"

p = PyJoke()

p.changeParams()
p.changeDatabase("SoftJokes.db","jokesfr",True)
p.changeDatabase("HardJokes.db","jokes_fr_cat",False)

if p.params.conv==0:
    print p.getTheJoke(s)
else:
    for i in range(p.params.conv):
        s = p.getTheJoke(s)
        print "Personne "+str((i%2)+1)+" dit : "+s

PyJoke has been developed for as a NAO module (in French), but can also work as a standalone. It should be possible to make it work in English.

How does it work?

  • Give a sentence to PyJoke (see script above)

  • PyJoke will analyse the sentence

  • First, create a keywords list (by removing stopwords)

  • If POSTAG is active, it will add a score to each kword

  • Then, create a query, connect to database and send query

  • The query (above) is meant to filter the jokes It will get the jokes with at least 1 keyword

  • Then, score each joke

  • And return the best one

What can the user change?

  • Config a MySQL or a SQLite database

  • Use of Postag (and the scores)

  • NAO mode

  • Language (French by default)

  • Maximum joke length

  • Conversation mode (experimental)

Database format

The joke database needs to have two fields at least:

  • text

  • score

Text being the joke itself, and score being an arbitrary score that’s not going to be used, really (should do that…)

Useful libs and dependencies

PyJoke has dependencies, some are optional

  • NTLK

  • SQLite (or MySQL)

  • YAML

  • TreeTagger (opt)

  • /usr/lib/sqlite3/pcre.so (opt)

Metadata

Release files for PyJoke 0.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PyJoke 0.3.3
File Size Uploaded Provenance
PyJoke-0.3.3.tar.gz 326.5 kB Without provenance Details

Release files / PyJoke-0.3.3.tar.gz

Download URL PyJoke-0.3.3.tar.gz
Size 326.5 kB
Tags Source
SHA-256 checksum
How to use checksums
545ef4ad3c3c25713db01e48f36add7af32d8b10eea262dce9cb6e0a2df14aec
BLAKE2b-256 checksum
How to use checksums
5201f0ad0da5b9f93d3ea0bceae53c4b6e9136591639757feb1bd6a7b31516af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for PyJoke 0.3.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page