Created
November 26, 2019 18:30
-
-
Save rafaljanwojcik/fa4c85f22cc1fedda25f156d3715ccae 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
def replace_sentiment_words(word, sentiment_dict): | |
''' | |
replacing each word with its associated sentiment score from sentiment dict | |
''' | |
try: | |
out = sentiment_dict[word] | |
except KeyError: | |
out = 0 | |
return out | |
replaced_closeness_scores = file_weighting.title.apply(lambda x: list(map(lambda y: replace_sentiment_words(y, sentiment_dict), x.split()))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment