Update app.py
Browse files
app.py
CHANGED
@@ -125,14 +125,13 @@ def detect_grammar_errors(text):
|
|
125 |
|
126 |
|
127 |
def penalize_for_grammar(student_answer):
|
128 |
-
grammar_errors = detect_grammar_errors(student_answer)
|
129 |
-
print(f"Grammar errors detected: {grammar_errors}")
|
130 |
|
131 |
-
# Apply a penalty based on the number of grammar errors (max
|
132 |
penalty = max(0.3, 1 - 0.1 * grammar_errors)
|
133 |
-
print(f"Grammar penalty applied: {penalty}")
|
134 |
return penalty
|
135 |
|
|
|
136 |
def compare_answers(student_answer, teacher_answer):
|
137 |
bert_similarity = calculate_cosine_similarity(get_bert_embedding(student_answer), get_bert_embedding(teacher_answer))
|
138 |
print(f"BERT similarity: {bert_similarity}")
|
|
|
125 |
|
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.3, 1 - 0.1 * grammar_errors)
|
|
|
132 |
return penalty
|
133 |
|
134 |
+
|
135 |
def compare_answers(student_answer, teacher_answer):
|
136 |
bert_similarity = calculate_cosine_similarity(get_bert_embedding(student_answer), get_bert_embedding(teacher_answer))
|
137 |
print(f"BERT similarity: {bert_similarity}")
|