File size: 841 Bytes
834f0ff
1202ad3
b7213fa
 
 
31f28ee
834f0ff
 
 
 
31f28ee
1202ad3
834f0ff
 
 
 
 
 
31f28ee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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}"
    )