Wednesday, July 3, 2024
HomeLanguagesPythonPython | TextBlob.word_counts() method

Python | TextBlob.word_counts() method

With the help of TextBlob.word_counts() method, we can get the word count of a particular word in the sentence by using TextBlob.word_counts() method.

Syntax : TextBlob.word_counts()
Return : Return the count of word in a sentence.

Example #1 :
In this example we can say that by using TextBlob.word_counts() method, we are able to get the count of word in a sentence.




# import TextBlob
from textblob import TextBlob
  
gfg = TextBlob("I am confused sometime, sometime I messed up things.")
  
# using TextBlob.word_counts() method
gfg = gfg.word_counts['sometime']
  
print(gfg)


Output :

2

Example #2 :




# import TextBlob
from textblob import TextBlob
  
gfg = TextBlob("My name is Khan khan KhaN.")
  
# using TextBlob.word_counts() method
gfg = gfg.word_counts['khan']
  
print(gfg)


Output :

3

Calisto Chipfumbu
Calisto Chipfumbuhttp://cchipfumbu@gmail.com
I have 5 years' worth of experience in the IT industry, primarily focused on Linux and Database administration. In those years, apart from learning significant technical knowledge, I also became comfortable working in a professional team and adapting to my environment, as I switched through 3 roles in that time.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments