Last active
September 2, 2020 19:31
-
-
Save josht-jpg/1a6f3f94bf152f8d6ee5c77e822c7524 to your computer and use it in GitHub Desktop.
beginning with AFINN
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
from afinn import Afinn | |
afinn = Afinn() | |
def afinn_context(book_bigrams): | |
book_bigrams['score'] = book_bigrams['word2'].apply(afinn.score) | |
book_bigrams['score'] = book_bigrams.apply( | |
lambda x: x['score'] * -1 if x['word1'] in negations else x['score'], | |
axis = 1) | |
return book_bigrams | |
notes_afinn = afinn_context(notes_bigrams) | |
crime_afinn = afinn_context(crime_bigrams) | |
idiot_afinn = afinn_context(idiot_bigrams) | |
possessed_afinn = afinn_context(possessed_bigrams) | |
brothers_afinn = afinn_context(brothers_bigrams) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment