SamanthaStorm commited on
Commit
8ced90a
·
verified ·
1 Parent(s): 4fafefc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -0
app.py CHANGED
@@ -404,6 +404,11 @@ def analyze_single_message(text, thresholds):
404
  label_scores = {label: score for label, score in zip(LABELS, scores)}
405
  passed = {label: score for label in threshold_labels if label in label_scores}
406
 
 
 
 
 
 
407
  if passed:
408
  top_score = max(passed.values())
409
  close_matches = {label: score for label, score in passed.items() if (top_score - score) <= 0.05}
 
404
  label_scores = {label: score for label, score in zip(LABELS, scores)}
405
  passed = {label: score for label in threshold_labels if label in label_scores}
406
 
407
+ # 🛡️ Prevent obscure language from being chosen unless it crosses a hard threshold
408
+ MIN_OBSCURE_SCORE = 0.30
409
+ if "obscure language" in passed and passed["obscure language"] < MIN_OBSCURE_SCORE:
410
+ del passed["obscure language"]
411
+
412
  if passed:
413
  top_score = max(passed.values())
414
  close_matches = {label: score for label, score in passed.items() if (top_score - score) <= 0.05}