Using Emot to convert emoticons to text description
Have you ever received an emoji that you don’t know or don’t understand what is it? I know that happens to all of us. There are a lot of emojis out there which we don’t understand, using that data in creating an NLP model can result in discrepancies.
What if I tell you that you can change these emojis to text? Yes, you heard that right you can do that. It will not only be easy to understand but also make the data ready for NLP modeling.
Emot is an open-source python library which we can use to convert emoticons to text description. In this article, we will explore how to use Emot.
Let’s get started…
Installing required libraries
We will start by installing Emot using pip. The command given below will do that.
pip install emot
Importing required libraries
In this step, we will import the required library i.e. Emot.
import emot as e
Converting emojis to text
This is the final step in which we will pass some text containing emojis to the emot library and convert emojis to text.
text = "I am a coder😎"
con = e.emoji(text)
con

Here you can see how easily it converted the emoji to the text. Let’s try with some more emojis.
text = "😁😆😅😂😇🙃"
con = e.emoji(text)
con

You see how wonderful emot is, creating text out of emojis. Let’s try a last one with a very unique emoji.
text = "🤡"
con = e.emoji(text)
con

You can use this to preprocess your text data before passing it to NLP models. Go ahead try this with different emoticons and let me know your comments in the response section.
This article is in collaboration with Piyush Ingale.
Thanks for reading! If you want to get in touch with me, feel free to reach me at geekycodesco@gmail.com. You can visit us regularly for different data science projects and packages tutorials.