SamanthaStorm commited on
Commit
5a06bc7
·
verified ·
1 Parent(s): e905632

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -40
app.py CHANGED
@@ -125,113 +125,112 @@ def get_emotional_tone_tag(emotion_profile, patterns, text_lower):
125
  if lex_counts["joy"] > 0 and any(k in text_lower for k in ["support","hope","grace"]):
126
  return "supportive"
127
 
128
- + # 1. Performative Regret
129
- + # → only when we see one of those patterns, not just lexicon hits
130
- + if sadness > 0.4 \
131
- + and any(p in patterns for p in ["blame shifting","guilt tripping","recovery phase"]):
132
- + return "performative regret"
133
 
134
  # 2. Coercive Warmth
135
  if (joy > 0.3 or sadness > 0.4) \
136
- and (lex_counts["joy"] > 0 or lex_counts["sadness"] > 0) \
137
- and any(p in patterns for p in ["control","gaslighting"]):
138
  return "coercive warmth"
139
 
140
  # 3. Cold Invalidation
141
  if (neutral + disgust) > 0.5 \
142
- and lex_counts["disgust"] > 0 \
143
- and any(p in patterns for p in ["dismissiveness","projection","obscure language"]):
144
  return "cold invalidation"
145
 
146
  # 4. Genuine Vulnerability
147
  if (sadness + fear) > 0.5 \
148
- and lex_counts["sadness"] > 0 and lex_counts["fear"] > 0 \
149
- and all(p == "recovery phase" for p in patterns):
150
  return "genuine vulnerability"
151
 
152
  # 5. Emotional Threat
153
  if (anger + disgust) > 0.5 \
154
- and (lex_counts["anger"] > 0 or lex_counts["disgust"] > 0) \
155
- and any(p in patterns for p in ["control","threat","insults","dismissiveness"]):
156
  return "emotional threat"
157
 
158
  # 6. Weaponized Sadness
159
  if sadness > 0.6 \
160
- and lex_counts["sadness"] > 0 \
161
- and any(p in patterns for p in ["guilt tripping","projection"]):
162
  return "weaponized sadness"
163
 
164
  # 7. Toxic Resignation
165
  if neutral > 0.5 \
166
- and any(p in patterns for p in ["dismissiveness","obscure language"]) \
167
- and lex_counts["disgust"] == 0:
168
  return "toxic resignation"
169
 
170
  # 8. Indignant Reproach
171
  if anger > 0.5 \
172
- and lex_counts["anger"] > 0 \
173
- and any(p in patterns for p in ["guilt tripping","contradictory statements"]):
174
  return "indignant reproach"
175
 
176
  # 9. Confrontational
177
  if anger > 0.6 \
178
- and lex_counts["anger"] > 0 \
179
- and patterns:
180
  return "confrontational"
181
 
182
  # 10. Passive Aggression
183
  if neutral > 0.6 \
184
- and lex_counts["disgust"] > 0 \
185
- and any(p in patterns for p in ["dismissiveness","projection"]):
186
  return "passive aggression"
187
 
188
  # 11. Sarcastic Mockery
189
  if joy > 0.3 \
190
- and lex_counts["joy"] > 0 \
191
- and "insults" in patterns:
192
  return "sarcastic mockery"
193
 
194
  # 12. Menacing Threat
195
  if fear > 0.3 \
196
- and lex_counts["fear"] > 0 \
197
- and "threat" in patterns:
198
  return "menacing threat"
199
 
200
  # 13. Pleading Concern
201
  if sadness > 0.3 \
202
- and lex_counts["sadness"] > 0 \
203
- and any(k in text_lower for k in APOLOGY_KEYWORDS) \
204
- and not patterns:
205
  return "pleading concern"
206
 
207
  # 14. Fear-mongering
208
  if (fear + disgust) > 0.5 \
209
- and lex_counts["fear"] > 0 \
210
- and "projection" in patterns:
211
  return "fear-mongering"
212
 
213
  # 15. Disbelieving Accusation
214
  if surprise > 0.3 \
215
- and lex_counts["surprise"] > 0 \
216
- and "blame shifting" in patterns:
217
  return "disbelieving accusation"
218
 
219
  # 16. Empathetic Solidarity
220
  if joy > 0.2 and sadness > 0.2 \
221
- and lex_counts["joy"] > 0 and lex_counts["sadness"] > 0 \
222
- and not patterns:
223
  return "empathetic solidarity"
224
 
225
  # 17. Assertive Boundary
226
  if anger > 0.4 \
227
- and lex_counts["anger"] > 0 \
228
- and "control" in patterns:
229
  return "assertive boundary"
230
 
231
  # 18. Stonewalling
232
  if neutral > 0.7 \
233
- and lex_counts["disgust"] == 0 \
234
- and not patterns:
235
  return "stonewalling"
236
 
237
  return None
 
125
  if lex_counts["joy"] > 0 and any(k in text_lower for k in ["support","hope","grace"]):
126
  return "supportive"
127
 
128
+
129
+ if sadness > 0.4 \
130
+ and any(p in patterns for p in ["blame shifting","guilt tripping","recovery phase"]):
131
+ return "performative regret"
 
132
 
133
  # 2. Coercive Warmth
134
  if (joy > 0.3 or sadness > 0.4) \
135
+ and (lex_counts["joy"] > 0 or lex_counts["sadness"] > 0) \
136
+ and any(p in patterns for p in ["control","gaslighting"]):
137
  return "coercive warmth"
138
 
139
  # 3. Cold Invalidation
140
  if (neutral + disgust) > 0.5 \
141
+ and lex_counts["disgust"] > 0 \
142
+ and any(p in patterns for p in ["dismissiveness","projection","obscure language"]):
143
  return "cold invalidation"
144
 
145
  # 4. Genuine Vulnerability
146
  if (sadness + fear) > 0.5 \
147
+ and lex_counts["sadness"] > 0 and lex_counts["fear"] > 0 \
148
+ and all(p == "recovery phase" for p in patterns):
149
  return "genuine vulnerability"
150
 
151
  # 5. Emotional Threat
152
  if (anger + disgust) > 0.5 \
153
+ and (lex_counts["anger"] > 0 or lex_counts["disgust"] > 0) \
154
+ and any(p in patterns for p in ["control","threat","insults","dismissiveness"]):
155
  return "emotional threat"
156
 
157
  # 6. Weaponized Sadness
158
  if sadness > 0.6 \
159
+ and lex_counts["sadness"] > 0 \
160
+ and any(p in patterns for p in ["guilt tripping","projection"]):
161
  return "weaponized sadness"
162
 
163
  # 7. Toxic Resignation
164
  if neutral > 0.5 \
165
+ and any(p in patterns for p in ["dismissiveness","obscure language"]) \
166
+ and lex_counts["disgust"] == 0:
167
  return "toxic resignation"
168
 
169
  # 8. Indignant Reproach
170
  if anger > 0.5 \
171
+ and lex_counts["anger"] > 0 \
172
+ and any(p in patterns for p in ["guilt tripping","contradictory statements"]):
173
  return "indignant reproach"
174
 
175
  # 9. Confrontational
176
  if anger > 0.6 \
177
+ and lex_counts["anger"] > 0 \
178
+ and patterns:
179
  return "confrontational"
180
 
181
  # 10. Passive Aggression
182
  if neutral > 0.6 \
183
+ and lex_counts["disgust"] > 0 \
184
+ and any(p in patterns for p in ["dismissiveness","projection"]):
185
  return "passive aggression"
186
 
187
  # 11. Sarcastic Mockery
188
  if joy > 0.3 \
189
+ and lex_counts["joy"] > 0 \
190
+ and "insults" in patterns:
191
  return "sarcastic mockery"
192
 
193
  # 12. Menacing Threat
194
  if fear > 0.3 \
195
+ and lex_counts["fear"] > 0 \
196
+ and "threat" in patterns:
197
  return "menacing threat"
198
 
199
  # 13. Pleading Concern
200
  if sadness > 0.3 \
201
+ and lex_counts["sadness"] > 0 \
202
+ and any(k in text_lower for k in APOLOGY_KEYWORDS) \
203
+ and not patterns:
204
  return "pleading concern"
205
 
206
  # 14. Fear-mongering
207
  if (fear + disgust) > 0.5 \
208
+ and lex_counts["fear"] > 0 \
209
+ and "projection" in patterns:
210
  return "fear-mongering"
211
 
212
  # 15. Disbelieving Accusation
213
  if surprise > 0.3 \
214
+ and lex_counts["surprise"] > 0 \
215
+ and "blame shifting" in patterns:
216
  return "disbelieving accusation"
217
 
218
  # 16. Empathetic Solidarity
219
  if joy > 0.2 and sadness > 0.2 \
220
+ and lex_counts["joy"] > 0 and lex_counts["sadness"] > 0 \
221
+ and not patterns:
222
  return "empathetic solidarity"
223
 
224
  # 17. Assertive Boundary
225
  if anger > 0.4 \
226
+ and lex_counts["anger"] > 0 \
227
+ and "control" in patterns:
228
  return "assertive boundary"
229
 
230
  # 18. Stonewalling
231
  if neutral > 0.7 \
232
+ and lex_counts["disgust"] == 0 \
233
+ and not patterns:
234
  return "stonewalling"
235
 
236
  return None