2

I'm relatively new to python and NLTK, but I wrote a program that used FreqDist from NLTK. It's been working as intended for the last week but today it returned: 'FreqDist' object has no attribute 'most_common'

Does anyone have any idea as to why this is? Like I said, everything was working fine prior to this and I didn't make any changes to the code.

edit: Here is the relevant code:

from nltk import FreqDist

fdist1 = FreqDist(input_list)
frequency_output = fdist1.most_common(150)

Not sure what else is necessary - the input list is a list of words. Was working fine last night...

Thank you!

stackex
  • 21
  • 3
  • Can you show the relevant code? – NathanOliver Mar 20 '15 at 16:58
  • Assuming you didn't mistype `most_common` or insert invisible characters: Either your program corrupts the `fdist1` object, or your nltk source is corrupted. Try printing `dir(fdist1)` and look for `most_common`. – alexis Mar 30 '15 at 22:27
  • @alexis I had similar problem (nltk.__version__ '2.0.5'), but the dir(fdist1) didn not contain most_common. How to fix this? – kingmakerking Jan 18 '17 at 19:10

1 Answers1

0

As long as input_list is iterable this should work fine. What is the type of input_list. Are you running this as a stand alone program ?

SanS
  • 385
  • 8
  • 21