Word Count using NLP Python

Manivannan Murugavel
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))

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Manivannan Murugavel
Manivannan Murugavel

Written by Manivannan Murugavel

Artificial Intelligence and Data Science

No responses yet

Write a response