The Palos Publishing Company

Follow Us On The X Platform @PalosPublishing
Categories We Write About

Create an emoji usage tracker

Here is a simple implementation of an Emoji Usage Tracker in Python. This tool tracks how many times each emoji has been used in a given set of messages or text content.

python
import re from collections import defaultdict # Emoji pattern using regex that matches most common emojis emoji_pattern = re.compile( "[" u"U0001F600-U0001F64F" # Emoticons u"U0001F300-U0001F5FF" # Symbols & Pictographs u"U0001F680-U0001F6FF" # Transport & Map Symbols u"U0001F1E0-U0001F1FF" # Flags (iOS) u"U00002700-U000027BF" # Dingbats u"U0001F900-U0001F9FF" # Supplemental Symbols and Pictographs u"U00002600-U000026FF" # Misc symbols u"U0001FA70-U0001FAFF" # Extended pictographs "]+", flags=re.UNICODE ) class EmojiUsageTracker: def __init__(self): self.emoji_count = defaultdict(int) def add_text(self, text): emojis = emoji_pattern.findall(text) for emoji in emojis: self.emoji_count[emoji] += 1 def get_usage_report(self, sort_by='count'): if sort_by == 'count': return sorted(self.emoji_count.items(), key=lambda item: item[1], reverse=True) elif sort_by == 'emoji': return sorted(self.emoji_count.items(), key=lambda item: item[0]) else: return list(self.emoji_count.items()) def reset_tracker(self): self.emoji_count.clear() # Example usage if __name__ == "__main__": tracker = EmojiUsageTracker() sample_texts = [ "Hello 😊! How are you today? 😊😊", "Let's grab a coffee ☕️ and talk. ☕️☕️", "This is so funny 😂😂😂!", "Great job! 👍👍👍👍" ] for text in sample_texts: tracker.add_text(text) print("Emoji Usage Report:") for emoji, count in tracker.get_usage_report(): print(f"{emoji}: {count}")

Features:

  • Tracks any emojis in a text string.

  • Aggregates emoji usage counts.

  • Supports sorting by count or emoji character.

  • Easy to reset and reuse.

Let me know if you want this adapted for a web dashboard, database integration, or real-time usage tracking in an app.

Share this Page your favorite way: Click any app below to share.

Enter your email below to join The Palos Publishing Company Email List

We respect your email privacy

Categories We Write About