Improve speaking grading
This commit is contained in:
28
app.py
28
app.py
@@ -97,7 +97,8 @@ def get_listening_section_2_question():
|
|||||||
|
|
||||||
app.logger.info("Generated monologue: " + str(monologue))
|
app.logger.info("Generated monologue: " + str(monologue))
|
||||||
start_id = 11
|
start_id = 11
|
||||||
exercises = generate_listening_monologue_exercises(monologue, req_exercises, number_of_exercises_q, start_id, difficulty)
|
exercises = generate_listening_monologue_exercises(monologue, req_exercises, number_of_exercises_q, start_id,
|
||||||
|
difficulty)
|
||||||
return {
|
return {
|
||||||
"exercises": exercises,
|
"exercises": exercises,
|
||||||
"text": monologue,
|
"text": monologue,
|
||||||
@@ -158,7 +159,8 @@ def get_listening_section_4_question():
|
|||||||
|
|
||||||
app.logger.info("Generated monologue: " + str(monologue))
|
app.logger.info("Generated monologue: " + str(monologue))
|
||||||
start_id = 31
|
start_id = 31
|
||||||
exercises = generate_listening_monologue_exercises(monologue, req_exercises, number_of_exercises_q, start_id, difficulty)
|
exercises = generate_listening_monologue_exercises(monologue, req_exercises, number_of_exercises_q, start_id,
|
||||||
|
difficulty)
|
||||||
return {
|
return {
|
||||||
"exercises": exercises,
|
"exercises": exercises,
|
||||||
"text": monologue,
|
"text": monologue,
|
||||||
@@ -378,7 +380,7 @@ def grade_speaking_task_1():
|
|||||||
token_count = count_tokens(message)["n_tokens"]
|
token_count = count_tokens(message)["n_tokens"]
|
||||||
response = make_openai_instruct_call(GPT_3_5_TURBO_INSTRUCT, message, token_count,
|
response = make_openai_instruct_call(GPT_3_5_TURBO_INSTRUCT, message, token_count,
|
||||||
["comment"],
|
["comment"],
|
||||||
GEN_QUESTION_TEMPERATURE)
|
GRADING_TEMPERATURE)
|
||||||
perfect_answer_message = ("Provide a perfect answer according to ielts grading system to the following "
|
perfect_answer_message = ("Provide a perfect answer according to ielts grading system to the following "
|
||||||
"Speaking Part 1 question: '" + question + "'")
|
"Speaking Part 1 question: '" + question + "'")
|
||||||
token_count = count_tokens(perfect_answer_message)["n_tokens"]
|
token_count = count_tokens(perfect_answer_message)["n_tokens"]
|
||||||
@@ -389,6 +391,11 @@ def grade_speaking_task_1():
|
|||||||
GEN_QUESTION_TEMPERATURE)
|
GEN_QUESTION_TEMPERATURE)
|
||||||
response['transcript'] = answer
|
response['transcript'] = answer
|
||||||
response['fixed_text'] = get_speaking_corrections(answer)
|
response['fixed_text'] = get_speaking_corrections(answer)
|
||||||
|
if response["overall"] == "0.0" or response["overall"] == 0.0:
|
||||||
|
response["overall"] = round((response["task_response"]["Fluency and Coherence"] +
|
||||||
|
response["task_response"]["Lexical Resource"] + response["task_response"][
|
||||||
|
"Grammatical Range and Accuracy"] + response["task_response"][
|
||||||
|
"Pronunciation"]) / 4, 1)
|
||||||
return response
|
return response
|
||||||
else:
|
else:
|
||||||
return {
|
return {
|
||||||
@@ -453,7 +460,7 @@ def grade_speaking_task_2():
|
|||||||
token_count = count_tokens(message)["n_tokens"]
|
token_count = count_tokens(message)["n_tokens"]
|
||||||
response = make_openai_instruct_call(GPT_3_5_TURBO_INSTRUCT, message, token_count,
|
response = make_openai_instruct_call(GPT_3_5_TURBO_INSTRUCT, message, token_count,
|
||||||
["comment"],
|
["comment"],
|
||||||
GEN_QUESTION_TEMPERATURE)
|
GRADING_TEMPERATURE)
|
||||||
perfect_answer_message = ("Provide a perfect answer according to ielts grading system to the following "
|
perfect_answer_message = ("Provide a perfect answer according to ielts grading system to the following "
|
||||||
"Speaking Part 2 question: '" + question + "'")
|
"Speaking Part 2 question: '" + question + "'")
|
||||||
token_count = count_tokens(perfect_answer_message)["n_tokens"]
|
token_count = count_tokens(perfect_answer_message)["n_tokens"]
|
||||||
@@ -464,6 +471,12 @@ def grade_speaking_task_2():
|
|||||||
GEN_QUESTION_TEMPERATURE)
|
GEN_QUESTION_TEMPERATURE)
|
||||||
response['transcript'] = answer
|
response['transcript'] = answer
|
||||||
response['fixed_text'] = get_speaking_corrections(answer)
|
response['fixed_text'] = get_speaking_corrections(answer)
|
||||||
|
if response["overall"] == "0.0" or response["overall"] == 0.0:
|
||||||
|
response["overall"] = round((response["task_response"]["Fluency and Coherence"] +
|
||||||
|
response["task_response"]["Lexical Resource"] + response["task_response"][
|
||||||
|
"Grammatical Range and Accuracy"] + response["task_response"][
|
||||||
|
"Pronunciation"]) / 4, 1)
|
||||||
|
|
||||||
return response
|
return response
|
||||||
else:
|
else:
|
||||||
return {
|
return {
|
||||||
@@ -586,13 +599,18 @@ def grade_speaking_task_3():
|
|||||||
token_count = count_tokens(message)["n_tokens"]
|
token_count = count_tokens(message)["n_tokens"]
|
||||||
response = make_openai_instruct_call(GPT_3_5_TURBO_INSTRUCT, message, token_count,
|
response = make_openai_instruct_call(GPT_3_5_TURBO_INSTRUCT, message, token_count,
|
||||||
["comment"],
|
["comment"],
|
||||||
GEN_QUESTION_TEMPERATURE)
|
GRADING_TEMPERATURE)
|
||||||
for i, answer in enumerate(perfect_answers, start=1):
|
for i, answer in enumerate(perfect_answers, start=1):
|
||||||
response['perfect_answer_' + str(i)] = answer
|
response['perfect_answer_' + str(i)] = answer
|
||||||
|
|
||||||
for i, answer in enumerate(text_answers, start=1):
|
for i, answer in enumerate(text_answers, start=1):
|
||||||
response['transcript_' + str(i)] = answer
|
response['transcript_' + str(i)] = answer
|
||||||
response['fixed_text_' + str(i)] = get_speaking_corrections(answer)
|
response['fixed_text_' + str(i)] = get_speaking_corrections(answer)
|
||||||
|
if response["overall"] == "0.0" or response["overall"] == 0.0:
|
||||||
|
response["overall"] = round((response["task_response"]["Fluency and Coherence"] + response["task_response"][
|
||||||
|
"Lexical Resource"] + response["task_response"]["Grammatical Range and Accuracy"] +
|
||||||
|
response["task_response"]["Pronunciation"]) / 4, 1)
|
||||||
|
|
||||||
return response
|
return response
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return str(e), 400
|
return str(e), 400
|
||||||
|
|||||||
Reference in New Issue
Block a user