Condition syntax summary
Conditions are formed by atomic conditions, which can be combined via operators into compound conditions of varying complexity, so writing proper conditions requires the use of operators. The operators are used to link words in a way that the chatbot can understand. Parentheses are also used in conditions in order to group expressions belonging together or to mark the scope of operators. Furthermore, in-line comments may be added to annotate complex conditions.
Some of the main operators used in Teneo Studio are shortly introduced below. For more details please see the Condition Reference Manual.
- AND operator (&) this operator is used in conditions to link several words, those words will be recognized in the user-input regardless of the word order. For example, if having the condition
where & are & you, the chatbot will not only recognize the phrase where are you? but also others containing those words but in a different order.
- FOLLOWED BY operator (+) this operator is similar to the AND operator, but it considers the order in which the words appear in the user input. So if this operator is used, the chatbot will only recognize the user input if the words are in the same order as specified in the condition. For example, the condition
who + are + youwill recognize a user input like who are you? but not you are the one who...
- OR operator (/) this operator can be used to add a list of synonymous words or expressions to a condition. When using this operator to separate several words in one condition, at least one of those words should appear in the user input for the chatbot to recognize it. For example, consider the condition
hi / hello / hey. In this case, the chatbot will recognize the user input providing at lease one of those words.
- NOT operator (!) this operator is used to indicate that a specified term cannot be part of the user input for the condition to be satisfied. This operator is useful to screen out sense-reversing words, such as not or don't. For example, with the condition
have &! goldfish, the user input I have a goldfish would not be recognized. Other user inputs such as I have a shark will be recognized. In a condition such as
(i & like & fish) &! (don't), the user input I like fish will be recognized, but not I don't like fish.
- COMPOUND operator (|) this operator can be used when wanting the chatbot to recognize compound words which could be written in different ways. This operator will only work with single compound expressions (no parentheses or jokers allowed). It is also important to consider that only a hyphen may appear between the two words. For example, the condition
anti|viruswill recognize the following inputs: I need an antivirus, I need an anti-virus and I need an anti virus.
- DIRECTLY FOLLOWED BY operator (>>) all the terms separated by the DIRECTLY FOLLOWED BY operator must appear in the user input in the stated order. No other terms can appear in between. For example, the condition
how >> are >> youwill allow the chatbot to recognize how are you?, but not how you are...
- NOT DIRECTLY FOLLOWED BY operator (!>>) all terms of the left sub-condition of the !>> operator must appear in the user input, but none of the terms of the right sub-condition may appear directly after the terms of the left sub-condition.
- MAYBE operator (~) this operator indicates that the specified term may be included in the user input, but it does not have to be there for the condition to be true. This operator is often used to accommodate adjectives or adverbs, for example.
The Extended And operators
The Extended And operators are intended to be used in conditions that also refer to annotations; however, they can be used with regular condition coding as well.
The used words of a condition including an Extended And operator are as follows:
- Bigger Match operator (&>): Used words of the left-hand operand for &>
- Smaller Match operator (&<): Used words of the right-hand operand for &<
- Different Match operator (&^): Union of used words of both left and right hand operand for &^
- Same Match operator (&=): Used words of either operand, as used words for the left-hand operand and the right-hand operand have to be identical for a match for &=
- Overlap Match operator (&~): Used words are only the words overlapping, i.e. matched by both of the left-hand operand and the right-hand operand for &~.
The Negated And operators
Like the Extended And operators, the Negated And operators really shine when used in language conditions that (also) refer to annotations. They make it possible to condition on both traditional Language Objects and on attributes from an annotation layer on the same used words.
For a Negated And operator to be fulfilled, at least the left-side of the condition must be fulfilled, if the right-side is fulfilled as well, then the total operator condition is met only if none of the matches of the right-side condition comply with the used word constraint, which depends on the specific operator being used.
The family of the Negated And operators include the following condition operators:
- Not Bigger Match operator (!&>)
- Not Smaller Match operator (!&<)
- Not Different Match operator (!&^)
- Not Same Match operator (!&=)
- Not Overlap Match operator (!&~)
Use of parentheses in conditions
Parentheses are used to group or organize expressions belonging together. Parentheses are also used to mark the scope of operators; if the scope of operators is not clear, parentheses or even nested parentheses should be used. Parentheses are only necessary when more than one operator is being used in a condition.
1I + like + my + (dog / cat / goldfish / turtle) 2
In the above example, the user input I like my dog will be recognized, but not I like my dogs or I like cats.
In this case, the list of pets separated by the OR operator (/) becomes just one more term in the string of the FOLLOWED BY (+) term.
If wanting to make the conditions
what's + up more advanced and integrate
what + is, the user must use nested parentheses:
(what's / (what + is)) + up set in the condition:
1hi / hello / hey / (how + are + you) / ((what's) / (what + is) + up) 2
Consider the following condition:
1((dogs / cats) + make + (good / great) + pets) &! (dont / don't / (do + not)) 2
|Matched user input||Unmatched user input|
|Dogs make really good pets||Dogs do not make good pets|
|Cats make great pets||Cats don't make good pets|
Breaking down the syntax results in the following:
|The term||"dogs" OR "cats"|
|followed by||"good" OR "great"|
|OR||"do" FOLLOWED BY "not"|
Several characters, such as +, &, *, or #, are reserved in conditions (see full list of reserved characters here).
If any of the reserved characters need to be recognized as text in a condition, the character should be put in quotation marks and put between the DIRECTLY FOLLOWED BY (>>) operators, for example,
newstrum >> "&" >> co.