Teneo Developers

TLML Syntax summary


Teneo Linguistic Modeling Language (TLML) is formed by atomic syntaxes, which can be combined via operators into compound syntaxes of varying complexity, so writing proper TLML syntax 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 the syntax to group expressions belonging together or to mark the scope of operators. Furthermore, in-line comments can be added to annotate complex TLML syntax.

Some of the operators used in Teneo Studio are shortly introduced below; for more details please see the complete TLML Reference Manual.

  • AND operator (&) this operator is used in the syntax to link several words, those words will be recognized in the user input regardless of the word order. For example, with the syntax 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 syntax. For example, the syntax who + are + you will 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 syntax. When using this operator to separate several words, at least one of those words should appear in the user input for the chatbot to recognize it. For example, consider the following syntax hi / hello / hey; in this case, the chatbot will recognize user input providing at least 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 syntax to be satisfied. This operator is useful to screen out sense-reversing words, such as not and don't. For example, with the syntax 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 syntax such as (i & like & fish) &! (don't), the user input I like fish will be recognized, but I don't like fish will not.
  • COMPOUND operator (|) this operator can be used when wanting the chatbot to recognize compound words which could be written in different ways. The operator only work with single compound expressions (no parentheses or jokers allowed). It is important to consider that only one hyphen may appear between the two words. For example, the syntax anti|virus will 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 syntax how >> are >> you will allow the chatbot to recognize how are you, but not how you are.
  • NOT DIRECTLY FOLLOWED BY operator (!>>) all terms of the left sub-syntax of the >> operator must appear in the user input, but none of the terms of the right sub-syntax may appear directly after the terms of the left sub-syntax.
  • 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 syntax to be true. This operator is often used to accommodate adjective or adverbs, for example.

Extended And operators

The Extended And operators are intended to be used in TLML syntax that also refers to annotations; however, they can be used in regular TLML syntax writing as well. The used words of a syntax 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 &~.

Read more in the TLML Reference Manual

Negated And operators

Like the Extended And operators, the Negated And operators really shine when used in TLML syntax that (also) refer to annotations. They make it possible to write syntax on both Language Objects/Entities and on attributes from an annotation layer on the same used words. For Negated And operators to be fulfilled, at least the left-side of the syntax must be fulfilled, if the right-side is fulfilled as well, then the total operator syntax is met only if none of the matches of the right-side syntax comply with the used word constraint, which depends on the specific operator being used.

The family of the Negated And operators include the following syntax operators:

  • Not Bigger Match operator (!&>)
  • Not Smaller Match operator (!&<)
  • Not Different Match operator (!&^)
  • Not Same Match operator (!&=)
  • Not Overlap Match operator (!&~)

Read more in the TLML Reference Manual

Use of parentheses

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 type of operator is being used in the TLML syntax.

Example 1


1I + like + my + (dog / cat / goldfish / turtle)

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.

Example 2

If wanting to make the syntax what's + up more advanced and integrate what + is, the user must use nested parentheses: (what's / (what + is)) + up set in the syntax:


1hi / hello / hey / (how + are + you) / ((what's) / (what + is) + up)

Example 3

Consider the following TLML syntax:


1((dogs / cats) + make + (good / great) + pets) &! (dont / don't / (do + not))
Matched user inputUnmatched user input
Dogs make really good petsDogs do not make good pets
Cats make great petsCats don't make good pets

Breaking down the syntax results in the following:

The term"dogs" OR "cats"
followed by"make"
followed by"good" OR "great"
followed by"pets"
not including"dont"
OR"do" FOLLOWED BY "not"

More on the use of Parentheses in the TLML Reference Manual

Reserved characters

Several characters, such as +, &, *, or #, are reserved in the TLML Syntax (see full list of reserved characters here).

If any of the reserved characters need to be recognized as text in a syntax rule, the character should be put in quotation marks and put between the DIRECTLY FOLLOWED BY (>>) operators, for example, newstrum >> "&" >> co.

Teneo Linguistic Modeling Language