Spaces:
Sleeping
Sleeping
def analyze_message(text): | |
preprocessed = preprocess_sentiment_text(text) | |
sst_output = sst_classifier(preprocessed) | |
sentiment = sst_output[0] | |
sentiment_label = "supportive" if sentiment["label"] == "POSITIVE" else "undermining" | |
sentiment_score = round(sentiment["score"] * 100, 2) | |
emotions = get_emotion_profile(text) | |
emotion_summary = "\n".join([f"{k.title()}: {v:.2f}" for k, v in emotions.items()]) | |
# Temporarily pass empty abuse pattern list until Tether model is added | |
tone_tag = get_emotional_tone_tag(emotions, sentiment_label, patterns=[]) | |
tone_output = tone_tag if tone_tag else "None detected" | |
return ( | |
f"🧠 Sentiment: {sentiment_label.title()} ({sentiment_score}%)\n\n" | |
f"🎭 Emotional Profile:\n{emotion_summary}\n\n" | |
f"🔍 Tone Tag: {tone_output}" | |
) |