Update app.py
Browse files
app.py
CHANGED
@@ -128,7 +128,7 @@ 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.
|
132 |
return penalty
|
133 |
|
134 |
|
@@ -140,7 +140,7 @@ def compare_answers(student_answer, teacher_answer):
|
|
140 |
print(f"Sentence similarity: {sentence_similarity}")
|
141 |
|
142 |
# Use a higher weight for BERT similarity
|
143 |
-
semantic_similarity = (0.
|
144 |
print(f"Semantic similarity: {semantic_similarity}")
|
145 |
|
146 |
# Apply grammar penalty
|
|
|
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, 1 - 0.1 * grammar_errors)
|
132 |
return penalty
|
133 |
|
134 |
|
|
|
140 |
print(f"Sentence similarity: {sentence_similarity}")
|
141 |
|
142 |
# Use a higher weight for BERT similarity
|
143 |
+
semantic_similarity = (0.50 * bert_similarity + 0.50 * sentence_similarity)
|
144 |
print(f"Semantic similarity: {semantic_similarity}")
|
145 |
|
146 |
# Apply grammar penalty
|