source code for chapter 3 of http://nltk.org/book