File size: 10,382 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
234
235
236
237
238
239
240
241
242
# -*- coding: utf-8 -*-
"""
Emotion Statistics - Complete overview of all emotions managed by the system

Shows:
- Total emotion count
- Emoji mapping
- Recognition accuracy from latest evaluation
"""

import sys
import os
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from avatar.sentiment_emoji_map import EmojiMapper


def get_emotion_stats():
    """Generate complete emotion statistics table"""
    
    mapper = EmojiMapper()
    all_emojis = mapper.get_all_emojis()
    
    # Remove legacy/system mappings for counting
    legacy_keys = ["very_negative", "negative", "slightly_negative", 
                   "slightly_positive", "positive", "very_positive",
                   "default", "ready"]
    
    emotion_emojis = {k: v for k, v in all_emojis.items() if k not in legacy_keys}
    
    # Recognition accuracy from latest evaluation (Multi-Emotion V2)
    # Data from evaluation/reports/comparison_multi-v2_2025-12-01_18-46-46.md
    recognition_accuracy = {
        # 100% accuracy
        "excitement": 100.0, "thrill": 100.0, "delight": 100.0, "cheerfulness": 100.0,
        "enthusiasm": 100.0, "calm": 100.0, "pleasure": 100.0, "love": 100.0,
        "affection": 100.0, "tenderness": 100.0, "caring": 100.0, "compassion": 100.0,
        "empathy": 100.0, "gratitude": 100.0, "wonder": 100.0, "awe": 100.0,
        "amazement": 100.0, "surprise": 100.0, "thinking": 100.0, "sadness": 100.0,
        "grief": 100.0, "disappointment": 100.0, "loneliness": 100.0, "hurt": 100.0,
        "fear": 100.0, "terror": 100.0, "horror": 100.0, "dread": 100.0,
        "anxiety": 100.0, "worry": 100.0, "nervousness": 100.0, "panic": 100.0,
        "anger": 100.0, "fury": 100.0, "irritation": 100.0, "hostility": 100.0,
        "disgust": 100.0, "contempt": 100.0, "disdain": 100.0, "shame": 100.0,
        "embarrassment": 100.0, "guilt": 100.0, "regret": 100.0, "remorse": 100.0,
        "tiredness": 100.0, "jealousy": 100.0, "sympathy": 100.0, "nostalgia": 100.0,
        "pessimism": 100.0, "yearning": 100.0, "determination": 100.0,
        "anticipation": 100.0, "trust": 100.0,
        # 90%+
        "happiness": 90.0, "silly": 87.5, "joy": 85.7, "pride": 85.7,
        "uncertain": 85.7, "confused": 85.7, "playful": 85.7, "hope": 85.7,
        # 80%+
        "satisfaction": 83.3, "relaxed": 83.3, "relief": 83.3, "interest": 83.3,
        "shock": 83.3, "annoyance": 83.3, "frustration": 83.3, "boredom": 83.3,
        "optimism": 83.3, "elation": 80.0, "euphoria": 80.0, "serenity": 80.0,
        "adoration": 80.0, "fascination": 80.0, "intrigue": 80.0, "astonishment": 80.0,
        "puzzled": 80.0, "perplexed": 80.0, "bewildered": 80.0, "baffled": 80.0,
        "sorrow": 80.0, "melancholy": 80.0, "despair": 80.0, "misery": 80.0,
        "apprehension": 80.0, "rage": 80.0, "resentment": 80.0, "bitterness": 80.0,
        "revulsion": 80.0, "scorn": 80.0, "humiliation": 80.0, "exhaustion": 80.0,
        "fatigue": 80.0, "weariness": 80.0, "inspiration": 80.0, "sarcasm": 80.0,
        # 70%+
        "neutral": 76.9, "amusement": 72.7, "ecstasy": 71.4, "longing": 71.4,
        # 60%+
        "envy": 66.7, "mischievous": 66.7, "acceptance": 60.0,
        # 50%+
        "contentment": 57.1, "curiosity": 57.1, "confidence": 50.0,
    }
    
    # Categories
    categories = {
        "POSITIVE (High Arousal)": ["ecstasy", "joy", "happiness", "delight", "elation", 
                                    "euphoria", "excitement", "thrill", "enthusiasm", "cheerfulness"],
        "POSITIVE (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"],
        "SADNESS": ["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", "determination", "inspiration", "anticipation", "trust", 
                          "acceptance", "sarcasm"],
    }
    
    return emotion_emojis, recognition_accuracy, categories


def print_emotion_table():
    """Print formatted emotion statistics table"""
    
    emotion_emojis, recognition_accuracy, categories = get_emotion_stats()
    
    print("=" * 80)
    print("EMOJI AI AVATAR - EMOTION RECOGNITION STATISTICS")
    print("=" * 80)
    print()
    print(f"πŸ“Š Total Emotions Mapped: {len(emotion_emojis)}")
    print(f"πŸ“Š Emotions with Recognition Data: {len(recognition_accuracy)}")
    print(f"πŸ“Š Overall Recognition Accuracy: 89.0%")
    print()
    
    # Print by category
    for category, emotions in categories.items():
        print(f"\n{'─' * 80}")
        print(f"πŸ“ {category}")
        print(f"{'─' * 80}")
        print(f"{'Emotion':<20} {'Emoji':<6} {'Accuracy':<10} {'Status'}")
        print(f"{'─' * 20} {'─' * 5} {'─' * 9} {'─' * 10}")
        
        for emotion in emotions:
            emoji = emotion_emojis.get(emotion, "❓")
            accuracy = recognition_accuracy.get(emotion, None)
            
            if accuracy is not None:
                if accuracy >= 80:
                    status = "βœ… PASS"
                elif accuracy >= 50:
                    status = "⚠️ OK"
                else:
                    status = "❌ FAIL"
                acc_str = f"{accuracy:.1f}%"
            else:
                status = "πŸ”Ή N/T"  # Not tested
                acc_str = "N/A"
            
            print(f"{emotion:<20} {emoji:<6} {acc_str:<10} {status}")
    
    # Summary statistics
    print()
    print("=" * 80)
    print("SUMMARY STATISTICS")
    print("=" * 80)
    
    tested = [acc for acc in recognition_accuracy.values()]
    
    perfect = sum(1 for acc in tested if acc == 100.0)
    high = sum(1 for acc in tested if 80.0 <= acc < 100.0)
    medium = sum(1 for acc in tested if 50.0 <= acc < 80.0)
    low = sum(1 for acc in tested if acc < 50.0)
    
    print(f"βœ… 100% Accuracy: {perfect} emotions")
    print(f"βœ… 80-99% Accuracy: {high} emotions")
    print(f"⚠️ 50-79% Accuracy: {medium} emotions")
    print(f"❌ <50% Accuracy: {low} emotions")
    print()
    print(f"Average Accuracy: {sum(tested)/len(tested):.1f}%")
    print()


def generate_markdown_table():
    """Generate markdown table for documentation"""
    
    emotion_emojis, recognition_accuracy, categories = get_emotion_stats()
    
    lines = [
        "# Emoji AI Avatar - Complete Emotion Table",
        "",
        f"**Total Emotions:** {len(emotion_emojis)}",
        f"**Overall Accuracy:** 89.0%",
        f"**Last Updated:** 2025-12-01",
        "",
        "## Recognition Accuracy by Category",
        "",
    ]
    
    for category, emotions in categories.items():
        lines.append(f"### {category}")
        lines.append("")
        lines.append("| Emotion | Emoji | Accuracy | Status |")
        lines.append("|---------|-------|----------|--------|")
        
        for emotion in emotions:
            emoji = emotion_emojis.get(emotion, "❓")
            accuracy = recognition_accuracy.get(emotion, None)
            
            if accuracy is not None:
                if accuracy >= 80:
                    status = "βœ… PASS"
                elif accuracy >= 50:
                    status = "⚠️ OK"
                else:
                    status = "❌ FAIL"
                acc_str = f"{accuracy:.1f}%"
            else:
                status = "πŸ”Ή N/T"
                acc_str = "N/A"
            
            lines.append(f"| {emotion} | {emoji} | {acc_str} | {status} |")
        
        lines.append("")
    
    # Add summary
    tested = list(recognition_accuracy.values())
    perfect = sum(1 for acc in tested if acc == 100.0)
    high = sum(1 for acc in tested if 80.0 <= acc < 100.0)
    medium = sum(1 for acc in tested if 50.0 <= acc < 80.0)
    low = sum(1 for acc in tested if acc < 50.0)
    
    lines.extend([
        "## Summary",
        "",
        "| Accuracy Range | Count |",
        "|----------------|-------|",
        f"| 100% (Perfect) | {perfect} |",
        f"| 80-99% (High) | {high} |",
        f"| 50-79% (Medium) | {medium} |",
        f"| <50% (Low) | {low} |",
        "",
        f"**Average Accuracy:** {sum(tested)/len(tested):.1f}%",
        "",
    ])
    
    return "\n".join(lines)


if __name__ == "__main__":
    print_emotion_table()
    
    # Also save markdown version
    md_content = generate_markdown_table()
    output_path = os.path.join(os.path.dirname(__file__), "reports", "emotion_statistics.md")
    with open(output_path, "w", encoding="utf-8") as f:
        f.write(md_content)
    
    print(f"\nπŸ“„ Markdown table saved to: {output_path}")