Create your own language objects
Sometimes you may not find the language objects you need in the Lexical Resources, for the simple reason that they do not exist. The Teneo Lexical Resources have primarily been designed to cover general language expressions and common phrases, so whenever you want to use more (domain) specific words in your dialogue, you may not find existing language objects for them. The good news is that you can easily create missing language objects yourself. Once created, you can use them in your current solution. In fact, you can re-use them in other solutions as well!
On this page, we will create several language objects to recognize various milk alternatives, like soy milk, lactose-free milk, etc. We will then create an entity that makes use of these language objects.
The final list of language objects will look like this:
But first... a bit of theory to explain the difference between 'simple' and 'complex' language objects.
Simple Language Objects
Let's assume that all the coffees served by Longberry Baristas can be ordered in decaffeinated versions. This makes 'decaf' an important concept in our dialogues. It would be useful to have a language object covering it. As the Lexical Resources do not feature a language object for 'decaf', we will create one ourselves.
To do so, we use the language object button in the 'New' section of the Ribbon and add a name for the language object to be created. Note that this name must be unique in the solution, otherwise Teneo will return an error. It is advantageous to use one of the suffixes if you'd like the new language object to be part of language conditions.
Complex Language Objects
While the example above is very simple, you can also create more complex language objects that make use of other language objects. The complex language object for "soy milk" could look like that:
Create an entity for milk alternatives
You can create entities using complex language objects too. Let's create an entity that covers alternatives for milk using complex language objects.
Create complex language objects
The first step is to create the language objects that should be used by the entity.
Let's start with the example we saw above for soy milk:
- Navigate to the folder where you would like to store your language objects. If desired you can create a subfolder to store them in, for example, one called
Milk alternatives
. - Create a new language object.
- Call the language object
LONGBERRY_SOY_MILK.MUL
. - Click on the back arrow in the top left to go to the condition window and add the Syntax Condition:
%SOY.NN.LEX >> %MILK.NN.LEX
. - Save the language object.
Repeat these steps to create the following language objects:
- Language object name:
LONGBERRY_CONDENSED_MILK.MUL
with a condition:%CONDENSED.ADJ.LEX >> %MILK.NN.LEX
- Language object name:
LONGBERRY_LACTOSE_FREE_MILK.MUL
with a condition:%LACTOSE_FREE.ADJ.MUL >> %MILK.NN.LEX
Use the language objects in an entity
The next step is to create a new entity that uses the language objects we've just created.
- Navigate back to the previous folder and this time, create an Entity.
- Call the entity
LONGBERRY_MILK_ALTERNATIVES
(the suffix 'ENTITY' will be added automatically). - Click on 'Add String Variable' and name it 'description'
- Add following entries and select 'First row is variable names':
Entry | description |
---|---|
%LONGBERRY_CONDENSED_MILK.MUL | condensed milk |
%LONGBERRY_LACTOSE_FREE_MILK.MUL | lactose free milk |
%LONGBERRY_SOY_MILK.MUL | soy milk |
- Save the entity.
We now have an entity that recognizes the milk alternatives.
Extra challenge for the brave
Now that we have an entity for milk alternatives, we can extend the 'User wants to order a coffee' flow to take the milk alternatives into account and allow conversations like this:
User: I would like to order a medium flat white with soy milk
Bot: Ok, a medium flat white with soy milk will be ready for pickup in 5 minutes.
But if the user doesn't mention an alternative milk type, we'll asume a regular milk will suffice:
User: Can I order a large flat white
Bot: Ok, a large flat white will be ready for pickup in 5 minutes.