Spaces:
Running
Running
Update model.py
Browse files
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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"
|