Hasitha16 commited on
Commit
1692a17
·
verified ·
1 Parent(s): b901475

Update model.py

Browse files
Files changed (1) hide show
  1. model.py +3 -9
model.py CHANGED
@@ -55,15 +55,9 @@ def smart_summarize(text, n_clusters=1):
55
  # === Emotion Detection ===
56
  def detect_emotion(text):
57
  try:
58
- result = emotion_pipeline(text)[0]
59
- label = result["label"].lower()
60
-
61
- # Fallback boost for weak detection
62
- fallback_triggers = ["frustrated", "angry", "disappointed", "cancel", "quit", "switch", "leaving", "hate"]
63
- if label == "neutral" and any(trigger in text.lower() for trigger in fallback_triggers):
64
- return "frustrated"
65
-
66
- return label
67
  except Exception as e:
68
  logging.warning(f"Emotion detection failed: {e}")
69
  return "neutral"
 
55
  # === Emotion Detection ===
56
  def detect_emotion(text):
57
  try:
58
+ result = emotion_pipeline(text)
59
+ top_label = result[0][0]["label"] if isinstance(result[0], list) else result[0]["label"]
60
+ return top_label
 
 
 
 
 
 
61
  except Exception as e:
62
  logging.warning(f"Emotion detection failed: {e}")
63
  return "neutral"