Improve writing spellcheck to return fixed_text.

This commit is contained in:
Cristiano Ferreira
2024-01-17 16:11:29 +00:00
parent ccc606d5de
commit 92c92dfd98
7 changed files with 13 additions and 615 deletions

15
app.py
View File

@@ -194,8 +194,9 @@ def grade_writing_task_1():
if has_words(answer):
message = (
"Grade this Writing Task 1 answer according to ielts grading system and provide an example of a perfect "
"answer and an elaborated comment where you deep dive into what is wrong and right about the answer."
"Provide your answer on the following json format: {'perfect_answer': 'example perfect answer', 'comment': 'comment about answer quality', 'overall': 7.0, "
"answer (min 150 words) and an elaborated comment where you deep dive into what is wrong and right"
" about the answer. Provide your answer on the following json format: {'perfect_answer': 'example "
"perfect answer', 'comment': 'comment about answer quality', 'overall': 7.0, "
"'task_response': {'Task Achievement': 0.0, 'Coherence and Cohesion': 0.0, 'Lexical Resource': 0.0, "
"'Grammatical Range and Accuracy': 0.0}}\n The question was '" + question + "' "
"and the answer was '" + answer + "'")
@@ -203,7 +204,7 @@ def grade_writing_task_1():
response = make_openai_instruct_call(GPT_3_5_TURBO_INSTRUCT, message, token_count,
["comment"],
GEN_QUESTION_TEMPERATURE)
response['misspelled_pairs'] = get_misspelled_pairs(answer)
response['fixed_text'] = get_fixed_text(answer)
return response
else:
return {
@@ -247,9 +248,9 @@ def grade_writing_task_2():
if has_words(answer):
message = (
"Grade this Writing Task 2 answer according to ielts grading system and provide an example of a perfect "
"answer and an elaborated comment where you deep dive into what is wrong and right about the answer."
"Provide your answer on the following json format: {'perfect_answer': 'example perfect answer', "
"'comment': 'comment about answer quality', 'overall': 7.0, "
"answer (min 250 words) and an elaborated comment where you deep dive into what is wrong and right "
"about the answer. Provide your answer on the following json format: {'perfect_answer': 'example "
"perfect answer', 'comment': 'comment about answer quality', 'overall': 7.0, "
"'task_response': {'Task Achievement': 0.0, 'Coherence and Cohesion': 0.0, 'Lexical Resource': 0.0, "
"'Grammatical Range and Accuracy': 0.0}}\n The question was '" + question + "' "
"and the answer was '" + answer + "'")
@@ -257,7 +258,7 @@ def grade_writing_task_2():
response = make_openai_instruct_call(GPT_3_5_TURBO_INSTRUCT, message, token_count,
["comment"],
GEN_QUESTION_TEMPERATURE)
response['misspelled_pairs'] = get_misspelled_pairs(answer)
response['fixed_text'] = get_fixed_text(answer)
return response
else:
return {