Skip to content

Instantly share code, notes, and snippets.

@rafaljanwojcik
Created November 26, 2019 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafaljanwojcik/fa4c85f22cc1fedda25f156d3715ccae to your computer and use it in GitHub Desktop.
Save rafaljanwojcik/fa4c85f22cc1fedda25f156d3715ccae to your computer and use it in GitHub Desktop.
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