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

后端 未结 5 1102
鱼传尺愫
鱼传尺愫 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 03:51

    fdist1 = FreqDist(NSmyText)

    vocab=fdist1.keys()

    This code is using in Python2.7. So you should do some change. dic.keys() returns an iteratable. So using:

    list(fdist1.keys())

提交回复
热议问题