-
Notifications
You must be signed in to change notification settings - Fork 56
Illustrative examples
On this page, you will find 2 examples: a quite simple one and a more complicated. The first shows the power and usual use of Chatette; the latter uses each and every feature the program has.
We will show the outputs of the program using the jsonl
adapter, rather than the rasa
one, for readability and size reasons. That being said, the same information is present in both kinds of outputs.
The example sentences that will be generated are here meant to train the NLU model of a simple chatbot application used to book flights at an airport. This example can also be found as an example in the repository.
File: master.chatette
// Flight booking sentences
%[&help]('train': '4', 'test': '2')
~[i need?] ~[help#noun] [please?]
~[help#verb] ~[me] [please?]
~[can you] ~[help#verb] ~[me] [please?][\??]
%[&book](training:12, testing:4)
~[i need?polite] [to?polite] ~[book] a flight ~[from airport?] ~[to airport] @[departure-time?] [please?]
%[&thank](2)
Thank you
Thanks [a lot?]
|aliases.chatette
|slots/cities.chatette
|slots/departure-times.chatette
This file is the master file (meaning the program will be executed on it) and contains the intents. The first two ones will generate training and testing data, while the thank
one will only generate training data.
The aliases are defined in the file aliases.chatette
and slots are defined in files in sub-directory slots/
. Both are included at the end of this file.
File: aliases.chatette
~[help#verb]
help
aid
assist
~[help#noun]
help
aid
~[me]
[me|us]
~[i need]
[&i]['d| would?] [need|want]
[&i]['d| would] like
~[can you]
can you
could you
would you [be so kind and?]
~[book]
book
register
~[from airport]
from @[source-airport]
~[to airport]
[to go?] to @[source-airport]
File: slots/cities.chatette
// Lists of cities that are available as source airports and destination airports
@[source-airport]
Brussels
Paris
Amsterdam
@[destination-airport]
Paris
Amsterdam
London
Edinburgh
Berlin
File: slots/departure-times.chatette
// Possible departure times for a flight
@[departure-time]
today
now = today
tomorrow
In the slot defined in this file, the possibilities of generations today
and now
map to the same entity value: today
.
A list of synonyms for entity values will thus be included, with today
and now
being synonyms of today
.
As we said, the adapter used here is jsonl
for readability and size reasons. The same information will be present in an output file produced with this adapter or with the rasa
adapter. We will not show the files that include the synonyms list here.
In the following output files, each line represents an example sentence, with the field name
being the intent and the field text
representing the sentence.
File: output/train/output.jsonl
{"entities": [], "name": "help", "text": "i want help please"}
{"entities": [], "name": "help", "text": "Aid me please"}
{"entities": [], "name": "help", "text": "Aid please"}
{"entities": [], "name": "help", "text": "Would you assist us"}
{"entities": [], "name": "thank", "text": "Thanks a lot"}
{"entities": [], "name": "thank", "text": "thank you"}
{"entities": [{"slot-name": "source-airport", "text": "Paris", "value": "Paris"}, {"slot-name": "source-airport", "text": "Paris", "value": "Paris"}, {"slot-name": "departure-time", "text": "today", "value": "today"}], "name": "book", "text": "i'd want to book a flight from Paris to Paris today"}
{"entities": [{"slot-name": "source-airport", "text": "Brussels", "value": "Brussels"}, {"slot-name": "source-airport", "text": "Paris", "value": "Paris"}, {"slot-name": "departure-time", "text": "now", "value": "today"}], "name": "book", "text": "Book a flight from Brussels to Paris now please"}
{"entities": [{"slot-name": "source-airport", "text": "Amsterdam", "value": "Amsterdam"}, {"slot-name": "departure-time", "text": "tomorrow", "value": "tomorrow"}], "name": "book", "text": "i would need to register a flight to Amsterdam tomorrow please"}
{"entities": [{"slot-name": "source-airport", "text": "Paris", "value": "Paris"}, {"slot-name": "source-airport", "text": "Amsterdam", "value": "Amsterdam"}], "name": "book", "text": "register a flight from Paris to go to Amsterdam please"}
{"entities": [{"slot-name": "source-airport", "text": "Paris", "value": "Paris"}], "name": "book", "text": "I want to register a flight to Paris please"}
{"entities": [{"slot-name": "source-airport", "text": "Amsterdam", "value": "Amsterdam"}, {"slot-name": "departure-time", "text": "now", "value": "today"}], "name": "book", "text": "I'd like to register a flight to go to Amsterdam now"}
{"entities": [{"slot-name": "source-airport", "text": "Paris", "value": "Paris"}, {"slot-name": "departure-time", "text": "tomorrow", "value": "tomorrow"}], "name": "book", "text": "i'd like to book a flight to go to Paris tomorrow"}
{"entities": [{"slot-name": "source-airport", "text": "Paris", "value": "Paris"}, {"slot-name": "source-airport", "text": "Paris", "value": "Paris"}, {"slot-name": "departure-time", "text": "tomorrow", "value": "tomorrow"}], "name": "book", "text": "register a flight from Paris to Paris tomorrow"}
{"entities": [{"slot-name": "source-airport", "text": "Brussels", "value": "Brussels"}], "name": "book", "text": "I'd want to register a flight to go to Brussels please"}
{"entities": [{"slot-name": "source-airport", "text": "Brussels", "value": "Brussels"}, {"slot-name": "source-airport", "text": "Amsterdam", "value": "Amsterdam"}], "name": "book", "text": "book a flight from Brussels to go to Amsterdam please"}
{"entities": [{"slot-name": "source-airport", "text": "Paris", "value": "Paris"}], "name": "book", "text": "register a flight to go to Paris"}
{"entities": [{"slot-name": "source-airport", "text": "Brussels", "value": "Brussels"}, {"slot-name": "departure-time", "text": "tomorrow", "value": "tomorrow"}], "name": "book", "text": "I'd like to book a flight to Brussels tomorrow please"}
File: output/test/output.jsonl
{"entities": [], "name": "help", "text": "i need aid please"}
{"entities": [], "name": "help", "text": "help please"}
{"entities": [{"slot-name": "source-airport", "text": "Brussels", "value": "Brussels"}, {"slot-name": "departure-time", "text": "today", "value": "today"}], "name": "book", "text": "i'd like to register a flight to Brussels today"}
{"entities": [{"slot-name": "source-airport", "text": "Paris", "value": "Paris"}, {"slot-name": "source-airport", "text": "Brussels", "value": "Brussels"}], "name": "book", "text": "i need to book a flight from Paris to go to Brussels please"}
{"entities": [{"slot-name": "source-airport", "text": "Amsterdam", "value": "Amsterdam"}, {"slot-name": "source-airport", "text": "Amsterdam", "value": "Amsterdam"}, {"slot-name": "departure-time", "text": "now", "value": "today"}], "name": "book", "text": "Book a flight from Amsterdam to Amsterdam now please"}
{"entities": [{"slot-name": "source-airport", "text": "Amsterdam", "value": "Amsterdam"}, {"slot-name": "departure-time", "text": "now", "value": "today"}], "name": "book", "text": "I want to register a flight to Amsterdam now"}
As you can see, there is no example sentence that is both in the training and the test dataset.
This example is the same as before, but with several things added so that it uses all the functionalities described in the wiki. This example can also be found in the repository.
File: master.chatette
// Flight booking sentences
%[&help]('train': '4', 'test': '2')
~[i need?] ~[help#noun] [please?]
~[help#verb] ~[me] [please?]
~[can you] ~[help#verb] ~[me] [please?][\??]
what ~[thing] ~[can you] {do/help ~[me] with}[\??]
%[&book](training:12, testing:4)
~[i need?polite] [to?polite] ~[book] a flight ~[from airport?] ~[to airport] @[departure-time?] [please?]
~[can you] ~[book] a flight [for?for me] ~[me?for me] ~[from airport?] ~[to airport] [please?][\??]
%[&number-tickets](train : 4)
~[this] ~[be] ~[for nb people][.?]
%[&thank](2)
Thank you
Thanks [a lot?]
|aliases.chatette
|slots/cities.chatette
|slots/departure-times.chatette
|slots/nb-people.chatette
As you can see, the last rule in the intent help
uses a reference to an alias called thing
. However, this alias is defined once with flavor singular
and once with plural
. As no variation is specified here, the generator will select either of them.
File: aliases.chatette
~[help#verb]
help
aid
assist
~[help#noun]
help
aid
~[me]
[me|us]
~[i need]
[&i]['d| would?] [need|want]
[&i]['d| would] like
~[can you]
can you
could you
would you [be so kind and?]
~[thing#singular]
[thing|stuff]
~[thing#plural]
[kind of|type of] [things|stuff]
~[book]
book
register
~[from airport]
from @[source-airport]
~[to airport]
[to go?] to @[source-airport]
~[this]
this
that
it
~[be]
is
[will|would] be
~[for nb people]
for [@[nb-people$one]|@[nb-people$1]]
File: slots/cities.chatette
// Lists of cities that are available as source airports and destination airports
@[source-airport]
Brussels
Paris
Amsterdam
@[destination-airport]
Paris
Amsterdam
London
Edinburgh
Berlin
File: slots/departure-time
// Possible departure times for a flight
@[departure-time]
today
now = today
tomorrow
File: slots/nb-people.chatette
// Slot for the number of people to book a flight for
// This slot uses arguments
@[nb-people]
[~[nb$1]|~[nb$one]] person = 1
[~[nb$2]|~[nb$two]] people = 2
[~[nb$3]|~[nb$three]] people = 3
[~[nb$4]|~[nb$four]] people = 4
[~[nb$5]|~[nb$five]] people = 5
[~[nb$6]|~[nb$six]] people = 6
~[nb$NB]
exactly $NB
precisely $NB
$NB
In this last file, you can see a quite simple use of an argument in an alias.
As before, those are the results using the jsonl
adapter (one example sentence per line).
File: output/train/output.jsonl
{"entities": [{"slot-name": "source-airport", "text": "Paris", "value": "Paris"}], "name": "book", "text": "Would you book a flight for us to go to Paris please?"}
{"entities": [{"slot-name": "source-airport", "text": "Paris", "value": "Paris"}], "name": "book", "text": "Can you book a flight for me to Paris"}
{"entities": [{"slot-name": "source-airport", "text": "Amsterdam", "value": "Amsterdam"}, {"slot-name": "source-airport", "text": "Amsterdam", "value": "Amsterdam"}], "name": "book", "text": "Can you book a flight from Amsterdam to go to Amsterdam please?"}
{"entities": [{"slot-name": "source-airport", "text": "Amsterdam", "value": "Amsterdam"}], "name": "book", "text": "Book a flight to go to Amsterdam"}
{"entities": [{"slot-name": "source-airport", "text": "Paris", "value": "Paris"}], "name": "book", "text": "could you book a flight for me to go to Paris"}
{"entities": [{"slot-name": "source-airport", "text": "Paris", "value": "Paris"}], "name": "book", "text": "I'd like to register a flight to go to Paris please"}
{"entities": [{"slot-name": "source-airport", "text": "Brussels", "value": "Brussels"}], "name": "book", "text": "Can you register a flight to Brussels please?"}
{"entities": [{"slot-name": "source-airport", "text": "Amsterdam", "value": "Amsterdam"}, {"slot-name": "source-airport", "text": "Amsterdam", "value": "Amsterdam"}], "name": "book", "text": "can you register a flight from Amsterdam to Amsterdam please?"}
{"entities": [{"slot-name": "source-airport", "text": "Brussels", "value": "Brussels"}], "name": "book", "text": "I would like to register a flight to go to Brussels please"}
{"entities": [{"slot-name": "source-airport", "text": "Paris", "value": "Paris"}, {"slot-name": "source-airport", "text": "Amsterdam", "value": "Amsterdam"}, {"slot-name": "departure-time", "text": "tomorrow", "value": "tomorrow"}], "name": "book", "text": "register a flight from Paris to Amsterdam tomorrow"}
{"entities": [{"slot-name": "source-airport", "text": "Amsterdam", "value": "Amsterdam"}, {"slot-name": "source-airport", "text": "Paris", "value": "Paris"}], "name": "book", "text": "could you register a flight for us from Amsterdam to go to Paris"}
{"entities": [{"slot-name": "source-airport", "text": "Paris", "value": "Paris"}, {"slot-name": "source-airport", "text": "Paris", "value": "Paris"}, {"slot-name": "departure-time", "text": "tomorrow", "value": "tomorrow"}], "name": "book", "text": "Register a flight from Paris to Paris tomorrow"}
{"entities": [], "name": "help", "text": "Help us"}
{"entities": [], "name": "help", "text": "I'd like help please"}
{"entities": [], "name": "help", "text": "assist me"}
{"entities": [], "name": "help", "text": "Would you help us please?"}
{"entities": [], "name": "thank", "text": "Thanks"}
{"entities": [], "name": "thank", "text": "Thanks a lot"}
{"entities": [{"slot-name": "nb-people", "text": "6 people", "value": "6"}], "name": "number-tickets", "text": "it will be for 6 people."}
{"entities": [{"slot-name": "nb-people", "text": "3 people", "value": "3"}], "name": "number-tickets", "text": "That would be for 3 people"}
{"entities": [{"slot-name": "nb-people", "text": "precisely two people", "value": "2"}], "name": "number-tickets", "text": "it will be for precisely two people."}
{"entities": [{"slot-name": "nb-people", "text": "two people", "value": "2"}], "name": "number-tickets", "text": "It will be for two people."}
File: output/test/output.jsonl
{"entities": [{"slot-name": "source-airport", "text": "Paris", "value": "Paris"}, {"slot-name": "departure-time", "text": "tomorrow", "value": "tomorrow"}], "name": "book", "text": "register a flight to Paris tomorrow please"}
{"entities": [{"slot-name": "source-airport", "text": "Brussels", "value": "Brussels"}, {"slot-name": "departure-time", "text": "tomorrow", "value": "tomorrow"}], "name": "book", "text": "book a flight to Brussels tomorrow please"}
{"entities": [{"slot-name": "source-airport", "text": "Paris", "value": "Paris"}, {"slot-name": "source-airport", "text": "Brussels", "value": "Brussels"}, {"slot-name": "departure-time", "text": "tomorrow", "value": "tomorrow"}], "name": "book", "text": "register a flight from Paris to Brussels tomorrow please"}
{"entities": [{"slot-name": "source-airport", "text": "Amsterdam", "value": "Amsterdam"}, {"slot-name": "source-airport", "text": "Brussels", "value": "Brussels"}], "name": "book", "text": "can you book a flight from Amsterdam to Brussels"}
{"entities": [], "name": "help", "text": "could you assist me please?"}
{"entities": [], "name": "help", "text": "can you aid me"}
You should now be able to make your own templates. You can learn more about the command line interface of the program here.