Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- emoticons = [('SMILE',[':-)', ':)', '(:', '(-:']),
- ('LAUGH',[':-D', ':D', 'X-D', 'XD', 'xD']),
- ('LOVE', ['<3', ':*']),
- ('WINK', [';-)', ';)', ';-D', ';D', '(;', '(-;']),
- ('FROWN', [':-(', ':(', '(:', '(-:']),
- ('CRY', [':,(', ':'(', ':"(', ':(('])]
- def token_to_emot(token):
- for (emoji, smileys) in emoticons:
- if token in smileys:
- converted = token.replace(token, emoji)
- return converted
- else:
- return token
- sample_tweet = ['It', 'was', 'amazing', ':)']
- processed_tweet = [token_to_emot(token) for token in sample_tweet]
- print(processed_tweet)
- ['It', 'was', 'amazing', 'SMILE']
Add Comment
Please, Sign In to add comment