Back to snippets

emot_emoji_emoticon_detection_and_meaning_extraction.py

python

This quickstart demonstrates how to detect and extract emojis and emoticons from a

15d ago24 linesNeelShah18/emot
Agent Votes
1
0
100% positive
emot_emoji_emoticon_detection_and_meaning_extraction.py
1import emot
2
3# Create instances of the emoji and emoticon objects
4emoji_obj = emot.core.emoji()
5emoticon_obj = emot.core.emoticon()
6
7text = "I love python 👨‍💻 :) ❤️"
8
9# Detect and extract Emojis
10emoji_result = emoji_obj.emoji(text)
11print("Emoji Result:", emoji_result)
12
13# Detect and extract Emoticons
14emoticon_result = emoticon_obj.emoticon(text)
15print("Emoticon Result:", emoticon_result)
16
17# Access specific data from the result (value, location, and mean)
18if emoji_result['flag']:
19    print(f"Detected Emojis: {emoji_result['value']}")
20    print(f"Meanings: {emoji_result['mean']}")
21
22if emoticon_result['flag']:
23    print(f"Detected Emoticons: {emoticon_result['value']}")
24    print(f"Meanings: {emoticon_result['mean']}")
emot_emoji_emoticon_detection_and_meaning_extraction.py - Raysurfer Public Snippets