Skip to content

fun with nltk and Zoolander, part 1 – concordance

I combined a few of my favorite things, mainly hacking, python, natural language, and of course, Zoolander, and it makes for some fun output.

One of my favorite features of nltk is the concordance function, which basically shows the context in which a given term is used.  It is referred to early on in the nltk book and never fails to provide entertaining output(hint: see how the word kill lines up?):

A quick Google search yielded the Zoolander script here.  From there, I copied and pasted the text and saved it as zoolander.txt.

Sprinkle in a little bit of simple python:

Here is the output for a few terms, as listed in the source code above.

See? Fun indeed. Next post, we’ll generate some random text based on lines from the movie.

One Trackback/Pingback

  1. [...] about the actual Apple product – most were comparing Steve Jobs to Newton himself. Check out my earlier post on NLTK concordance for details on how I did [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*