SamanthaStorm commited on
Commit
1bd01b0
·
verified ·
1 Parent(s): 7119e2f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -183,8 +183,7 @@ def analyze_single_message(text, thresholds):
183
  }
184
 
185
  contradiction_flag = detect_contradiction(text)
186
-
187
- )
188
  inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
189
  with torch.no_grad():
190
  outputs = model(**inputs)
@@ -193,15 +192,17 @@ def analyze_single_message(text, thresholds):
193
  threshold_labels = [
194
  label for label, score in zip(LABELS, scores)
195
  if score > adjusted_thresholds[label]
196
- ]
 
197
  motifs = [phrase for _, phrase in matched_phrases]
 
198
  darvo_score = calculate_darvo_score(
199
- pattern_labels,
200
  sentiment_before=0.0,
201
  sentiment_after=sentiment_score,
202
  motifs_found=motifs,
203
  contradiction_flag=contradiction_flag
204
-
205
  top_patterns = sorted(
206
  [(label, score) for label, score in zip(LABELS, scores)],
207
  key=lambda x: x[1],
@@ -273,7 +274,7 @@ def analyze_composite(msg1, msg2, msg3, *answers_and_none):
273
  level = "moderate" if avg_darvo < 0.65 else "high"
274
  out += f"\n\n🎭 **DARVO Score: {avg_darvo}** → This indicates a **{level} likelihood** of narrative reversal (DARVO), where the speaker may be denying, attacking, or reversing blame."
275
 
276
- return out
277
 
278
  textbox_inputs = [gr.Textbox(label=f"Message {i+1}") for i in range(3)]
279
  quiz_boxes = [gr.Checkbox(label=q) for q, _ in ESCALATION_QUESTIONS]
 
183
  }
184
 
185
  contradiction_flag = detect_contradiction(text)
186
+
 
187
  inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
188
  with torch.no_grad():
189
  outputs = model(**inputs)
 
192
  threshold_labels = [
193
  label for label, score in zip(LABELS, scores)
194
  if score > adjusted_thresholds[label]
195
+ ]
196
+
197
  motifs = [phrase for _, phrase in matched_phrases]
198
+
199
  darvo_score = calculate_darvo_score(
200
+ threshold_labels,
201
  sentiment_before=0.0,
202
  sentiment_after=sentiment_score,
203
  motifs_found=motifs,
204
  contradiction_flag=contradiction_flag
205
+ )
206
  top_patterns = sorted(
207
  [(label, score) for label, score in zip(LABELS, scores)],
208
  key=lambda x: x[1],
 
274
  level = "moderate" if avg_darvo < 0.65 else "high"
275
  out += f"\n\n🎭 **DARVO Score: {avg_darvo}** → This indicates a **{level} likelihood** of narrative reversal (DARVO), where the speaker may be denying, attacking, or reversing blame."
276
 
277
+ return out
278
 
279
  textbox_inputs = [gr.Textbox(label=f"Message {i+1}") for i in range(3)]
280
  quiz_boxes = [gr.Checkbox(label=q) for q, _ in ESCALATION_QUESTIONS]