re-applied changes from https://github.com/heatherleaf/nltk/commit/c65dffdf4bf10a81aa07e508175f7818a12f5183, cf https://github.com/nltk/nltk/issues/670