Word Count using NLP Python
1 min readJan 3, 2018
Using NLTK Package
Simple Example without using file.txt
import nltk
text1 = 'hello he heloo hello hi '
text1 = text1.split(' ')
fdist1 = nltk.FreqDist(text1)
#Get 50 Most Common Words
print (fdist1.most_common(50))
Using file.txt
hello he heloo hello hi
my username is heinst
your username is frooty
python code
import nltk
with open ("input.txt", "r") as myfile:
data=myfile.read().replace('\n', ' ')
data = data.split(' ')
fdist1 = nltk.FreqDist(data)
print (fdist1.most_common(50))