Skip to main content

Django Bayesian inference based comment moderation app.

Project description

Django Moderator

Django Bayesian inference based comment moderation app.

django-moderator integrates Django’s comments framework with SpamBayes to automatically classify comments into three categories, ham, spam or unknown, based on previous training (see Paul Graham’s A Plan for Spam for some background).

Comments classified as unknown have to be manually classified as either spam or ham via admin, thereby training the system to automatically classify similarly worded comments in future.

Comments classified as spam will have their is_removed field set to True and as such it will no longer be visible in comment listings.

Comments classified as ham will remain unchanged and as such will be visible in comment listings.

django-moderator also implements a user friendly admin interface for efficiently moderating comments.

Installation

  1. Install or add django-moderator to your Python path.

  2. Add moderator to your INSTALLED_APPS setting.

  3. Add a MODERATOR setting to your project’s settings.py file. This setting specifies what classifier storage backend to use (see below) and also classification thresholds:

    MODERATOR = {
        'CLASSIFIER': 'moderator.storage.DjangoClassifier',
        'HAM_CUTOFF': 0.3,
        'SPAM_CUTOFF': 0.7,
    }

    Specifically a HAM_CUTOFF value of 0.3 as in this example specifies that any comment scoring less than 0.3 during Bayesian inference will be classified as ham. A SPAM_CUTOFF value of 0.7 as in this example specifies that any comment scoring more than 0.7 during Bayesian inference will be classified as spam. Anything between 0.3 and 0.7 will be classified as unsure, awaiting manual user classification. HAM_CUTOFF and SPAM_CUTOFF can be ommited in which case the default cuttofs are 0.3 and 0.7 respectively.

Classifier Storage Backends

django-moderator includes two SpamBayes storage backends, moderator.storage.DjangoClassifier and moderator.storage.RedisClassifier respectively.

To use moderator.storage.RedisClassifier as your classifier storage backend specify it in your MODERATOR setting, i.e.:

MODERATOR = {
    'CLASSIFIER': 'moderator.storage.RedisClassifier',
    'CLASSIFIER_CONFIG': {
        'host': 'localhost',
        'port': 6379,
        'db': 0,
        'password': None,
    },
    'HAM_CUTOFF': 0.3,
    'SPAM_CUTOFF': 0.7,
}

You can aslo create your own backends, in which case take note that the content of CLASSIFIER_CONFIG will be passed as keyword agruments to your backend’s __init__ method.

Usage

Once correctly configured you’ll use the classifycomments management command to automatically classify comments as either ham, spam or unsure based on previous training, i.e.:

$ ./manage.py classifycomments

Unsure comments can be manually classified as either ham or spam via the Classified comments page in admin.

Authors

Praekelt Foundation

  • Shaun Sephton

Changelog

0.0.1 (2012-05-23)

  1. Initial release

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

django-moderator-0.0.1.tar.gz (10.7 kB view hashes)

Uploaded Source

Built Distribution

django_moderator-0.0.1-py2.7.egg (24.1 kB view hashes)

Uploaded Source

Supported by

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