title: Python: How to compute the top X most frequently used words in an NLTK corpus?
body: <p>I'm unsure if I've understood correctly how the FreqDist functions works on Python. As I am following a tutorial, I am led to believe that the following code constructs a frequency distribution for a given list of words and calculates the top x frequently used words. (In the example below let corpus be an NLTK corpus and file to be a filename of a file in that corpus)</p>
  
  <pre><code>words = corpus.words('file.txt')
  fd_words = nltk.FreqDist(word.lower() for word in words)
  fd_words.items()[:x]
  </code></pre>
  
  <p>However, when I go through the following commands on Python, it seems to suggest otherwise: </p>
  
  <pre><code>&gt;&gt;&gt; from nltk import *
  &gt;&gt;&gt; fdist = FreqDist(['hi','my','name','is','my','name'])
  &gt;&gt;&gt; fdist
  FreqDist({'my': 2, 'name':2, 'is':1, 'hi':1}
  &gt;&gt;&gt; fdist.items()
  [('is',1),('hi',1),('my',2),('name',2)]
  &gt;&gt;&gt; fdist.items[:2]
  [('is',1),('hi',1)]
  </code></pre>
  
  <p>The fdist.items()[:x] method is in fact returning the x least common words?</p>
  
  <p>Can someone tell me if I have done something wrong or if the mistake lies in the tutorial I am following?</p>