Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -85,15 +85,14 @@ def get_emotional_tone_tag(emotions, sentiment, patterns, abuse_score=0):
|
|
85 |
# Main function
|
86 |
def analyze_message(text):
|
87 |
preprocessed = preprocess_sentiment_text(text)
|
88 |
-
sst_result = sst_classifier(preprocessed)
|
89 |
-
|
90 |
-
sentiment_label = "supportive" if
|
91 |
-
sentiment_score = round(
|
92 |
|
93 |
emotions = get_emotion_profile(text)
|
94 |
emotion_summary = "\n".join([f"{k.title()}: {v:.2f}" for k, v in emotions.items()])
|
95 |
|
96 |
-
# Temporarily pass empty abuse pattern list until Tether model is added
|
97 |
tone_tag = get_emotional_tone_tag(emotions, sentiment_label, patterns=[])
|
98 |
tone_output = tone_tag if tone_tag else "None detected"
|
99 |
|
@@ -102,7 +101,6 @@ def analyze_message(text):
|
|
102 |
f"🎭 Emotional Profile:\n{emotion_summary}\n\n"
|
103 |
f"🔍 Tone Tag: {tone_output}"
|
104 |
)
|
105 |
-
|
106 |
# Interface
|
107 |
iface = gr.Interface(
|
108 |
fn=analyze_message,
|
|
|
85 |
# Main function
|
86 |
def analyze_message(text):
|
87 |
preprocessed = preprocess_sentiment_text(text)
|
88 |
+
sst_result = sst_classifier(preprocessed)[0] # <- this line was missing!
|
89 |
+
|
90 |
+
sentiment_label = "supportive" if sst_result["label"] == "POSITIVE" else "undermining"
|
91 |
+
sentiment_score = round(sst_result["score"] * 100, 2)
|
92 |
|
93 |
emotions = get_emotion_profile(text)
|
94 |
emotion_summary = "\n".join([f"{k.title()}: {v:.2f}" for k, v in emotions.items()])
|
95 |
|
|
|
96 |
tone_tag = get_emotional_tone_tag(emotions, sentiment_label, patterns=[])
|
97 |
tone_output = tone_tag if tone_tag else "None detected"
|
98 |
|
|
|
101 |
f"🎭 Emotional Profile:\n{emotion_summary}\n\n"
|
102 |
f"🔍 Tone Tag: {tone_output}"
|
103 |
)
|
|
|
104 |
# Interface
|
105 |
iface = gr.Interface(
|
106 |
fn=analyze_message,
|