Spaces:
Running
Running
| """ | |
| Sentiment Emoji Map - Maps emotion labels to face emojis | |
| This module maps detected emotions to visual emoji representations | |
| Unified for both user and AI (same emojis for all) | |
| Version 2.0: Added new emotions for multi-emotion model support | |
| """ | |
| from typing import Dict, Optional | |
| class EmojiMapper: | |
| """Maps emotion labels to face emojis - unified for user and AI""" | |
| EMOTION_EMOJIS: Dict[str, str] = { | |
| # === POSITIVE EMOTIONS (High Arousal) === | |
| "ecstasy": "๐คฉ", | |
| "joy": "๐", | |
| "happiness": "๐", | |
| "delight": "๐", | |
| "elation": "๐", | |
| "euphoria": "๐ฅณ", | |
| "excitement": "๐", | |
| "thrill": "๐", | |
| "enthusiasm": "๐", | |
| "cheerfulness": "๐", | |
| # === POSITIVE EMOTIONS (Medium Arousal) === | |
| "contentment": "๐", | |
| "satisfaction": "๐", | |
| "pleasure": "๐", | |
| "relief": "๐ฎโ๐จ", | |
| "serenity": "๐", | |
| "calm": "๐", | |
| "relaxed": "๐", | |
| "pride": "๐ค", | |
| "confidence": "๐", | |
| "triumph": "๐", | |
| # === LOVE & AFFECTION === | |
| "love": "๐ฅฐ", | |
| "adoration": "๐", | |
| "affection": "๐ฅฐ", | |
| "tenderness": "๐ค", | |
| "caring": "๐ค", | |
| "compassion": "๐ฅน", | |
| "empathy": "๐ฅน", | |
| "gratitude": "๐", | |
| "thankful": "๐", | |
| # === INTEREST & CURIOSITY === | |
| "curiosity": "๐ง", | |
| "interest": "๐ค", | |
| "fascination": "๐ฏ", | |
| "wonder": "๐ฒ", | |
| "awe": "๐ฎ", | |
| "amazement": "๐ฒ", | |
| "intrigue": "๐คจ", | |
| # === SURPRISE === | |
| "surprise": "๐ฎ", | |
| "astonishment": "๐ฑ", | |
| "shock": "๐ณ", | |
| "startled": "๐ง", | |
| # === NEUTRAL / THINKING === | |
| "neutral": "๐", | |
| "thinking": "๐ค", | |
| "contemplative": "๐ค", | |
| "pensive": "๐", | |
| "reflective": "๐ค", | |
| "uncertain": "๐", | |
| "ambivalent": "๐", | |
| "indifferent": "๐", | |
| # === CONFUSION === | |
| "confused": "๐", | |
| "confusion": "๐", | |
| "puzzled": "๐คจ", | |
| "perplexed": "๐ตโ๐ซ", | |
| "bewildered": "๐ต", | |
| "baffled": "๐คฏ", | |
| # === NEGATIVE EMOTIONS (Low Arousal) === | |
| "sadness": "๐ข", | |
| "sorrow": "๐ญ", | |
| "grief": "๐ญ", | |
| "melancholy": "๐", | |
| "disappointment": "๐", | |
| "dejection": "๐ฉ", | |
| "despair": "๐ซ", | |
| "hopelessness": "๐ฟ", | |
| "loneliness": "๐ฅบ", | |
| "hurt": "๐ข", | |
| "misery": "๐ฃ", | |
| # === FEAR & ANXIETY === | |
| "fear": "๐จ", | |
| "terror": "๐ฑ", | |
| "horror": "๐ฑ", | |
| "dread": "๐ฐ", | |
| "anxiety": "๐ฐ", | |
| "worry": "๐", | |
| "nervousness": "๐ฌ", | |
| "apprehension": "๐ง", | |
| "panic": "๐ฑ", | |
| # === ANGER & FRUSTRATION === | |
| "anger": "๐ ", | |
| "rage": "๐คฌ", | |
| "fury": "๐ก", | |
| "irritation": "๐ค", | |
| "annoyance": "๐", | |
| "frustration": "๐ค", | |
| "exasperation": "๐ซ", | |
| "resentment": "๐", | |
| "hostility": "๐ ", | |
| "bitterness": "๐", | |
| # === DISGUST & CONTEMPT === | |
| "disgust": "๐คข", | |
| "revulsion": "๐คฎ", | |
| "contempt": "๐", | |
| "disdain": "๐", | |
| "loathing": "๐ค", | |
| "scorn": "๐", | |
| # === SHAME & EMBARRASSMENT === | |
| "shame": "๐ณ", | |
| "embarrassment": "๐ณ", | |
| "guilt": "๐ฃ", | |
| "regret": "๐", | |
| "remorse": "๐", | |
| "humiliation": "๐ซฃ", | |
| # === BOREDOM & TIREDNESS === | |
| "boredom": "๐", | |
| "tiredness": "๐ด", | |
| "exhaustion": "๐ฉ", | |
| "fatigue": "๐ฅฑ", | |
| "weariness": "๐ฎโ๐จ", | |
| "sleepy": "๐ด", | |
| # === ENVY & JEALOUSY === | |
| "envy": "๐", | |
| "jealousy": "๐", | |
| # === PLAYFUL & SILLY === | |
| "playful": "๐", | |
| "silly": "๐คช", | |
| "mischievous": "๐", | |
| "teasing": "๐", | |
| "sarcastic": "๐", | |
| "witty": "๐", | |
| "amusement": "๐", | |
| "funny": "๐คฃ", | |
| # === SPECIAL STATES === | |
| "sympathy": "๐ฅน", | |
| "nostalgia": "๐ฅฒ", | |
| "hope": "๐", | |
| "optimism": "๐", | |
| "pessimism": "๐", | |
| "longing": "๐ฅบ", | |
| "yearning": "๐ข", | |
| # === NEW IN V2 === | |
| "determination": "๐ค", | |
| "inspiration": "๐คฉ", # Changed from โจ to face emoji | |
| "anticipation": "๐ค", | |
| "trust": "๐", # Changed from ๐ค to face emoji | |
| "acceptance": "๐", | |
| "sarcasm": "๐", | |
| # === NEW IN V3 - Context Emotions === | |
| "indifferent": "๐", | |
| "admiration": "๐คฉ", | |
| "despair": "๐ฐ", | |
| "greeting": "๐", # Changed from ๐ to face emoji | |
| "heartbreak": "๐ญ", # Changed from ๐ to face emoji, | |
| # === LEGACY MAPPINGS === | |
| "very_negative": "๐ญ", | |
| "negative": "๐ ", | |
| "slightly_negative": "๐", | |
| "slightly_positive": "๐", | |
| "positive": "๐", | |
| "very_positive": "๐คฉ", | |
| # Default | |
| "default": "๐", | |
| "ready": "๐", | |
| } | |
| def __init__(self, custom_emojis: Optional[Dict[str, str]] = None): | |
| """Initialize with default or custom emoji mappings""" | |
| self.emojis = self.EMOTION_EMOJIS.copy() | |
| if custom_emojis: | |
| self.emojis.update(custom_emojis) | |
| def get_emoji(self, emotion: str) -> str: | |
| """ | |
| Get emoji for a given emotion | |
| Args: | |
| emotion: Emotion label (e.g., 'joy', 'anger', 'curiosity') | |
| Returns: | |
| Face emoji string | |
| """ | |
| emotion_clean = emotion.lower().strip().replace(" ", "_").replace("-", "_") | |
| return self.emojis.get(emotion_clean, self.emojis.get("default", "๐")) | |
| def get_all_emojis(self) -> Dict[str, str]: | |
| """Get all emotionโemoji mappings""" | |
| return self.emojis.copy() | |
| if __name__ == "__main__": | |
| mapper = EmojiMapper() | |
| test_emotions = [ | |
| "joy", "happiness", "love", "sadness", "anger", | |
| "fear", "surprise", "disgust", "curiosity", "neutral" | |
| ] | |
| print("Emotion โ Emoji Mappings:") | |
| for emotion in test_emotions: | |
| emoji = mapper.get_emoji(emotion) | |
| print(f" {emotion:20} โ {emoji}") | |
| print(f"\nTotal emotions: {len(mapper.get_all_emojis())}") | |