Level 6: Advanced Scripts

Tags

The way a script works is that it makes a random choice of prompt at each step out of the ones available in the step’s group. This is certainly a good idea; it is not helpful for the student to practise the same dialogue every time, since they will only get the same small number of vocabulary items over and over again. But if the script is at all complicated, it can often happen that two steps are related. Perhaps the theme is shopping, and the student is told to say they want to buy a particular article in one step, and then say in a later step that the article is the wrong size. If the student has been told to say they want to buy a pair of jeans in the first step, it makes no sense for them to be told in the second step that they should complain about the shirt.

This kind of problem can be solved by attaching “tags” to the Prompt units. The point of a tag is that it gives the system some basic knowledge of what the Prompt unit is about, so that it can keep the dialogue consistent. For the example above, tags can be used as follows. In the first step, where the student is told to ask for the article, the prompts for “jeans” and “shirt” are as follows:

Prompt
Lesson         shopping
Group          ask_for_article
Multimedia     how_can_i_help_you
Text/french    Dis : tu voudrais un jeans
Tags           garment=jeans
Response       i would like to buy a pair of jeans
EndPrompt

Prompt
Lesson         shopping
Group          ask_for_article
Multimedia     how_can_i_help_you
Text/french    Dis : tu voudrais une chemise
Tags           garment=shirt
Response       i would like to buy a shirt
EndPrompt

Here, the value of the tag garment is jeans in the first prompt, and shirt in the second. (In practice, one would probably write the prompts using a template, but we present them explicitly to make it clearer what’s going on). Later, in the second step, the prompts are:

Prompt
Lesson         shopping
Group          too_expensive
Multimedia     do_you_like_them
Text/french    Dis : le jeans est trop cher
Tags           garment=jeans
Response       the jeans are too expensive
EndPrompt

Prompt
Lesson         shopping
Group          too_expensive
Multimedia     do_you_like_them
Text/french    Dis : la chemise est trop chère
Tags           garment=shirt
Response       the shirt is too expensive
EndPrompt

At the first step, the system picks a prompt at random. But when it reaches the second step, it has to keep the tags consistent, so it will choose the prompt with the same value for the tag garment.

The tags also make it possible to choose different multimedia files depending on the prompt. So the prompts for the second step could be

Prompt
Lesson         shopping
Group          too_expensive
Multimedia     do_you_like_the_jeans
Text/french    Dis : le jeans est trop cher
Tags           garment=jeans
Response       the jeans are too expensive
EndPrompt

Prompt
Lesson         shopping
Group          too_expensive
Multimedia     do_you_like_the_shirt
Text/french    Dis : la chemise est trop chère
Tags           garment=shirt
Response       the shirt is too expensive
EndPrompt

Here, the multimedia resource do_you_like_the_jeans contains files with words like “Are the jeans okay?” while the multimedia resource do_you_like_the_shirt has files with words like “Are you happy with the shirt?”

Conditional steps

Another technique for making dialogues more interesting is to include extra paths. This can be done by adding “conditional steps”, where the <next_success> tag in the step includes a condition that has to be satisfied. The step will then have several different <next_success> tags, and the first one whose condition matches will be chosen.

The simplest type of condition is a random choice. For example, in this step from a hotel lesson,

<step>
   <id>ask_type_of_room</id>
   <group>type_of_room</group>
   <next_limit>is_single_okay</next_limit>
   <next_success probability="50">here_is_the_price</next_success>
   <next_success>not_available</next_success>
</step>

the student is asked what kind of room they want, and are told to say something like “I want a double room” or “I want a suite”. If they are accepted, there will be a 50% chance of moving to the step here_is_the_price, where they are told how much it costs, and a 50% chance of moving to the step not_available, where they are told that a room of the kind they want is unavailable and offered an alternative.

If the course includes gamification, it is also possible to make the choice of next step conditional on the student’s current badge level, so that they can be offered new possibilities when they reach a higher level. For example, near the end of the hotel script one could have a step like

<step>
   <id>enjoy_your_stay</id>
   <group>thanks</group>
   <next_limit>exit</next_limit>
   <next_success cond="level >= silver">is_everything_okay</next_success>
   <next_success>exit</next_success>
</step>

Here, the student is asked something like “I hope you will enjoy your stay with us”, and prompted to respond with something like “Thank you”. The first <next_success> line says that, if the badge level is at least silver, the dialogue will transition to a step where the desk clerk asks if everything is okay and the student is prompted to complain about something. The second <next_success> line says that the dialogue will otherwise exit the lesson.

A more complicated example

Grammar

# ---------------------------------------------------
# Course

# One course, 'toy_english_course'

Course
Name           toy_english_course
Client              dialogue_client
L2          english
Languages      french german
MaxTries       3
EndCourse

# ---------------------------------------------------
# Lessons

# One lesson, 'hotel'

Lesson
Name           hotel
PrintName      Hotel booking
Description    Simple hotel booking dialogue
Script         toy_hotel
EndLesson

# ---------------------------------------------------
# Prompts

# Say hello to the desk clerk

Prompt
Lesson         hotel
Group          welcome_greeting
Multimedia     hello
Text/french    Salut
Text/german    Hallo
Response       hello
Response       hi
Response       good morning
AudioHelp      help/hello.wma hello
EndPrompt

# Ask if one night is okay

Prompt
Lesson         hotel
Group          dont_understand_but_is_one_night_okay
Multimedia     dont_understand_but_is_one_night_okay
Text/french    Oui
Text/german    Ja
Response       yes ?please
Response       ?( yes | sure | thanks | thank you ) one night is ( fine | okay )
AudioHelp      help/yes.wma yes
EndPrompt

# Say you would like a room for a certain number of nights.

PromptTemplate i_want_a_room_for_period FRENCH GERMAN ENGLISH AUDIO
Lesson         hotel
Group          room_for_number_of_nights
Multimedia     how_many_nights
Text/french    Demande : une chambre pour FRENCH
Text/german    Frag : Zimmer für GERMAN
Response       a room for ENGLISH please
Response       ( can | could ) i have a room for ENGLISH ?please
Response       could you ?please give me a room for ENGLISH
Response       do you have a room for ENGLISH ?please
Response       give me a room for ENGLISH ?please
Response       have you got a room for ENGLISH
Response       i am looking for a room for ENGLISH
Response       i ( need | would like | want | will have ) a room for ENGLISH
Response       i would like to stay for ENGLISH
AudioHelp      help/AUDIO a room for ENGLISH please
EndPromptTemplate

ApplyTemplate i_want_a_room_for_period "1 semaine" "1 Woche" "one week" "a_room_for_one_week_please.wma"
ApplyTemplate i_want_a_room_for_period "2 nuits" "2 Nächte" "two nights" "a_room_for_two_nights_please.wma"
ApplyTemplate i_want_a_room_for_period "3 nuits" "3 Nächte" "three nights" "a_room_for_three_nights_please.wma"
ApplyTemplate i_want_a_room_for_period "4 nuits" "4 Nächte" "four nights" "a_room_for_four_nights_please.wma"
ApplyTemplate i_want_a_room_for_period "5 nuits" "5 Nächte" "five nights" "a_room_for_five_nights_please.wma"
ApplyTemplate i_want_a_room_for_period "6 nuits" "6 Nächte" "six nights" "a_room_for_six_nights_please.wma"
ApplyTemplate i_want_a_room_for_period "7 nuits" "7 Nächte" "seven nights" "a_room_for_seven_nights_please.wma"

# Here is your room; say thank you

Prompt
Lesson         hotel
Group          here_is_your_room_thanks
Multimedia     here_is_your_room
Text/french    Merci
Text/german    Danke
Response       thanks
Response       thank you ?(so much | very much | a lot)
AudioHelp      help/thank_you.wma thank you
EndPrompt

# Here is your room; say that you can't find something

PromptTemplate no_x_in_room FRENCH GERMAN ENGLISH TAG AUDIO
Lesson         hotel
Group          here_is_your_room_missing_article
Multimedia     here_is_your_room
Text/french    Dis : Il n'y a pas FRENCH dans la chambre
Text/german    Sag : Im Zimmer hat es GERMAN
Tags           missing_hotel_item=TAG
Response       there is no ENGLISH ?(in the room)
Response       i could not find ?(the | any) ENGLISH ?(in the room)
AudioHelp      help/AUDIO there is no ENGLISH
EndPromptTemplate

ApplyTemplate no_x_in_room "de gel douche" "kein Duschgel" "shower gel" "showergel" "there_is_no_shower_gel.wma"
ApplyTemplate no_x_in_room "de sèche-cheveux" "kein Haarföhn" "hairdryer" "hairdryer" "there_is_no_hairdryer.wma"
ApplyTemplate no_x_in_room "de shampooing" "kein Shampoo" "shampoo" "shampoo" "there_is_no_shampoo.wma"

# Sorry, not available; say thank you

Prompt
Lesson         hotel
Group          sorry_not_available_exclaim
Multimedia     sorry_not_available
Text/french    Merci
Text/german    Danke
Response       ( thanks | thank you )
AudioHelp      help/thank_you.wma thank you
EndPrompt

# Sorry, not available; exclaim

Prompt
Lesson         hotel
Group          sorry_not_available_exclaim
Multimedia     sorry_not_available
Text/french    Merde
Text/german    Scheisse
Response       ( damn | darn | shit )
AudioHelp      help/damn.wma damn
EndPrompt

# Sorry, not available; ask where you can buy various items

PromptTemplate where_can_i_buy FRENCH GERMAN ENGLISH TAG AUDIO
Lesson         hotel
Group          sorry_not_available_where_buy
Multimedia     sorry_not_available
Text/french    Demande: Où puis-je acheter FRENCH
Text/german    Frag : Wo kann ich GERMAN kaufen ?
Tags           missing_hotel_item=TAG
Response       where can i buy ENGLISH
AudioHelp      help/AUDIO where can i buy ENGLISH
EndPromptTemplate

ApplyTemplate where_can_i_buy "du gel douche" "ein Duschgel" "shower gel" "showergel" "where_can_i_buy_shower_gel.wma"
ApplyTemplate where_can_i_buy "du shampooing" "ein Shampoo" "shampoo" "shampoo" "where_can_i_buy_shampoo.wma"
ApplyTemplate where_can_i_buy "un sèche-cheveux" "einen Haarföhn" "a hairdryer" "hairdryer" "where_can_i_buy_a_hairdryer.wma"

# You can buy it at the store round the corner; say thank you

PromptTemplate you_can_buy_it_here TAG MULTIMEDIA
Lesson         hotel
Group          you_can_buy_it_here_thanks
Multimedia     MULTIMEDIA
Text/french    Merci
Text/german    Danke
Tags           missing_hotel_item=TAG
Response       thanks
Response       thank you ?(so much | very much | a lot)
AudioHelp      help/thank_you.wma thank you
EndPromptTemplate

ApplyTemplate you_can_buy_it_here "showergel" "where_to_buy_showergel"
ApplyTemplate you_can_buy_it_here "shampoo" "where_to_buy_shampoo"
ApplyTemplate you_can_buy_it_here "hairdryer" "where_to_buy_hairdryer"

# ---------------------------------------------------
# Multimedia declarations

Multimedia
Id hello
File hello.wma
File sorry_i_didnt_understand.wma
EndMultimedia

Multimedia
Id how_many_nights
File how_many_nights.wma
File sorry_i_didnt_understand.wma
EndMultimedia

Multimedia
Id dont_understand_but_is_one_night_okay
File dont_understand_but_is_one_night_okay.wma
File sorry_i_didnt_understand.wma
EndMultimedia

Multimedia
Id here_is_your_room
File here_is_your_room.wma
File sorry_i_didnt_understand.wma
EndMultimedia

Multimedia
Id sorry_not_available
File sorry_we_dont_have_that.wma
File sorry_i_didnt_understand.wma
EndMultimedia

Multimedia
Id where_to_buy_showergel
File you_can_buy_showergel_at_boots.wma
File sorry_i_didnt_understand.wma
EndMultimedia

Multimedia
Id where_to_buy_shampoo
File you_can_buy_shampoo_at_boots.wma
File sorry_i_didnt_understand.wma
EndMultimedia

Multimedia
Id where_to_buy_hairdryer
File you_can_buy_hairdryer_at_department_store.wma
File sorry_i_didnt_understand.wma
EndMultimedia

# ---------------------------------------------------
# Phrase score declarations

PhraseScore
Phrase do you have
Score 1
EndPhraseScore

PhraseScore
Phrase would like
Score 1
EndPhraseScore

PhraseScore
Phrase could i have
Score 2
EndPhraseScore

Script

<?xml version="1.0"?>
<script>
<!-- Strategy for toy hotel lesson -->

<!-- Hello -->
<step>
   <id>hello</id>
   <group>welcome_greeting</group>
   <next_limit>ask_for_number_nights</next_limit>
   <next_success>ask_for_number_nights</next_success>
</step>

<!-- Ask for number of nights -->
<step>
   <id>ask_for_number_nights</id>
   <group>room_for_number_of_nights</group>
   <next_limit>dont_understand_but_is_one_night_okay</next_limit>
   <next_success probability="25">here_is_your_room_number_end</next_success>
   <next_success>here_is_your_room_number_ask</next_success>
</step>

<!-- Don't understand, but is room for one night okay? -->
<step>
   <id>dont_understand_but_is_one_night_okay</id>
   <group>dont_understand_but_is_one_night_okay</group>
   <next_limit>here_is_your_room_number_end</next_limit>
   <next_success probability="25">here_is_your_room_number_end</next_success>
   <next_success>here_is_your_room_number_ask</next_success>
</step>

<!-- Here is your room number. Student says thank you -->
<step>
   <id>here_is_your_room_number_end</id>
   <group>here_is_your_room_thanks</group>
   <next_limit>exit</next_limit>
   <next_success>exit</next_success>
</step>

<!-- Here is your room number. Student says something is missing -->
<!-- Either go to the step where you're told to ask where to buy it -->
<!-- Or go to the step where you just say thank you -->
<step>
   <id>here_is_your_room_number_ask</id>
   <group>here_is_your_room_missing_article</group>
   <next_limit>exit</next_limit>
   <next_success probability="50">where_to_buy</next_success>
   <next_success>not_available_end</next_success>
</step>

<!-- Sorry,  not available. Student is annoyed -->
<step>
   <id>not_available_end</id>
   <group>sorry_not_available_exclaim</group>
   <next_limit>exit</next_limit>
   <next_success>exit</next_success>
</step>

<!-- Sorry,  not available. Student asks where to buy it -->
<step>
   <id>where_to_buy</id>
   <group>sorry_not_available_where_buy</group>
   <next_limit>thanks</next_limit>
   <next_success>thanks</next_success>
</step>

<!-- You can buy it at the store around the corner. Student says thank you -->
<step>
   <id>thanks</id>
   <group>you_can_buy_it_here_thanks</group>
   <next_limit>exit</next_limit>
   <next_success>exit</next_success>
</step>

</script>