Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -410,10 +410,10 @@ def analyze_single_message(text, thresholds):
|
|
410 |
del passed["obscure language"]
|
411 |
|
412 |
if passed:
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
else:
|
418 |
top_pattern_label, top_pattern_score = top_patterns[0]
|
419 |
matched_scores = [
|
|
|
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}
|
415 |
+
sorted_close = sorted(close_matches.items(), key=lambda x: ESCALATION_HIERARCHY.index(x[0]))
|
416 |
+
top_pattern_label, top_pattern_score = sorted_close[0]
|
417 |
else:
|
418 |
top_pattern_label, top_pattern_score = top_patterns[0]
|
419 |
matched_scores = [
|