Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -140,12 +140,17 @@ def detect_contradiction(message):
|
|
140 |
def calculate_darvo_score(patterns, sentiment_before, sentiment_after, motifs_found, contradiction_flag=False):
|
141 |
pattern_hits = len([p for p in patterns if p in DARVO_PATTERNS])
|
142 |
pattern_score = pattern_hits / len(DARVO_PATTERNS)
|
143 |
-
|
144 |
-
sentiment_shift_score = max(0.0, sentiment_after - sentiment_before)
|
145 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
motif_hits = len([
|
147 |
-
|
148 |
-
if
|
149 |
])
|
150 |
motif_score = motif_hits / len(DARVO_MOTIFS)
|
151 |
|
|
|
140 |
def calculate_darvo_score(patterns, sentiment_before, sentiment_after, motifs_found, contradiction_flag=False):
|
141 |
pattern_hits = len([p for p in patterns if p in DARVO_PATTERNS])
|
142 |
pattern_score = pattern_hits / len(DARVO_PATTERNS)
|
|
|
|
|
143 |
|
144 |
+
# 🎯 New: If 2+ DARVO patterns are hit, ignore sentiment discount
|
145 |
+
if pattern_hits >= 2:
|
146 |
+
sentiment_shift_score = 0.2
|
147 |
+
else:
|
148 |
+
sentiment_shift_score = max(0.0, sentiment_after - sentiment_before)
|
149 |
+
|
150 |
+
text_lower = " ".join(motifs_found).lower()
|
151 |
motif_hits = len([
|
152 |
+
phrase for phrase in DARVO_MOTIFS
|
153 |
+
if phrase.lower() in text_lower
|
154 |
])
|
155 |
motif_score = motif_hits / len(DARVO_MOTIFS)
|
156 |
|