A project to demonstrate maximum entropy models for extracting quotes from news articles in Python.
JavaScript Python
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Citizen Quotes

A simple project to demonstrate the use of NLTK maximum entropy models for extracting quotes from news articles. Also includes a pretty quote browser that cycles through quotes from a random selection of Bay Citizen stories.


  • A workflow and class wrapper for training, evaluating and applying NLTK maximum entropy models to quote detection.
  • A demonstration of OpenCalais for coreference detection.
  • Basic Django admin interface for training a classifier.
  • A simple public-facing quote browser interface.
  • Sample data so you can see how everything ties together.

Getting started

The demo is designed to work out of the box with an included SQLite database. To get up and running, simply:

git clone git@github.com:cirlabs/citizen-quotes.git
cd citizen-quotes
pip install -r requirements.txt
python manage.py runserver

The quote browser will be running in your browser at

Training the system

Being supervised classifiers, maxent models require a set of training data to learn from before they can begin classifying.

In this case, the classification problem is a simply binary choice: Given a paragraph, is it a quote or isn’t it? But as with most classification problems, things aren’t quite so simple under the surface.

Luckily, training the system is easy. Simple log into the system’s admin interface at The default username and password are both quotex.

Navigate to the paragraph interface. In the list view, you’ll see a dropdown that identifies an item as a quote and a checkbox indicating it should be in the training set. Simply set these values according to the each value according to its paragraph and hit save.

The more training data you have, the better the classifier will work. We’d recommend manually classifiying at least a few hundred before you set the classifier loose.

Running the classifier

The classifier is located at quotex/classify/maxent.py. Running it is easy:

python maxent.py

The first thing you’ll want to do is see how it performs. By default, the script uses your manually classified training set to test initial performance. It does this by splitting the set in half: the first half for training and the second half for testing. You can change that split in the code if you’d like.

When you’re ready to perform the actual classification, just uncomment the following line in the classifier code:



This project brought to you by Chase Davis’ nights and weekends: cdavis@cironline.org.