Create your own language objects

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 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 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:

Final list of language objects

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 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 automatically generated conditions.

Simple language object

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:

Complex Language Object Definition

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:

  1. 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 Milk alternatives.
  2. Click on the language object button in the 'New' section of the top ribbon.
  3. Call the language object LONGBERRY_SOY_MILK.MUL.
  4. 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.
  5. 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

Note that all these new language objects 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 language objects 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:
    Entry description
    %LONGBERRY_CONDENSED_MILK.MUL condensed milk
    %LONGBERRY_LACTOSE_FREE_MILK.MUL lactose free milk
    %LONGBERRY_SOY_MILK.MUL soy 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 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.

Would you know how to proceed?

Click here for the answer.

Was this page helpful?