vcelegance / Scoring System.py
ehsannotes's picture
Rename app.py to Scoring System.py
0d434f4 verified
# scoring.py
BAND_CRITERIA = {
'vocab': {
9: {"threshold": 0.9, "description": "Sophisticated lexical items"},
8: {"threshold": 0.8, "description": "Wide resource, occasional errors"},
7: {"threshold": 0.7, "description": "Adequate range"},
6: {"threshold": 0.6, "description": "Limited range"}
},
'grammar': {
9: {"errors": 0, "description": "Virtually error-free"},
8: {"errors": 2, "description": "Rare minor errors"},
7: {"errors": 4, "description": "Some errors"},
6: {"errors": 6, "description": "Frequent errors"}
}
}
def convert_to_band(raw_score, category):
"""Convert raw model output to IELTS band"""
bands = sorted(BAND_CRITERIA[category].items(), reverse=True)
for band, criteria in bands:
if category == 'vocab' and raw_score >= criteria['threshold']:
return band
elif category == 'grammar' and raw_score <= criteria['errors']:
return band
return 4 # Minimum band