SamanthaStorm commited on
Commit
d025865
·
verified ·
1 Parent(s): e70a773

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -10,7 +10,7 @@ from PIL import Image
10
  from datetime import datetime
11
  from transformers import pipeline as hf_pipeline # prevent name collision with gradio pipeline
12
 
13
- def get_emotion_profile(text):
14
  emotions = emotion_pipeline(text)
15
  if isinstance(emotions, list) and isinstance(emotions[0], list):
16
  emotions = emotions[0]
@@ -130,7 +130,7 @@ ESCALATION_QUESTIONS = [
130
  ("Violence has increased in frequency or severity", 3),
131
  ("Partner monitors your calls/GPS/social media", 2)
132
  ]
133
- def get_emotional_tone_tag(emotions, sentiment, patterns, abuse_score):
134
  sadness = emotions.get("sadness", 0)
135
  joy = emotions.get("joy", 0)
136
  neutral = emotions.get("neutral", 0)
@@ -454,7 +454,7 @@ def analyze_single_message(text, thresholds):
454
  label for label, score in zip(LABELS, scores)
455
  if score > adjusted_thresholds[label]
456
  ]
457
- tone_tag = get_emotional_tone_tag(emotion_profile, sentiment, threshold_labels, 0)
458
 
459
 
460
  top_patterns = sorted(
@@ -490,7 +490,7 @@ def analyze_single_message(text, thresholds):
490
  )
491
 
492
  # Tag must happen after abuse score is finalized
493
- tone_tag = get_emotional_tone_tag(emotion_profile, sentiment, threshold_labels, abuse_score)
494
 
495
  # ---- Profanity + Anger Override Logic ----
496
  profane_words = {"fuck", "fucking", "bitch", "shit", "cunt", "ho", "asshole", "dick", "whore", "slut"}
 
10
  from datetime import datetime
11
  from transformers import pipeline as hf_pipeline # prevent name collision with gradio pipeline
12
 
13
+ def get_emotional_tone_tag(emotions, sentiment, patterns, abuse_score, text):
14
  emotions = emotion_pipeline(text)
15
  if isinstance(emotions, list) and isinstance(emotions[0], list):
16
  emotions = emotions[0]
 
130
  ("Violence has increased in frequency or severity", 3),
131
  ("Partner monitors your calls/GPS/social media", 2)
132
  ]
133
+ tone_tag = get_emotional_tone_tag(emotion_profile, sentiment, threshold_labels, abuse_score):
134
  sadness = emotions.get("sadness", 0)
135
  joy = emotions.get("joy", 0)
136
  neutral = emotions.get("neutral", 0)
 
454
  label for label, score in zip(LABELS, scores)
455
  if score > adjusted_thresholds[label]
456
  ]
457
+ tone_tag = get_emotional_tone_tag(emotion_profile, sentiment, threshold_labels, 0, text)
458
 
459
 
460
  top_patterns = sorted(
 
490
  )
491
 
492
  # Tag must happen after abuse score is finalized
493
+ tone_tag = get_emotional_tone_tag(emotion_profile, sentiment, threshold_labels, abuse_score, text)
494
 
495
  # ---- Profanity + Anger Override Logic ----
496
  profane_words = {"fuck", "fucking", "bitch", "shit", "cunt", "ho", "asshole", "dick", "whore", "slut"}