Creating your Own Language Objects in Teneo
Language objects (LO)are building blocks for language conditions. Sometimes you may not find the language objects you need in the Teneo Lexical Resources (TLR), for the simple reason that they do not exist. 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 dialog, you may not find existing language objects for them.
The good news is that you can easily create missing LO 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 a number of 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 dialogs. It would be useful to have a language object covering it. As the TLR does not feature a LO 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 automatically generated conditions.
Complex Language Objects
While the example above is very simple, you can also create more complex language objects that make use of other LO . The complex 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.
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:
- Go 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
- Click on the language object button in the ‘New’ section of the top ribbon.
- Click on the back arrow in the top left to go to the condition window and add the condition:
%SOY.NN.LEX >> %MILK.NN.LEX.
- Save the language object.
Repeat these steps to create the following:
- Language object name:
LONGBERRY_CONDENSED_MILK.MULwith a condition:
%CONDENSED.ADJ.LEX >> %MILK.NN.LEX
- Language object name:
LONGBERRY_LACTOSE_FREE_MILK.MULwith a condition:
%LACTOSE_FREE.ADJ.MUL >> %MILK.NN.LEX
Note that all these new LO consist of multiple words, and thus bear the suffix “MUL”. Because they are specific to our Longberry Baristas project, we decided to add the prefix “LONGBERRY” to each of them. This is common practise because it facilitates the retrieval and maintenance of such project-related language objects. For example, you can easily find them by typing “LONGBERRY_*” in the search interface.
Use the language objects in an entity
The next step is to create a new entity that uses the LO we’ve just created.
1. In your main solution window, click on Entity in the ‘New’ section of the top ribbon. This will create a new entity.
2. Call the entity
LONGBERRY_MILK_ALTERNATIVES (the suffix ‘ENTITY’ will be added automatically).
3. Add the following entries:
|%LONGBERRY_LACTOSE_FREE_MILK.MUL||lactose free milk|
4. 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 assume 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.
Would you know how to proceed? Click here for the answer.