-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVADERSA.py
More file actions
31 lines (22 loc) · 805 Bytes
/
VADERSA.py
File metadata and controls
31 lines (22 loc) · 805 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
29
30
31
import pandas as pd
import csv
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
with open('tweet_text.csv', "r", errors='ignore') as f:
reader = csv.reader(f)
your_list = list(reader)
analyser = SentimentIntensityAnalyzer()
def print_sentiment_scores(alist):
for aSentence in alist:
aSnt = analyser.polarity_scores(aSentence[0])
print(str(aSnt))
df_before = print_sentiment_scores(your_list)
print_sentiment_scores(your_list)
def print_sentiment_scores(alist):
polarity_scores = []
for aSentence in alist:
aSnt = analyser.polarity_scores(aSentence[0])
print(str(aSnt))
polarity_scores += [aSnt]
return polarity_scores
output_df = pd.DataFrame(print_sentiment_scores(your_list))
output_df.to_csv('SATweets.csv')