Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -475,7 +475,7 @@ How I'll mark:
|
|
| 475 |
- 150β200 β 3β
|
| 476 |
- 200β250 β 4β
|
| 477 |
- 250+ β 5β
|
| 478 |
-
|
| 479 |
|
| 480 |
Write clearly, think deeply, and press **Grade & Save!**
|
| 481 |
"""
|
|
@@ -529,34 +529,50 @@ STUDENT SUMMARY (ORIGINAL TEXT BELOW):
|
|
| 529 |
if not knows_story:
|
| 530 |
comp = None
|
| 531 |
|
|
|
|
| 532 |
wc = count_words(student_summary)
|
| 533 |
len_s = length_stars(wc)
|
| 534 |
grammar_count = len(issues)
|
| 535 |
grammar_star = round(grammar_stars_from_count(grammar_count), 1)
|
| 536 |
|
|
|
|
| 537 |
vals = [float(expr), float(refl), float(len_s), float(grammar_star)]
|
| 538 |
if knows_story and comp is not None:
|
| 539 |
vals.append(float(comp))
|
|
|
|
|
|
|
| 540 |
avg = round(sum(vals) / len(vals), 2) if vals else 0.0
|
| 541 |
-
# APPLY THE -1 STAR PENALTY
|
| 542 |
-
penalty_applied = False
|
| 543 |
-
if is_nonsense_ai or is_repetitive_math:
|
| 544 |
-
avg = max(0.0, round(avg - 1.0, 2))
|
| 545 |
-
penalty_applied = True
|
| 546 |
|
| 547 |
-
#
|
| 548 |
-
|
| 549 |
-
md.append(f"### π Summary Grading Report")
|
| 550 |
|
| 551 |
-
|
| 552 |
-
|
| 553 |
-
|
| 554 |
-
|
|
|
|
|
|
|
| 555 |
|
| 556 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 557 |
md = []
|
| 558 |
md.append(f"### π Summary Grading Report")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 559 |
md.append(f"**Name:** {student_name} **Class:** {student_class}")
|
|
|
|
| 560 |
md.append(f"**Title:** {title}")
|
| 561 |
md.append(f"**Word count:** {wc}")
|
| 562 |
md.append("")
|
|
|
|
| 475 |
- 150β200 β 3β
|
| 476 |
- 200β250 β 4β
|
| 477 |
- 250+ β 5β
|
| 478 |
+
Writing Nonsense will invite negative star
|
| 479 |
|
| 480 |
Write clearly, think deeply, and press **Grade & Save!**
|
| 481 |
"""
|
|
|
|
| 529 |
if not knows_story:
|
| 530 |
comp = None
|
| 531 |
|
| 532 |
+
# ======================== START OF REPLACEMENT ========================
|
| 533 |
wc = count_words(student_summary)
|
| 534 |
len_s = length_stars(wc)
|
| 535 |
grammar_count = len(issues)
|
| 536 |
grammar_star = round(grammar_stars_from_count(grammar_count), 1)
|
| 537 |
|
| 538 |
+
# Base values for calculation
|
| 539 |
vals = [float(expr), float(refl), float(len_s), float(grammar_star)]
|
| 540 |
if knows_story and comp is not None:
|
| 541 |
vals.append(float(comp))
|
| 542 |
+
|
| 543 |
+
# Initial average calculation
|
| 544 |
avg = round(sum(vals) / len(vals), 2) if vals else 0.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 545 |
|
| 546 |
+
# RUN NONSENSE & REPETITION CHECKS
|
| 547 |
+
rep_ratio = check_repetition_ratio(student_summary)
|
|
|
|
| 548 |
|
| 549 |
+
# Determine specific penalty reasons
|
| 550 |
+
reasons = []
|
| 551 |
+
if is_nonsense_ai:
|
| 552 |
+
reasons.append("The AI teacher flagged this text as nonsense or gibberish.")
|
| 553 |
+
if rep_ratio < 0.30 and wc > 20:
|
| 554 |
+
reasons.append(f"High repetition detected. You only used {round(rep_ratio * 100)}% unique words.")
|
| 555 |
|
| 556 |
+
is_failing = len(reasons) > 0
|
| 557 |
+
|
| 558 |
+
# OVERRIDE SCORE IF FAILING (Absolute -1 Star)
|
| 559 |
+
if is_failing:
|
| 560 |
+
avg = -1.0
|
| 561 |
+
|
| 562 |
+
# Start building the Report
|
| 563 |
md = []
|
| 564 |
md.append(f"### π Summary Grading Report")
|
| 565 |
+
|
| 566 |
+
if is_failing:
|
| 567 |
+
md.append("> ## β FINAL SCORE: -1 STAR")
|
| 568 |
+
md.append("> **Penalty Reason(s):**")
|
| 569 |
+
for r in reasons:
|
| 570 |
+
md.append(f"> * {r}")
|
| 571 |
+
md.append("> \n> *Please write a real summary in your own words to receive a valid grade.*")
|
| 572 |
+
md.append("")
|
| 573 |
+
|
| 574 |
md.append(f"**Name:** {student_name} **Class:** {student_class}")
|
| 575 |
+
# ========================= END OF REPLACEMENT =========================
|
| 576 |
md.append(f"**Title:** {title}")
|
| 577 |
md.append(f"**Word count:** {wc}")
|
| 578 |
md.append("")
|