-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetimentAnalysis.py
More file actions
63 lines (47 loc) · 2.44 KB
/
Copy pathsetimentAnalysis.py
File metadata and controls
63 lines (47 loc) · 2.44 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
analyser = SentimentIntensityAnalyzer()
def sentiment_analyzer_scores(sentence):
score = analyser.polarity_scores(sentence) # obtain polarity index of given sentence.
# produces the index of the -ve, +ve, neutral and compound sentiment
# the compound score is a sum of all lexicon ratings normalized between -1(very negative) to 1 (very positive)
print(f'{sentence} polarity scores: {score}')
sentiment_analyzer_scores("This phone is super cool")
# punctuation. ! shows a degree of intensity. This is good !!!! is more intense compared to this is good
print(">>>>>>>>>>>>>>>>>Punctuation>>>>>>>>>>>>>>>>>")
sentiment_analyzer_scores("This food is good")
sentiment_analyzer_scores("This food is good!!")
sentiment_analyzer_scores("This food is good!!!")
# capitalization. Denotes emphasis
print(">>>>>>>>>>>>>>>>>Capitalization>>>>>>>>>>>>>>>>>")
sentiment_analyzer_scores("This food is good!")
sentiment_analyzer_scores("This food is GREAT")
sentiment_analyzer_scores("This food is great")
# Degree modifiers/intensifier. Impact intensity positively or negatively
print(">>>>>>>>>>>>>>>>>Intensifiers>>>>>>>>>>>>>>>>>")
sentiment_analyzer_scores("The lunch was extremely good")
sentiment_analyzer_scores("The lunch was EXTREMELY bad")
sentiment_analyzer_scores("The lunch was marginally good")
#Conjunctions. They denote a shift in sentiment. eg but
print(">>>>>>>>>>>>>>>>>Intensifiers>>>>>>>>>>>>>>>>>")
sentiment_analyzer_scores("The lunch was extremely good")
sentiment_analyzer_scores("The lunch was EXTREMELY bad")
sentiment_analyzer_scores("The lunch was marginally good")
# preceding Tri-gram
print(">>>>>>>>>>>>>>>>>Intensifiers>>>>>>>>>>>>>>>>>")
sentiment_analyzer_scores("The lunch was extremely good")
sentiment_analyzer_scores("The lunch was EXTREMELY bad")
sentiment_analyzer_scores("The lunch was marginally good")
# Emojis
print(">>>>>>>>>>>>>>>>>Emoji>>>>>>>>>>>>>>>>>")
sentiment_analyzer_scores("I am 😄 today")
sentiment_analyzer_scores("😊")
sentiment_analyzer_scores("😥")
print(sentiment_analyzer_scores('☹️'))
# Common slang
print(">>>>>>>>>>>>>>>>>Slang>>>>>>>>>>>>>>>>>")
print(sentiment_analyzer_scores("Today SUX!"))
print(sentiment_analyzer_scores("Today only kinda sux! But I'll get by, lol"))
# Emoticon
print(">>>>>>>>>>>>>>>>>Emoticons>>>>>>>>>>>>>>>>>")
sentiment_analyzer_scores("You either feel :) or :D")
sentiment_analyzer_scores("wow. That was :(")