forked from subrata3112/Hack-Vsit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsent.py
More file actions
28 lines (23 loc) · 740 Bytes
/
sent.py
File metadata and controls
28 lines (23 loc) · 740 Bytes
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
27
28
from nltk.sentiment.vader import SentimentIntensityAnalyzer
from nltk import tokenize
sentences = ["It is very sad evening.",
"I can't take it anymore.",
"Its such a beautiful morning!",
"I hate my life. There is no point in living anymore.",
"Its hard to defend ourselves.",
"Its impossible to defeat the guy."]
sid = SentimentIntensityAnalyzer()
for x in sentences:
if x.count('.')>1:
lines_list = tokenize.sent_tokenize(x)
sentences.extend(lines_list)
sentences.remove(x)
positivity = 0
for x in sentences:
ss = sid.polarity_scores(x)
# print(x)
# print(type(ss))
# print(ss['pos'])
positivity+=ss['pos']
if positivity <= 2.6:
print("You seem to be depressed. Have a consultation!")