Name: Towards AI Legal Name: Towards AI, Inc. Description: Towards AI is the world's leading artificial intelligence (AI) and technology publication. Read by thought-leaders and decision-makers around the world. Phone Number: +1-650-246-9381 Email: [email protected]
228 Park Avenue South New York, NY 10003 United States
Website: Publisher: https://towardsai.net/#publisher Diversity Policy: https://towardsai.net/about Ethics Policy: https://towardsai.net/about Masthead: https://towardsai.net/about
Name: Towards AI Legal Name: Towards AI, Inc. Description: Towards AI is the world's leading artificial intelligence (AI) and technology publication. Founders: Roberto Iriondo, , Job Title: Co-founder and Advisor Works for: Towards AI, Inc. Follow Roberto: X, LinkedIn, GitHub, Google Scholar, Towards AI Profile, Medium, ML@CMU, FreeCodeCamp, Crunchbase, Bloomberg, Roberto Iriondo, Generative AI Lab, Generative AI Lab Denis Piffaretti, Job Title: Co-founder Works for: Towards AI, Inc. Louie Peters, Job Title: Co-founder Works for: Towards AI, Inc. Louis-François Bouchard, Job Title: Co-founder Works for: Towards AI, Inc. Cover:
Towards AI Cover
Logo:
Towards AI Logo
Areas Served: Worldwide Alternate Name: Towards AI, Inc. Alternate Name: Towards AI Co. Alternate Name: towards ai Alternate Name: towardsai Alternate Name: towards.ai Alternate Name: tai Alternate Name: toward ai Alternate Name: toward.ai Alternate Name: Towards AI, Inc. Alternate Name: towardsai.net Alternate Name: pub.towardsai.net
5 stars – based on 497 reviews

Frequently Used, Contextual References

TODO: Remember to copy unique IDs whenever it needs used. i.e., URL: 304b2e42315e

Resources

Take our 85+ lesson From Beginner to Advanced LLM Developer Certification: From choosing a project to deploying a working product this is the most comprehensive and practical LLM course out there!

Publication

Emoticon and Emoji in Text Mining
Latest   Machine Learning

Emoticon and Emoji in Text Mining

Last Updated on July 20, 2023 by Editorial Team

Author(s): Dhilip Subramanian

Originally published on Towards AI.

Converting Emoticon and Emoji into word form using Python

Source: wallpaperplay

In today’s online communication, emojis and emoticons are becoming the primary language that allows us to communicate with anyone globally when you need to be quick and precise. Both emoji and emoticons are playing an essential part in text analysis.

Both Emoji and Emoticon are most often used in social media, emails, and text messages, though they may be found in any type of electronic communication. On the one hand, we might need to remove for some of our textual analysis. On the other hand, we need to retain as these give some valuable information, especially in Sentiment Analysis and removing them might not be a right solution.

For example, if a company wants to find out how people are feeling about a new product, a new campaign, or about the brand itself on social media. Emojis can help identify where there is a need to improve consumer engagement by picturing users’ moods, attitudes, and opinions. We can capture people’s emotions by analyzing emojis and emoticons. This will provide an essential piece of information, and it is vital for companies to understand their customer’s feelings better.

Collecting and analyzing data on emojis as well as emoticons give companies useful insights. Hence, we will convert these into word format so they can be used in modeling processes. In this blog, we will see how to save both emoji and emoticon into word form using python.

What is an Emoji? U+1F642 U+1F641

An emoji is an image small enough to insert into text that expresses an emotion or idea. The word emoji essentially means β€œpicture-character” (from Japanese e β€” β€œpicture,” and moji β€” β€œletter, character”).

What is an Emoticon? πŸ™‚ :-]

An emoticon is a representation of a human facial expression using only keyboard characters such as letters, numbers, and punctuation marks.

Here, I have used a library called emot. For more details on this library, please check this Github repo. It has a good collection of emoticons and emojis with the corresponding words. I have used the same to convert the emojis and emoticons into words.

Code

#Installing emot library
!pip install emot
#Importing libraries
import re
from emot.emo_unicode import UNICODE_EMO, EMOTICONS
# Function for converting emojis into word
def convert_emojis(text):
for emot in UNICODE_EMO:
text = text.replace(emot, "_".join(UNICODE_EMO[emot].replace(",","").replace(":","").split()))
return text
# Example
text1 = "Hilarious U+1F602. The feeling of making a sale U+1F60E, The feeling of actually fulfilling orders U+1F612"
convert_emojis(text1)

Output

'Hilarious face_with_tears_of_joy. The feeling of making a sale smiling_face_with_sunglasses, The feeling of actually fulfilling orders unamused_face'

Emoticon into word form

Code

# Function for converting emoticons into word
def convert_emoticons(text):
for emot in EMOTICONS:
text = re.sub(u'('+emot+')', "_".join(EMOTICONS[emot].replace(",","").split()), text)
return text
# Example
text = "Hello :-) :-)"
convert_emoticons(text)

Output

'Hello Happy_face_smiley Happy_face_smiley'

Note:

Removal and converting of emojis or emoticons are purely based on business use cases.

Thanks for reading. Keep learning and stay tuned for more!

Join thousands of data leaders on the AI newsletter. Join over 80,000 subscribers and keep up to date with the latest developments in AI. From research to projects and ideas. If you are building an AI startup, an AI-related product, or a service, we invite you to consider becoming aΒ sponsor.

Published via Towards AI

Feedback ↓