cherry picking https://github.com/longdt219/nltk/commit/592ba8788783bb195bdc06479ab90387cf52a0fe; cf #805
minor stylistic tweaks, resolves #805