Emoji translation for Python. This project relies on previous works, like emoji, emojilib, and vaderSentiment.
The primary differentiator of this work is the incorporation of keyword alternatives to the standard unicode emoji descriptions, which result in more natural translations. The translation can also be randomized if desired.
from emoji_translate.emoji_translate import Translator
emo = Translator(exact_match_only=False, randomize=True)
# basic translation
print(emo.emojify('The house is on fire!')) # > 'The 🏠 is on 🔥!'
print(emo.demojify('The 🏠 is on 🔥!')) # > 'The house is on fire!'
# targeting sentiment
print(emo.remove_positive_emojis('That new SNL skit 😂😂')) # > 'That new SNL skit'
print(emo.add_positive_emojis('I cannot believe it!', num=1)) # > 'I cannot believe it! 💪'
print(emo.add_negative_emojis('I cannot believe it!', num=2)) # > 'I cannot believe it! 🙄😱'
print(emo.add_neutral_emojis('I cannot believe it!', num=3)) # > 'I cannot believe it! 🚝🐮🛶'
NOTE: Emoji sentiment (polarity) was computed by concatenating the emoji short_name
and keywords
and passing them all into vaderSentiment.SentimentIntensityAnalyzer
.
Via pip:
pip install emoji_translate
From master branch:
$ git clone https://github.com/fabriceyhc/emoji_translate.git
$ cd emoji_translate
$ python setup.py install
The following enhancements are planned for sometime in the future. Feel free to reach out / submit pull requests if you want to beat me to it.
- Creating a static / functional version of the package that does not require the creation of Emojify object.
- Incorporating part-of-speech (POS) information during emoji translation, possibly via spaCy.
- Using an alternative to VADER for sentiment analysis on the emojis, possibly offering a variety of options.
Fabrice Harel-Canada / @fabriceyhc