VictorM-Coder commited on
Commit
a6b5e2a
·
verified ·
1 Parent(s): 34ea950

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -25,7 +25,7 @@ def get_model():
25
  ).to(device).eval()
26
  return tokenizer, model
27
 
28
- # UPDATED: Threshold changed from 0.81 to 0.59
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 remains at 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,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
- # Logic now uses the 0.59 threshold
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: