Double check for english words in writing grading.

This commit is contained in:
Cristiano Ferreira
2024-06-11 21:45:56 +01:00
parent 3676d7ad39
commit 7637322239
2 changed files with 10 additions and 2 deletions

12
app.py
View File

@@ -218,7 +218,7 @@ def grade_writing_task_1():
answer = data.get('answer') answer = data.get('answer')
if not has_words(answer): if not has_words(answer):
return { return {
'comment': "The answer does not contain any english words.", 'comment': "The answer does not contain enough english words.",
'overall': 0, 'overall': 0,
'task_response': { 'task_response': {
'Coherence and Cohesion': 0, 'Coherence and Cohesion': 0,
@@ -256,6 +256,10 @@ def grade_writing_task_1():
'Additionally, provide an exemplary answer with a minimum of 150 words, along with a ' 'Additionally, provide an exemplary answer with a minimum of 150 words, along with a '
'detailed commentary highlighting both strengths and weaknesses in the response. ' 'detailed commentary highlighting both strengths and weaknesses in the response. '
'\n Question: "' + question + '" \n Answer: "' + answer + '"') '\n Question: "' + question + '" \n Answer: "' + answer + '"')
},
{
"role": "user",
"content": 'The perfect answer must have at least 150 words.'
} }
] ]
token_count = count_total_tokens(messages) token_count = count_total_tokens(messages)
@@ -314,7 +318,7 @@ def grade_writing_task_2():
answer = data.get('answer') answer = data.get('answer')
if not has_words(answer): if not has_words(answer):
return { return {
'comment': "The answer does not contain any english words.", 'comment': "The answer does not contain enough english words.",
'overall': 0, 'overall': 0,
'task_response': { 'task_response': {
'Coherence and Cohesion': 0, 'Coherence and Cohesion': 0,
@@ -353,6 +357,10 @@ def grade_writing_task_2():
'exemplary answer with a minimum of 250 words, along with a detailed commentary highlighting ' 'exemplary answer with a minimum of 250 words, along with a detailed commentary highlighting '
'both strengths and weaknesses in the response.' 'both strengths and weaknesses in the response.'
'\n Question: "' + question + '" \n Answer: "' + answer + '"') '\n Question: "' + question + '" \n Answer: "' + answer + '"')
},
{
"role": "user",
"content": 'The perfect answer must have at least 250 words.'
} }
] ]
token_count = count_total_tokens(messages) token_count = count_total_tokens(messages)

Binary file not shown.