apply fixes from https://github.com/jskda/nltk/commit/9e41f5286ae99e66f054118fef6213c820b2ce1d