Saturday 17 August 2024

Top 5 Python Programs Using demoji for Emoji Processing

 1. Remove Emojis from a Text String

This program removes all emojis from a given text string.


import demoji

text = "Python is fun! 🐍πŸ”₯ Let's code! πŸ’»πŸŽ‰"

cleaned_text = demoji.replace(text, "")

print(cleaned_text)

#source Code --> clcoding.com

Python is fun!  Let's code! 

2. Replace Emojis with Descriptions

This program replaces emojis in a text with their corresponding descriptions.


import demoji

text = "Good morning! ☀️ Have a nice day! 🌸😊"

emojis = demoji.findall(text)

for emoji, description in emojis.items():

    text = text.replace(emoji, f"[{description}]")

print(text)

#source Code --> clcoding.com

Good morning! [sun] Have a nice day! [cherry blossom][smiling face with smiling eyes]

3. Count the Number of Emojis in a Text

This program counts how many emojis are present in a text string.


import demoji

text = "Coding is awesome! πŸ‘¨‍πŸ’»πŸš€πŸ€“"

emoji_count = len(demoji.findall(text))

print(f"Number of emojis: {emoji_count}")

#source Code --> clcoding.com

Number of emojis: 3

4. Extract All Emojis from a Text

This program extracts all the emojis from a given text string.


import demoji

text = "Enjoy your meal! 🍽️πŸ•πŸ”πŸŸ"

emojis = demoji.findall(text)

print("Emojis found:", list(emojis.keys()))

#source Code --> clcoding.com

Emojis found: ['πŸ•', '🍽️', '🍟', 'πŸ”']

5. Create an Emoji Frequency Dictionary

This program creates a dictionary that maps each emoji in a text to the number of times it appears.


import demoji

text = "I love 🍎 and 🍌. Do you like 🍎 too? 🍎🍎"

emoji_freq = {}

emojis = demoji.findall(text)

for emoji in emojis.keys():

    emoji_freq[emoji] = text.count(emoji)

print("Emoji Frequency:", emoji_freq)

#source Code --> clcoding.com

Emoji Frequency: {'🍌': 1, '🍎': 4}

0 Comments:

Post a Comment

Popular Posts

Categories

AI (29) Android (24) AngularJS (1) Assembly Language (2) aws (17) Azure (7) BI (10) book (4) Books (121) C (77) C# (12) C++ (82) Course (67) Coursera (195) Cybersecurity (24) data management (11) Data Science (100) Data Strucures (7) Deep Learning (11) Django (14) Downloads (3) edx (2) Engineering (14) Excel (13) Factorial (1) Finance (6) flask (3) flutter (1) FPL (17) Google (19) Hadoop (3) HTML&CSS (46) IBM (25) IoT (1) IS (25) Java (93) Leet Code (4) Machine Learning (46) Meta (18) MICHIGAN (5) microsoft (4) Pandas (3) PHP (20) Projects (29) Python (834) Python Coding Challenge (279) Questions (2) R (70) React (6) Scripting (1) security (3) Selenium Webdriver (2) Software (17) SQL (41) UX Research (1) web application (8)

Followers

Person climbing a staircase. Learn Data Science from Scratch: online program with 21 courses