File size: 5,272 Bytes
0580921 |
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 |
# emojis.py
# JusticeAI Emoji Intelligence Engine ๐ง โ๏ธ
# One-file version โ handles emotions, tone, and context adaptively.
import random
# ============================================================
# CORE EMOTIONS ๐๐ญ๐ก
# ============================================================
EMOJIS = {
# --- Primary human emotions ---
"joy": ["๐", "๐", "๐", "๐", "๐", "๐", "๐คฃ", "๐น"],
"love": ["๐ฅฐ", "๐", "๐", "๐", "โค๏ธ", "๐", "๐", "๐"],
"surprise": ["๐ฒ", "๐คฏ", "๐ฎ", "๐ณ", "๐"],
"anger": ["๐ ", "๐ก", "๐คฌ", "๐ข", "๐ค"],
"fear": ["๐จ", "๐ฑ", "๐ฐ", "๐ง", "๐"],
"sadness": ["๐", "๐ข", "๐", "๐ญ", "๐ฅบ"],
"disgust": ["๐คข", "๐คฎ", "๐", "๐ค"],
"neutral": ["๐", "๐", "๐ค", "๐ถ"],
# ============================================================
# CONVERSATION FLOW ๐ฌ
# ============================================================
"greeting": ["๐", "๐โโ๏ธ", "๐โโ๏ธ", "๐"],
"thinking": ["๐ค", "๐ง ", "๐ญ", "๐"],
"ack": ["โ
", "๐", "๐", "๐"],
"unsure": ["๐คทโโ๏ธ", "๐คทโโ๏ธ", "๐", "๐
"],
"learning": ["๐", "๐งฉ", "๐ง ", "๐", "๐ก"],
"success": ["๐", "๐", "๐", "๐", "๐ฅ"],
"apology": ["๐", "๐ฌ", "๐ฅบ"],
"encouragement": ["๐ช", "๐", "โจ", "๐ซ", "๐ค"],
"humor": ["๐", "๐คฃ", "๐", "๐", "๐คญ", "๐คช"],
"farewell": ["๐", "๐", "๐ซ", "๐"],
# ============================================================
# CONTEXTUAL EMOJIS ๐โ๏ธ
# ============================================================
"ai": ["๐ค", "๐ป", "๐ง ", "๐ฌ", "๐งฎ"],
"justice": ["โ๏ธ", "๐๏ธ", "๐", "๐๏ธ", "๐จโโ๏ธ"],
"nature": ["๐ฟ", "๐ธ", "๐", "๐", "๐", "๐", "๐"],
"energy": ["โก", "๐ฅ", "๐ฅ", "๐"],
"time": ["โณ", "๐ฐ๏ธ", "โ", "โฑ๏ธ"],
"reward": ["๐", "๐ฏ", "๐
", "๐"],
"warning": ["โ ๏ธ", "๐จ", "๐"],
"celebration": ["๐", "๐", "๐ฅณ", "๐พ"],
"philosophy": ["๐", "๐", "๐ฎ", "๐ช", "๐งโโ๏ธ"],
# ============================================================
# SOCIAL / META โจ
# ============================================================
"cool": ["๐", "๐ค", "๐", "๐ฅ"],
"nerdy": ["๐ค", "๐ง ", "๐", "๐"],
"curiosity": ["๐ต๏ธโโ๏ธ", "๐", "๐ง"],
"motivation": ["๐", "๐", "๐", "๐ฅ"],
"comfort": ["๐ค", "๐", "๐ธ"],
"celebrate": ["๐", "๐ฅณ", "๐"],
}
# Merge all keys for validation
ALL_CATEGORIES = set(EMOJIS.keys())
# ============================================================
# SMART SELECTOR FUNCTIONS ๐งฉ
# ============================================================
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")
# ============================================================
# TEST (only runs when executed directly)
# ============================================================
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"))
|