Spaces:
Running
Running
File size: 6,647 Bytes
25e624c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
"""
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())}")
|