Garvitj commited on
Commit
ef7ef20
·
verified ·
1 Parent(s): 62d27f2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
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.8, 1 - 0.1 * grammar_errors)
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.60 * bert_similarity + 0.40 * sentence_similarity)
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