Guest User

Untitled

a guest
Nov 22nd, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. emoticons = [('SMILE',[':-)', ':)', '(:', '(-:']),
  2. ('LAUGH',[':-D', ':D', 'X-D', 'XD', 'xD']),
  3. ('LOVE', ['<3', ':*']),
  4. ('WINK', [';-)', ';)', ';-D', ';D', '(;', '(-;']),
  5. ('FROWN', [':-(', ':(', '(:', '(-:']),
  6. ('CRY', [':,(', ':'(', ':"(', ':(('])]
  7.  
  8.  
  9. def token_to_emot(token):
  10. for (emoji, smileys) in emoticons:
  11. if token in smileys:
  12. converted = token.replace(token, emoji)
  13. return converted
  14. else:
  15. return token
  16.  
  17. sample_tweet = ['It', 'was', 'amazing', ':)']
  18. processed_tweet = [token_to_emot(token) for token in sample_tweet]
  19. print(processed_tweet)
  20.  
  21. ['It', 'was', 'amazing', 'SMILE']
Add Comment
Please, Sign In to add comment