Update app.py
Browse files
app.py
CHANGED
@@ -126,9 +126,9 @@ def detect_grammar_errors(text):
|
|
126 |
|
127 |
def penalize_for_grammar(student_answer):
|
128 |
grammar_errors, _ = detect_grammar_errors(student_answer) # Only take the first element (error count)
|
129 |
-
|
130 |
# Apply a penalty based on the number of grammar errors (max 70% penalty)
|
131 |
-
penalty = max(0, 1 - 0.
|
132 |
return penalty
|
133 |
|
134 |
|
@@ -145,7 +145,7 @@ def compare_answers(student_answer, teacher_answer):
|
|
145 |
|
146 |
# Apply grammar penalty
|
147 |
grammar_penalty = penalize_for_grammar(student_answer)
|
148 |
-
final_similarity = semantic_similarity
|
149 |
print(f"grammar penalty: {grammar_penalty}")
|
150 |
print(f"Final similarity (after grammar penalty): {final_similarity}")
|
151 |
|
|
|
126 |
|
127 |
def penalize_for_grammar(student_answer):
|
128 |
grammar_errors, _ = detect_grammar_errors(student_answer) # Only take the first element (error count)
|
129 |
+
print(f"errors given by grammer:{grammar_errors}")
|
130 |
# Apply a penalty based on the number of grammar errors (max 70% penalty)
|
131 |
+
penalty = max(0, 1 - 0.25 * grammar_errors)
|
132 |
return penalty
|
133 |
|
134 |
|
|
|
145 |
|
146 |
# Apply grammar penalty
|
147 |
grammar_penalty = penalize_for_grammar(student_answer)
|
148 |
+
final_similarity = semantic_similarity - grammar_penalty
|
149 |
print(f"grammar penalty: {grammar_penalty}")
|
150 |
print(f"Final similarity (after grammar penalty): {final_similarity}")
|
151 |
|