Sentiment analysis refers to procedures of finding whether a specified part of text is positive, negative, or neutral. This technique is frequently considered to find out how people think about a particular situation. It evaluates the sentiments of consumers in different forms, such as advertising campaigns, social media, and e-commerce customers.
Analyzing the sentiment of a sentence
How to do it...
- Create a new file and import the chosen packages:
import nltk.classify.util
from nltk.classify import NaiveBayesClassifier
from nltk.corpus import movie_reviews
- Describe a function to extract features:
def collect_features(word_list):
word = []
return dict ([(word, True) for word in word_list])
- Adopt movie reviews in NLTK...