Basic Sentiment Analysis
Learn how to perform basic sentiment analysis using Python.
- Create sentiment dictionary:
sentiment = {
'good': 1,
'bad': -1,
'great': 2,
'terrible': -2
}
- Analyze text:
def analyze(text):
words = text.lower().split()
return sum(sentiment.get(word, 0) for word in words)
- Test analysis:
print(analyze("This is a great day!"))
Read more: Sentiment Analysis