Hasitha16 commited on
Commit
e0723c4
·
verified ·
1 Parent(s): 8b420fe

Update model.py

Browse files
Files changed (1) hide show
  1. model.py +8 -1
model.py CHANGED
@@ -56,7 +56,14 @@ def smart_summarize(text, n_clusters=1):
56
  def detect_emotion(text):
57
  try:
58
  result = emotion_pipeline(text)[0]
59
- return result["label"]
 
 
 
 
 
 
 
60
  except Exception as e:
61
  logging.warning(f"Emotion detection failed: {e}")
62
  return "neutral"
 
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"