Python NLP
About Lesson

In this Python NLP lesson we are going to learn about NLP Frequency Distribution, using Frequency Distribution we can find that how many times a word is used in a sentence, or we can count words in our text using NLP Frequency Distribution.

 

 

Now let’s create an example, we are going to use some text from nltk.book and we want to find the frequency distribution of the words.

 

 

If you run the code in Jupyter Notebook, this will be the result.

 

 

The class FreqDist works like a dictionary where the keys are the words in the text and the values are the count associated with that word. For example, if you want to see how many words “book” are in the text, you can type:

 

 

Now let’s create our own text and find the frequency distribution, you can see that we have a simple paragraph and we want find the frequency distribution of the text word, if you run the code you will receive 2 as the result, because we have two times text word.