Text sentiment analysis with textblob
Sentiment Analysis can help us decipher the mood and emotions of general public and gather insightful information regarding the context. Sentiment Analysis is a process of analyzing data and classifying it based on the need of the research.
!pip install textblob
from textblob import TextBlob
from IPython.display import display, HTML
blob = TextBlob(text_blob)
Sentiment analysis
Write your text here:
input_1
def polarity_to_text(blob):
if (blob.sentiment.polarity > 0.1):
return 'Polarity is positive 😊'
elif(blob.sentiment.polarity <= 0.1 and blob.sentiment.polarity >= -0.1):
return 'Polarity is neutral 😐'
else:
return 'Polarity is negative 😡'
def subjecitivity_to_text(blob):
if (blob.sentiment.subjectivity > 0.1):
return 'Sentence is objective 👨🏫'
elif(blob.sentiment.subjectivity <= 0.1 and blob.sentiment.subjectivity >= -0.1):
return 'Sentence is is neutral 😐'
else:
return 'Sentence is subjective 👀'
HTML(f'''<h3>{polarity_to_text(blob)}</h3>
<h3>{subjecitivity_to_text(blob)}</h3>''')
print(f'Raw output: {blob.sentiment}')
Raw output: Sentiment(polarity=0.0, subjectivity=0.0)