Add writing task 1 grading.
This commit is contained in:
@@ -2,12 +2,60 @@ from enum import Enum
|
||||
|
||||
|
||||
class QuestionType(Enum):
|
||||
WRITING_TASK_1 = "Writing Task 1"
|
||||
WRITING_TASK_2 = "Writing Task 2"
|
||||
SPEAKING = "Speaking Task"
|
||||
|
||||
|
||||
def get_grading_messages(question_type: QuestionType, question: str, answer: str):
|
||||
if QuestionType.WRITING_TASK_2 == question_type:
|
||||
def get_grading_messages(question_type: QuestionType, question: str, answer: str, context: str = None):
|
||||
if QuestionType.WRITING_TASK_1 == question_type:
|
||||
messages = [
|
||||
{
|
||||
"role": "user",
|
||||
"content": "You are a IELTS examiner.",
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": f"The question you have to grade is of type Writing Task 1 and is the following: {question}",
|
||||
}
|
||||
]
|
||||
|
||||
if not (context is None or context == ""):
|
||||
messages.append({
|
||||
"role": "user",
|
||||
"content": f"To grade the previous question, bear in mind the following context: {context}",
|
||||
})
|
||||
|
||||
messages.extend([
|
||||
{
|
||||
"role": "user",
|
||||
"content": "It is mandatory for you to provide your response with the overall grade and breakdown grades, "
|
||||
"with just the following json format: {'comment': 'comment about answer quality', 'overall': 7.0, "
|
||||
"'task_response': {'Task Achievement': 8.0, 'Coherence and Cohesion': 6.5, 'Lexical Resource': 7.5, "
|
||||
"'Grammatical Range and Accuracy': 6.0}}",
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Example output: { 'comment': 'Overall, the response is good but there are some areas that need "
|
||||
"improvement.\n\nIn terms of Task Achievement, the writer has addressed all parts of the question "
|
||||
"and has provided a clear opinion on the topic. However, some of the points made are not fully "
|
||||
"developed or supported with examples.\n\nIn terms of Coherence and Cohesion, there is a clear "
|
||||
"structure to the response with an introduction, body paragraphs and conclusion. However, there "
|
||||
"are some issues with cohesion as some sentences do not flow smoothly from one to another.\n\nIn "
|
||||
"terms of Lexical Resource, there is a good range of vocabulary used throughout the response and "
|
||||
"some less common words have been used effectively.\n\nIn terms of Grammatical Range and Accuracy, "
|
||||
"there are some errors in grammar and sentence structure which affect clarity in places.\n\nOverall, "
|
||||
"this response would score a band 6.5.', 'overall': 6.5, 'task_response': "
|
||||
"{ 'Coherence and Cohesion': 6.5, 'Grammatical Range and Accuracy': 6.0, 'Lexical Resource': 7.0, "
|
||||
"'Task Achievement': 7.0}}",
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": f"Evaluate this answer according to ielts grading system: {answer}",
|
||||
},
|
||||
])
|
||||
return messages
|
||||
elif QuestionType.WRITING_TASK_2 == question_type:
|
||||
return [
|
||||
{
|
||||
"role": "user",
|
||||
|
||||
Reference in New Issue
Block a user