Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -25,7 +25,7 @@ def get_model():
|
|
| 25 |
).to(device).eval()
|
| 26 |
return tokenizer, model
|
| 27 |
|
| 28 |
-
# UPDATED: Threshold
|
| 29 |
THRESHOLD = 0.59
|
| 30 |
|
| 31 |
# -----------------------------
|
|
@@ -72,7 +72,7 @@ def analyze(text):
|
|
| 72 |
return "—", "—", "<em>Please enter text...</em>", None
|
| 73 |
|
| 74 |
word_count = len(text.split())
|
| 75 |
-
# Word count
|
| 76 |
if word_count < 300:
|
| 77 |
warning_msg = f"⚠️ <b>Insufficient Text:</b> Your input has {word_count} words. Please enter at least 300 words for an accurate analysis."
|
| 78 |
return "Too Short", "N/A", f"<div style='color: #b80d0d; padding: 20px; border: 1px solid #b80d0d; border-radius: 8px;'>{warning_msg}</div>", None
|
|
@@ -104,7 +104,7 @@ def analyze(text):
|
|
| 104 |
weighted_avg = sum(p * l for p, l in zip(probs, lengths)) / total_words if total_words > 0 else 0
|
| 105 |
|
| 106 |
# -----------------------------
|
| 107 |
-
# HTML RECONSTRUCTION
|
| 108 |
# -----------------------------
|
| 109 |
highlighted_html = "<div style='font-family: sans-serif; line-height: 1.8;'>"
|
| 110 |
prob_map = {idx: probs[i] for i, idx in enumerate(pure_sents_indices)}
|
|
@@ -116,7 +116,7 @@ def analyze(text):
|
|
| 116 |
|
| 117 |
if i in prob_map:
|
| 118 |
score = prob_map[i]
|
| 119 |
-
#
|
| 120 |
if score >= THRESHOLD:
|
| 121 |
color, bg = "#b80d0d", "rgba(184, 13, 13, 0.15)" # RED
|
| 122 |
else:
|
|
|
|
| 25 |
).to(device).eval()
|
| 26 |
return tokenizer, model
|
| 27 |
|
| 28 |
+
# UPDATED: Threshold set to 59% for visual triggers
|
| 29 |
THRESHOLD = 0.59
|
| 30 |
|
| 31 |
# -----------------------------
|
|
|
|
| 72 |
return "—", "—", "<em>Please enter text...</em>", None
|
| 73 |
|
| 74 |
word_count = len(text.split())
|
| 75 |
+
# Word count requirement restored to 300
|
| 76 |
if word_count < 300:
|
| 77 |
warning_msg = f"⚠️ <b>Insufficient Text:</b> Your input has {word_count} words. Please enter at least 300 words for an accurate analysis."
|
| 78 |
return "Too Short", "N/A", f"<div style='color: #b80d0d; padding: 20px; border: 1px solid #b80d0d; border-radius: 8px;'>{warning_msg}</div>", None
|
|
|
|
| 104 |
weighted_avg = sum(p * l for p, l in zip(probs, lengths)) / total_words if total_words > 0 else 0
|
| 105 |
|
| 106 |
# -----------------------------
|
| 107 |
+
# HTML RECONSTRUCTION (Highlights trigger at THRESHOLD)
|
| 108 |
# -----------------------------
|
| 109 |
highlighted_html = "<div style='font-family: sans-serif; line-height: 1.8;'>"
|
| 110 |
prob_map = {idx: probs[i] for i, idx in enumerate(pure_sents_indices)}
|
|
|
|
| 116 |
|
| 117 |
if i in prob_map:
|
| 118 |
score = prob_map[i]
|
| 119 |
+
# Color determined by the new 59% threshold
|
| 120 |
if score >= THRESHOLD:
|
| 121 |
color, bg = "#b80d0d", "rgba(184, 13, 13, 0.15)" # RED
|
| 122 |
else:
|