|
|
|
|
|
|
|
|
|
|
|
|
|
|
import random |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EMOJIS = { |
|
|
|
|
|
"joy": ["๐", "๐", "๐", "๐", "๐", "๐", "๐คฃ", "๐น"], |
|
|
"love": ["๐ฅฐ", "๐", "๐", "๐", "โค๏ธ", "๐", "๐", "๐"], |
|
|
"surprise": ["๐ฒ", "๐คฏ", "๐ฎ", "๐ณ", "๐"], |
|
|
"anger": ["๐ ", "๐ก", "๐คฌ", "๐ข", "๐ค"], |
|
|
"fear": ["๐จ", "๐ฑ", "๐ฐ", "๐ง", "๐"], |
|
|
"sadness": ["๐", "๐ข", "๐", "๐ญ", "๐ฅบ"], |
|
|
"disgust": ["๐คข", "๐คฎ", "๐", "๐ค"], |
|
|
"neutral": ["๐", "๐", "๐ค", "๐ถ"], |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"greeting": ["๐", "๐โโ๏ธ", "๐โโ๏ธ", "๐"], |
|
|
"thinking": ["๐ค", "๐ง ", "๐ญ", "๐"], |
|
|
"ack": ["โ
", "๐", "๐", "๐"], |
|
|
"unsure": ["๐คทโโ๏ธ", "๐คทโโ๏ธ", "๐", "๐
"], |
|
|
"learning": ["๐", "๐งฉ", "๐ง ", "๐", "๐ก"], |
|
|
"success": ["๐", "๐", "๐", "๐", "๐ฅ"], |
|
|
"apology": ["๐", "๐ฌ", "๐ฅบ"], |
|
|
"encouragement": ["๐ช", "๐", "โจ", "๐ซ", "๐ค"], |
|
|
"humor": ["๐", "๐คฃ", "๐", "๐", "๐คญ", "๐คช"], |
|
|
"farewell": ["๐", "๐", "๐ซ", "๐"], |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ai": ["๐ค", "๐ป", "๐ง ", "๐ฌ", "๐งฎ"], |
|
|
"justice": ["โ๏ธ", "๐๏ธ", "๐", "๐๏ธ", "๐จโโ๏ธ"], |
|
|
"nature": ["๐ฟ", "๐ธ", "๐", "๐", "๐", "๐", "๐"], |
|
|
"energy": ["โก", "๐ฅ", "๐ฅ", "๐"], |
|
|
"time": ["โณ", "๐ฐ๏ธ", "โ", "โฑ๏ธ"], |
|
|
"reward": ["๐", "๐ฏ", "๐
", "๐"], |
|
|
"warning": ["โ ๏ธ", "๐จ", "๐"], |
|
|
"celebration": ["๐", "๐", "๐ฅณ", "๐พ"], |
|
|
"philosophy": ["๐", "๐", "๐ฎ", "๐ช", "๐งโโ๏ธ"], |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"cool": ["๐", "๐ค", "๐", "๐ฅ"], |
|
|
"nerdy": ["๐ค", "๐ง ", "๐", "๐"], |
|
|
"curiosity": ["๐ต๏ธโโ๏ธ", "๐", "๐ง"], |
|
|
"motivation": ["๐", "๐", "๐", "๐ฅ"], |
|
|
"comfort": ["๐ค", "๐", "๐ธ"], |
|
|
"celebrate": ["๐", "๐ฅณ", "๐"], |
|
|
} |
|
|
|
|
|
|
|
|
ALL_CATEGORIES = set(EMOJIS.keys()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_emoji(category: str, intensity: float = 0.5) -> str: |
|
|
""" |
|
|
Return an emoji from a given category, with intensity (0โ1). |
|
|
Higher intensity โ stronger emotion (later in list). |
|
|
""" |
|
|
if category not in EMOJIS: |
|
|
return "๐ค" |
|
|
emojis = EMOJIS[category] |
|
|
index = min(int(len(emojis) * intensity), len(emojis) - 1) |
|
|
return emojis[index] |
|
|
|
|
|
|
|
|
def random_emoji(category: str) -> str: |
|
|
"""Return a random emoji from a category.""" |
|
|
return random.choice(EMOJIS.get(category, ["๐ค"])) |
|
|
|
|
|
|
|
|
def merge_emojis(*categories, count=2) -> str: |
|
|
""" |
|
|
Mix emojis from multiple categories. |
|
|
Example: merge_emojis("joy", "ai") โ ๐๐ค |
|
|
""" |
|
|
selected = [] |
|
|
for cat in categories: |
|
|
if cat in EMOJIS: |
|
|
selected.append(random.choice(EMOJIS[cat])) |
|
|
random.shuffle(selected) |
|
|
return " ".join(selected[:count]) if selected else "๐ค" |
|
|
|
|
|
|
|
|
def search_emoji(keyword: str) -> list: |
|
|
""" |
|
|
Search emojis by keyword in category names. |
|
|
Returns a flat list of matches. |
|
|
""" |
|
|
result = [] |
|
|
keyword = keyword.lower() |
|
|
for cat, emojis in EMOJIS.items(): |
|
|
if keyword in cat: |
|
|
result.extend(emojis) |
|
|
return result or ["๐ค"] |
|
|
|
|
|
|
|
|
def all_emojis() -> list: |
|
|
"""Return a flattened list of all emojis available.""" |
|
|
return [e for group in EMOJIS.values() for e in group] |
|
|
|
|
|
|
|
|
def get_category_for_mood(mood_label: str) -> str: |
|
|
""" |
|
|
Map model mood labels (e.g. 'happy', 'sad', 'angry') |
|
|
to an emoji category name. |
|
|
""" |
|
|
mapping = { |
|
|
"happy": "joy", |
|
|
"joy": "joy", |
|
|
"sad": "sadness", |
|
|
"anger": "anger", |
|
|
"angry": "anger", |
|
|
"fear": "fear", |
|
|
"disgust": "disgust", |
|
|
"surprise": "surprise", |
|
|
"neutral": "neutral", |
|
|
"love": "love", |
|
|
"excited": "success", |
|
|
} |
|
|
return mapping.get(mood_label.lower(), "neutral") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
print("๐ง Total categories:", len(EMOJIS)) |
|
|
print("๐ Total emojis:", len(all_emojis())) |
|
|
print("๐ฅ Random test:", merge_emojis("joy", "ai", count=3)) |
|
|
print("๐ Joy (0.9 intensity):", get_emoji("joy", 0.9)) |
|
|
print("๐ต๏ธ Search 'ai':", search_emoji("ai")) |
|
|
|