Last active
March 22, 2019 13:29
-
-
Save databrit/b5407097fcb69ab7495eaa7af1e0c8b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import time | |
from nltk.sentiment import SentimentIntensityAnalyzer | |
t0 = time.time() | |
top_100 = pd.read_csv('/Users/brit.cava/Desktop/TabPy/top100.csv') | |
text = top_100['Word'] | |
sid = SentimentIntensityAnalyzer() | |
word_score_dict = {} | |
for word in text: | |
ss = sid.polarity_scores(word) | |
word_score_dict[word]=(ss['compound']) | |
t1 = time.time() | |
total = t1-t0 | |
print(total) | |
df = pd.DataFrame(list(word_score_dict.iteritems()), columns=['word','score']) | |
df.to_csv("/Users/brit.cava/Desktop/Scores.csv", index=False, cols=('word','score')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment