Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -40,7 +40,7 @@ THRESHOLDS = {
|
|
40 |
}
|
41 |
|
42 |
# ——— 3) Emotional-tone tagging (no abuse_score / DARVO) —————————————————————————————
|
43 |
-
def
|
44 |
anger = emotion_profile.get("anger", 0)
|
45 |
disgust = emotion_profile.get("disgust", 0)
|
46 |
sadness = emotion_profile.get("sadness", 0)
|
@@ -99,11 +99,12 @@ def analyze_message(text):
|
|
99 |
# pick up all labels whose score >= threshold
|
100 |
active = [lab for lab, sc in zip(LABELS, scores) if sc >= THRESHOLDS[lab]]
|
101 |
|
|
|
102 |
return {
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
|
108 |
|
109 |
def analyze_composite(uploaded_file, *texts):
|
@@ -125,10 +126,9 @@ def analyze_composite(uploaded_file, *texts):
|
|
125 |
r = analyze_message(content)
|
126 |
outputs.append(
|
127 |
"── Uploaded File ──\n"
|
128 |
-
f"Matched Phrases : {r['matched_phrases']}\n"
|
129 |
f"Emotion Profile : {r['emotion_profile']}\n"
|
130 |
f"Active Patterns : {r['active_patterns']}\n"
|
131 |
-
f"Emotional Tone
|
132 |
)
|
133 |
|
134 |
# 2) Text-box blocks
|
@@ -138,10 +138,9 @@ def analyze_composite(uploaded_file, *texts):
|
|
138 |
r = analyze_message(txt)
|
139 |
outputs.append(
|
140 |
f"── Message {idx} ──\n"
|
141 |
-
f"Matched Phrases : {r['matched_phrases']}\n"
|
142 |
f"Emotion Profile : {r['emotion_profile']}\n"
|
143 |
f"Active Patterns : {r['active_patterns']}\n"
|
144 |
-
f"Emotional Tone
|
145 |
)
|
146 |
|
147 |
if not outputs:
|
|
|
40 |
}
|
41 |
|
42 |
# ——— 3) Emotional-tone tagging (no abuse_score / DARVO) —————————————————————————————
|
43 |
+
def get_emotional_tone_tag(emotion_profile, patterns):
|
44 |
anger = emotion_profile.get("anger", 0)
|
45 |
disgust = emotion_profile.get("disgust", 0)
|
46 |
sadness = emotion_profile.get("sadness", 0)
|
|
|
99 |
# pick up all labels whose score >= threshold
|
100 |
active = [lab for lab, sc in zip(LABELS, scores) if sc >= THRESHOLDS[lab]]
|
101 |
|
102 |
+
tone_tag = get_emotional_tone_tag(emotion_profile, active_patterns)
|
103 |
return {
|
104 |
+
"emotion_profile": emotion_profile,
|
105 |
+
"active_patterns": active_patterns,
|
106 |
+
"tone_tag": tone_tag # ← make sure this line is present
|
107 |
+
}
|
108 |
|
109 |
|
110 |
def analyze_composite(uploaded_file, *texts):
|
|
|
126 |
r = analyze_message(content)
|
127 |
outputs.append(
|
128 |
"── Uploaded File ──\n"
|
|
|
129 |
f"Emotion Profile : {r['emotion_profile']}\n"
|
130 |
f"Active Patterns : {r['active_patterns']}\n"
|
131 |
+
f"Emotional Tone : {r['tone_tag']}\n"
|
132 |
)
|
133 |
|
134 |
# 2) Text-box blocks
|
|
|
138 |
r = analyze_message(txt)
|
139 |
outputs.append(
|
140 |
f"── Message {idx} ──\n"
|
|
|
141 |
f"Emotion Profile : {r['emotion_profile']}\n"
|
142 |
f"Active Patterns : {r['active_patterns']}\n"
|
143 |
+
f"Emotional Tone : {r['tone_tag']}\n"
|
144 |
)
|
145 |
|
146 |
if not outputs:
|