Optimize language conditions
Earlier on we have seen examples of how to semi-automatically create Teneo Linguistic Modeling Language (TLML) Syntax conditions based on positive example inputs. For example, we created a syntax condition that can handle conversations like the following:
User: Can I have one of those?
Bot: Ok, a Cappuccino will be ready for pickup in 5 minutes.
However, as soon as you slightly change the question, you will get a wrong answer
User: Can I have 1 of those?
Bot: I am sorry, can you re-phrase your question?
In the following, we will shorten the language condition while at the same time broaden its coverage. After having investigated what went wrong in the second part of the example conversation above, we improve the language condition by following two strategies:
- Recombining language objects
- Exchanging language objects
Having a closer look at the TLML Syntax condition
This is the syntax condition that has automatically been created from our positive examples:
tlml
1(
2 (%I.FW.LEX &^ %WANT.VB.LEX &^ (one/%IT.FW.LEX))
3 /
4 (%I_WILL.PHR &^ %GO_FOR.VB.MUL &^ %IT.FW.SYN)
5)^{ orderedCoffeeType = coffeeTypeInFocus }
6
The reason why the question "Can I have 1 of those?" did not trigger this flow is that '1' is not among the words listed in the condition. We will thus recombine the language objects so that the different phrases for asking about the pricing are combined with the different ways of expressing "one" or "1".
Recombination of language objects
We start by updating each line of the language condition to make it match on both 'one' and '1'. We do this by replacing each occurrence of 'one' with a language object called '%ONE.FW.LEX', as illustrated below:
tlml
1(
2 (%I.FW.LEX &^ %WANT.VB.LEX &^ (%ONE.FW.LEX/%IT.FW.LEX))
3 /
4 (%I_WILL.PHR + %GO_FOR.VB.MUL + %IT.FW.SYN)
5)^{ orderedCoffeeType = coffeeTypeInFocus }
6
Strictly speaking, our problem is now solved. However, we can go one step further. The first line of our syntax condition can be replaced with a phrase language object:
tlml
1(
2 (%I_WANT.PHR &^ (%ONE.FW.LEX/%IT.FW.LEX))
3 /
4 (%I_WILL.PHR + %GO_FOR.VB.MUL + %IT.FW.SYN)
5)^{ orderedCoffeeType = coffeeTypeInFocus }
6
That's it. What a nice and powerful syntax condition we now have created!
Exchange language objects
We now have a much more robust language condition than before. However, there are still some inputs like 'I want that' that are not yet covered by this condition. So let's broaden the coverage of the condition a bit.
As we can see, the condition currently uses the lexical language object IT.FW.LEX. Lexical objects only cover inflections of a word. Perhaps there is another language object we can use that covers synonyms. To do that you can try this:
- Select %IT.FW.LEX and replace it with the text
it.fw
. - Hit Ctrl + Space.
- A list with language objects matching 'it.fw' appears. One of them is IT.FW.SYN.
- Now go ahead and replace %IT.FW.LEX with
%IT.FW.SYN
in your Syntax condition. - Hit 'Save'.
Your final Syntax condition should now look like this:
tlml
1(
2 (%I_WANT.PHR &^ (%ONE.FW.LEX/%IT.FW.SYN))
3 /
4 (%I_WILL.PHR + %GO_FOR.VB.MUL + %IT.FW.SYN)
5)^{ orderedCoffeeType = coffeeTypeInFocus }
6
As you have noticed you can type words (and even parts of sentences) straight into the TLML Syntax condition editor and ask Teneo for language objects matching those words. This auto-complete function is very handy if you have a bit of an idea of which words you would like to cover and explore what is covered by the Teneo Language Resources. You can read more about it here: How to find language objects. Once you get a bit more experienced, you might know common language objects by heart and include them directly.