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"))