merging https://github.com/nltk/nltk/pull/485, with minor fixes as discussed by @kmike and @nschneid
merging https://github.com/nltk/nltk/pull/485, with minor fixes as discussed by @kmike and @nschneid

nltk/nltk,nltk/nltk,nltk/nltk