This is a module for the characterization and quantification of concise humour using 10 distinct computational features. These features were inspired by Ritchie's Incongruity-Resolution Theory, and are formulated as follows:
- Obviousness (
obviousness
) - Compatibility (
compatibility
) - Inappropriateness (
inappropriateness
) - Humorous Conflict (
humorous_conflict
) - Non-humorous Conflict (
non_humorous_conflict
) - Adjective Absurdity (
adjective_absurdity
) - Humorous Noun Absurdity (
humorous_noun_absurdity
) - Non-humorous Noun Absurdity (
non_humorous_noun_absurdity
) - HMM Probability (
hmm_probability
) - N-Gram Probability (
ngram_probability
)
import pyhumour
a = pyhumour.PyHumour([<humorous_corpus>], [<non_humorous_corpus>])
a.fit()
a.obviousness('this is an obvious statement')
Run the following to install:
pip install pyhumour
To install pyhumour, along with the tools you need to develop and run tests, run the following in your virtualenv:
pip install -e .[dev]
python setup.py bdist_wheel
python setup.py sdist
pip install twine
twine upload dist/*
twine upload --repository testpypi dist/*
pip install tox
tox
Use the following command inside of git root directory to run the unit tests:
nosetests -w ./ --with-coverage --cover-html --cover-package=./ --cover-erase --with-timer --timer-top-n 10
A folder called cover
will be created in src
post running the
command. You can open cover/index.html
to view the lines (if any)
that need to be additionally covered in the unit tests.