conditional frequency distribution nltk
Question: I'm a complete newbie and learning to use python using the natural language
toolkit. I have been trying to analyze a text in terms of most common words in
it. Specifically, I am trying to make a graph of the most frequent long words
(more than 6 letters) in it. Could anyone suggest how to tweak the Cumulative
Frequency Plot fdist.plot(cumulative=False) so it works only with long words?

thank you!


Answer: After tokenizing your word list, eliminate the undesired words with len() in a
list comprehension.

    
    
    from nltk import word_tokenize
    tokens = word_tokenize(input_string)
    
    long_words = [x for x in tokens if len(x) > 7]
    

Perform your analysis using this new list of tokens. Check out [this
page](http://www.nltk.org/book/ch01.html) for a more extensive explanation.

