Listening part 1.

This commit is contained in:
Cristiano Ferreira
2024-06-25 20:49:27 +01:00
parent b93ead3a7b
commit 2adb7d1847
3 changed files with 23 additions and 4 deletions

5
app.py
View File

@@ -53,7 +53,7 @@ def get_listening_section_1_question():
difficulty = request.args.get("difficulty", default=random.choice(difficulties)) difficulty = request.args.get("difficulty", default=random.choice(difficulties))
if (len(req_exercises) == 0): if (len(req_exercises) == 0):
req_exercises = random.sample(LISTENING_EXERCISE_TYPES, 1) req_exercises = random.sample(LISTENING_1_EXERCISE_TYPES, 1)
number_of_exercises_q = divide_number_into_parts(TOTAL_LISTENING_SECTION_1_EXERCISES, len(req_exercises)) number_of_exercises_q = divide_number_into_parts(TOTAL_LISTENING_SECTION_1_EXERCISES, len(req_exercises))
@@ -62,7 +62,8 @@ def get_listening_section_1_question():
app.logger.info("Generated conversation: " + str(processed_conversation)) app.logger.info("Generated conversation: " + str(processed_conversation))
start_id = 1 start_id = 1
exercises = generate_listening_conversation_exercises(parse_conversation(processed_conversation), req_exercises, exercises = generate_listening_conversation_exercises(parse_conversation(processed_conversation),
req_exercises,
number_of_exercises_q, number_of_exercises_q,
start_id, difficulty) start_id, difficulty)
return { return {

View File

@@ -19,6 +19,8 @@ GEN_TEXT_FIELDS = ['title']
LISTENING_GEN_FIELDS = ['transcript', 'exercise'] LISTENING_GEN_FIELDS = ['transcript', 'exercise']
READING_EXERCISE_TYPES = ['fillBlanks', 'writeBlanks', 'trueFalse', 'paragraphMatch'] READING_EXERCISE_TYPES = ['fillBlanks', 'writeBlanks', 'trueFalse', 'paragraphMatch']
LISTENING_EXERCISE_TYPES = ['multipleChoice', 'writeBlanksQuestions', 'writeBlanksFill', 'writeBlanksForm'] LISTENING_EXERCISE_TYPES = ['multipleChoice', 'writeBlanksQuestions', 'writeBlanksFill', 'writeBlanksForm']
LISTENING_1_EXERCISE_TYPES = ['multipleChoice', 'writeBlanksQuestions', 'writeBlanksFill', 'writeBlanksFill',
'writeBlanksForm', 'writeBlanksForm', 'writeBlanksForm', 'writeBlanksForm']
TOTAL_READING_PASSAGE_1_EXERCISES = 13 TOTAL_READING_PASSAGE_1_EXERCISES = 13
TOTAL_READING_PASSAGE_2_EXERCISES = 13 TOTAL_READING_PASSAGE_2_EXERCISES = 13

View File

@@ -283,6 +283,16 @@ def generate_listening_1_conversation(topic: str):
'Make sure that the generated conversation does not contain forbidden subjects in ' 'Make sure that the generated conversation does not contain forbidden subjects in '
'muslim countries.') 'muslim countries.')
},
{
"role": "user",
"content": 'Try to have misleading discourse (refer multiple dates, multiple colors and etc).'
},
{
"role": "user",
"content": 'Try to have spelling of names (cities, people, etc)'
} }
] ]
token_count = count_total_tokens(messages) token_count = count_total_tokens(messages)
@@ -951,13 +961,19 @@ def gen_write_blanks_form_exercise_listening_conversation(text: str, quantity: i
"role": "system", "role": "system",
"content": ( "content": (
'You are a helpful assistant designed to output JSON on this format: ' 'You are a helpful assistant designed to output JSON on this format: '
'{"form": ["key: value", "key2: value"]}') '{"form": ["key": "value", "key2": "value"]}')
}, },
{ {
"role": "user", "role": "user",
"content": ( "content": (
'Generate a form with ' + str( 'Generate a form with ' + str(
quantity) + ' ' + difficulty + ' difficulty key-value pairs about this conversation:\n"' + text + '"') quantity) + ' entries with information about this conversation:\n"' + text + '"')
},
{
"role": "user",
"content": 'It must be a form and not questions. '
'Example: {"form": ["Color of car": "blue", "Brand of car": "toyota"]}'
} }
] ]