Teneo can use language conditions to verify if an input of a user matches certain linguistic criteria. For example, a language condition used in a syntax trigger of a flow makes sure the flow is triggered when the user's input matches the criteria in the language condition. Or if a transition inside a flow contains a language condition, then Teneo will only traverse the transition when the input matches the language condition of the transition.
Examples of language conditions in use can be seen on these pages:
The most common elements that make up a language condition are:
For example, the following language condition contains 3 language objects and 2 operators:
%BAGGAGE.NN.LEX & (%BABY.NN.LEX / %CHILD.NN.SYN)
Let's dissect this language condition.
The language objects used in the example above are:
The example condition contains the following operators:
In the example condition above we also use parentheses ( ). Parentheses are used to group expressions belonging together. In the example above, this means that the condition will only match if the input contains the word 'baggage' and the word 'baby' or if the input contains the word 'baggage' and a synonym of 'child'.
Based on this information we can determine that this condition will match on:
All inputs above contain at least the word 'baby' or a synonym of 'child' and they also contain the word 'baggage'.
The condition above will not match on the following inputs:
It is important to acknowledge the intent before writing conditions in a flow. What is the purpose of this flow, what do we want it to trigger and what do we want to avoid? Depending on the language objects mentioned, the flow can become stronger or weaker. Therefore it is important to know when to use which language object.
The following demonstrates an example with the word 'cat' as a starting point together with the different levels.
Language Object | Condition | Matches | Does not match |
---|---|---|---|
cat | my cat | my cats kitten |
|
cat/cats | my cat two cats |
my kitten | |
%CAT.NN.LEX | cat/cats/cat's/cats' | my cat two cats |
my kitten |
%CAT.NN.SYN | %CAT.NN.LEX / %FELINE.NN.LEX / %KITTEN.NN.LEX /%KITTY.NN.LEX / %MOGGY.NN.LEX / %PUSS.NN.LEX / … | my cat two kittens |
one dog |
%ANIMALS_PETS.LIST | %CAT.NN.SYN / %CAT_BREEDS.LIST / %DOG.NN.SYN / %DOG_BREEDS.LIST / %RABBIT.NN.LEX / %BIRD.NN.LEX / … | my cat two kittens one dog |
a dragon |
As you can see in the examples above (CAT.NN.SYN and ANIMALS_PETS.LIST), the language condition of a language object can refer to other language objects. This makes it very easy to create language objects that recognize complex linguistic structures.
There are several advantages to using language objects in your conditions, including:
Consider an example use case in which we want to create a linguistic match requirement that fires on questions from users who want to know if they can bring their pet on board of an aircraft.
Possible inputs may include:
• Can I bring my dog ...
• Is it OK if I take my cat ...
• Would you mind if I carry my chihuahua ...
In this case, we could create a flow in which the trigger has a Condition Match Requirement and uses this language condition: (%CAN_I_BRING.PHR + %ANIMALS_PETS.LIST + %ONBOARD.ADJV.SYN)
The introduction above highlights a few of the core elements of a language condition, but there are many more components that can be used when creating language conditions. The following list contains the elements that can be used and links to pages with more details:
Component | Description |
---|---|
Operators | The example above already introduced two operators, but to get precise control on what to match there are many more operators that can be used. More details can be found in the Condition Syntax Reference. |
Language objects | As outlined above, language objects capture words, synonyms or various ways of expressing the same (partial) intent. More details can be found on the Language Objects page. Teneo provides Lexical Resources that contain many pre-defined language objects. |
Annotations | Annotations can be considered 'labels' that are attached to inputs. They are mostly attached to an input using machine learned models. Annotations can be used in language conditions in a similar way as language objects. More information on this can be found on the Annotations page. |
Script conditions | Groovy scripts can be used in conditions too. For a Script condition to be fulfilled, the result of the expression has to be true. More details can be found in the script-condition paragraph of the Condition Syntax Reference. |
Attached scripts | A language condition's primary goal is to make sure an input matches certain linguistic criteria. However, attached scripts can also be included in a language condition. The purpose of attached scripts in a condition is not so much to make sure that an input matches certain criteria, but to extract information from an input. An input may contain a city or product name that we may want to remember and use, and attached scripts can be used to extract them. More details can be found on the attached scripts page. |
Normally, a language condition only specifies which words must be present in an input. There may be other words in the input, not accounted for by the condition, and the input will still match the condition. Let's take a simplistic condition like what + date + is + it
. This condition will match both 'What date is it?' and 'What date is it tomorrow?'
Sometimes, however, we want a condition to be very exact and not match if the user's input contains words that were not specified in the condition at all. With 'Limit unused words', restrictions can be added on how many words besides those specified in the condition may be present in the user input.
More details on how to work with unused words can be found in the Condition Syntax Reference and an example usage is illustrated on the create a custom order group page.
Conditions can be coded manually, or Teneo Studio can automatically generate a condition with the 'Draft Condition' function. This drafted condition is based on the positive examples for that node.
An automatically generated condition is always based on the full text of all the examples entered. Therefore it is best to be brief in the examples, and only use words that are relevant to understand what the end user wants.
An automatically generated condition is guaranteed to match the examples entered, but is not necessarily the best condition possible. Perhaps it is a bit too wide or a bit too exact for the current use case? Perhaps it can be made more efficient or easier to maintain? After the condition is generated, always look for potential areas of improvement.
If preferred, language conditions can be created from scratch as well. In this case, the first step is to make sure there is a clear idea of what user inputs should match with the condition. Here we must ask ourselves, is one single condition enough to fit all variations or do we need multiple conditions? Are we covering enough synonyms and enough different sentence structures?
Teneo Studio offers useful suggestions for cases where we write language conditions from scratch. This way, there's no need to memorize how to write every single language object or other element in the condition. To see these suggestions, simply type text into the condition text field, select all or some of that text, and hit Ctrl + Space. A list of suggestions will pop up, as seen in the following image.
Was this page helpful?