-
Notifications
You must be signed in to change notification settings - Fork 0
/
analyzer.py
26 lines (22 loc) · 915 Bytes
/
analyzer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import nltk
from nltk.sentiment import SentimentIntensityAnalyzer
# Create an instance of the sentiment analyzer
sia = SentimentIntensityAnalyzer()
def analyze_report(text):
# Analyze sentiment of the text
sentiment = sia.polarity_scores(text)
# Print sentiment analysis results
print("Report Analysis Results:")
print("Negative result: ", sentiment['neg']*100, "%")
print("Neutral result: ", sentiment['neu']*100, "%")
print("Positive result: ", sentiment['pos']*100, "%")
print("Compound result: ", sentiment['compound']*100, "%")
neg = sentiment['neg']
pos = sentiment['pos']
neu = sentiment['neu']
if neg > 0.5:
print("This report seems like negative. Think twice about it. ")
elif pos >= 0.5:
print("This report is positive. You are safe on it. ")
elif neu > 0.5:
print("This report is average. You can think it averagely. ")