Sunday, November 17, 2024
Google search engine
HomeLanguagesPython | TextBlob.sentiment() method

Python | TextBlob.sentiment() method

With the help of TextBlob.sentiment() method, we can get the sentiments of the sentences by using TextBlob.sentiment() method.

Syntax : TextBlob.sentiment()
Return : Return the tuple of sentiments.

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




# import TextBlob
from textblob import TextBlob
  
gfg = TextBlob("GFG is a good company and always value their employees.")
  
# using TextBlob.sentiment method
gfg = gfg.sentiment
  
print(gfg)


Output :

Sentiment(polarity=0.7, subjectivity=0.6000000000000001)

Example #2 :




# import TextBlob
from textblob import TextBlob
  
gfg = TextBlob("Sandeep Jain An IIT Roorkee alumnus and founder of Lazyroar. He loves to solve programming problems in most efficient ways.")
  
# using TextBlob.sentiment method
gfg = gfg.sentiment
  
print(gfg)


Output :

Sentiment(polarity=0.5, subjectivity=0.5)

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments