This is an implementation of a simple double entendre classifier in Python.
This currently uses a Naive Bayes classifier (the NLTK implementation) as a Python package. This was inspired by the bvandenvos Ruby TWSS project and uses the same data corpus.
This was built on the eve of Barcamp Mumbai 8 and presented during a session there.
Suggestions welcome. Do file bugs. Fork away. Send us pull requests.
Setup Instructions
$ virtualenv --no-site-packages --distribute venv
$ source venv/bin/activate
$ pip install -r requirements.txt
This creates a virtual environment for this project and install all the packages necessary for the project to work.
Demo
Once this is installed, you can take it out for a spin:
>>> from twss import TWSS
>>> twss = TWSS()
>>> twss("That was hard")
True
>>> twss("Hello world")
False
The first call can take a while- the module needs to train the classifier against the pre-installed training dataset.
Getting dirty
You can supply your own training data using positive and negative corpus files:
>>> twss = TWSS(positive_corpus_file=open('foo.txt'), negative_corpus_file=open('bar.txt'))
or directly, as a list of tuples:
>>> training_data = [
... ("Sentence 1", True),
... ("Sentence 2", False),
...
... ]
>>> twss = TWSS(training_data)
Roadmap
Making this pip-installable.
Writing a sample web app.
Writing a sample Twitter client.
Release files for twss 0.1.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| twss-0.1.8.tar.gz | 169.9 kB | Details |
Release files / twss-0.1.8.tar.gz
| Download URL | twss-0.1.8.tar.gz |
|---|---|
| Size | 169.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
894903c067e089d3eb29c2ff0bd36c200e16267739795aad08d36751959374d0
|
|
BLAKE2b-256 checksum How to use checksums |
5cb2202221d65dde15df4c31d7997ee1b020d2dec97ba14bd463a0fe565b2d7c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |