NLTK python error: “TypeError: 'dict_keys' object is not subscriptable”

后端 未结 5 1103
鱼传尺愫
鱼传尺愫 2020-12-01 03:36

I am following instructions for a class homework assignment and I am supposed to look up the top 200 most frequently used words in a text file.

Here\'s the last par

5条回答
  •  感动是毒
    2020-12-01 04:02

    Looks like you are using Python 3. In Python 3 dict.keys() returns an iterable but not indexable object. The most simple (but not so efficient) solution would be:

    vocab = list(fdist1.keys())
    

提交回复
热议问题