Teneo Developers

Syntax Editor

Introduction

Syntax editors are found in - among others - TLML Syntax Matches, Language Objects (LOBs) and Listeners. They provide the option to write syntaxes using plain words, references to (other) Language Objects and/or Entities and even allow to attach scripts or reference annotations.
The syntax language used in Teneo is the Teneo Linguistic Modeling Language (TLML); a complete manual is available here.

This page summarizes the functionalities available in the Syntax editor.

Auto-Complete

The auto-complete functionality of the Syntax editor offers suggestions when starting to type a reference to the name of an Entity or the name/alias of a Language Object.
To use the auto-complete functionality, follow the below steps:

  • type % (percentage sign)
  • write the first letter(s) of the name/alias
  • press Ctrl + space

A list of Entity and Language Object names beginning with the same set of letters will be displayed, and the user can choose any one of them to use in the TLML Syntax.

Condition Building Assistant

The TLML Syntax condition building assistant suggests which Entities or Language Objects to use in order to capture words expected in the user input.
To use the assistant, follow the below steps:

  • type the letters/word to capture
  • select the letters/word
  • press Ctrl + space

A list of Entities and Language Objects containing the word or letter combination will be suggested to the user.

When writing more than one word, all the words need to be selected to get suggestions on all the words (when pressing Ctrl + Space).

In Teneo Studio Web, when adding Language Object and Entity Matches or After Matches, the initially displayed list of suggestions (before writing anything in the text field) contains a list of the 20 most recently added or modified Language Objects/Entities

Teneo Studio Desktop also includes the NLU Generator in Matches to draft TLML Syntaxes based on User Intent examples and which can later be adapted as needed.

Syntax Highlighting

The Syntax editor provides support for syntax highlighting and the below table includes an overview of the available highlighting; also see the Troubleshooting TLML Syntax page for more information on specific syntax errors.

ColorUsed for...Example
Recognized Language ObjectRecognized Language ObjectsRecognized Language Objects
Recognized EntityRecognized EntityRecognized Entity
Variable names and operatorsVariable names and operatorsVariable names and operators
AnnotationsAnnotationsAnnotations
Color of commentsComments and quoted stringsThis is a comment
ScriptsScriptsScript
Missing parentheses or operatorsMissing parentheses or operatorsMissing parentheses or operators
Unrecognized objectUnrecognized Language Objects and EntitiesUnrecognized object
Disabled Language ObjectDisabled Language ObjectsDisabled Language Object
Disabled EntityDisabled EntitiesDisabled Entity
Parentheses matchingTeneo Studio Desktop only Parentheses matching: Placing the cursor after a parenthesis will highlight the matching pair in pale green.Parentheses matching
NLU script valuesTeneo Studio Desktop only NLU script values are printed in orangeNLU Script values
NLU scriptsTeneo Studio Web only NLU scripts are printed in dark green

Indent and Outdent

To indent and outdent text in Syntax editors, use the below key combinations:

  • Tab indents the line
  • Shift + Tab outdents the line

Find

Teneo Studio allows to find specific text in Syntax editors by using the Find function.

  • Ctrl + F opens the Find text box
  • Writing text allows to find and match text in the editor (and highlights the found text)
  • Navigate the matched instances by pressing the up and down buttons

Expand

In Teneo Studio Web, the developer can expand the TLML editor by clicking the expand icon available on hover over which allows for a better overview of the TLML syntax and a broader workspace.

Expand

Click outside the expanded view to close it again.

Open LOB or Entity from Reference

This section currently apply only toTeneo Studio Desktop

To open a Language Object (LOB) or Entity reference from the Syntax editor, simply:

  • press Ctrl while clicking the reference to open in read-only mode
  • press Alt while clicking the reference to open in edit mode.

Note that Language Objects and Entities from a Lexical Resource are always opened read-only

Looking for keyboard shortcuts? Visit the summary of Keyboard Shortcuts!

Unrecognized LOB or Entity Reference

This section currently apply only toTeneo Studio Desktop

When writing references to non-existing Language Objects (LOB) or Entities in the Syntax Editor, the document is printed in red and struck-through as seen in the above table.
Now, creating the non-existing document can be done either as described here or directly in the Syntax editor by following the below steps:

  • Press either the Ctrl or the Alt while clicking the non-existing document
  • The Select a Folder window opens; select the folder where the new document should be created
  • Click OK
  • The new document opens, write the Properties (i.e., Name and Description)
  • When done, click the green Play icon or the back arrow in the top left area
  • Now, add the Language Object's TLML syntax or the entries of the Entity
  • When done, click Save and close the document
  • Back in the original document, the Syntax editor now print the new document in a greenish color (see above table) indicating the document is recognized.

Learn more about editing Language Objects and Entities

Scripts

Script Syntax

Script code can be embedded in syntaxes as long as the developer surrounds the code with curly brackets and make sure that whatever is returned by the script code is either a Boolean true or false; read more in the TLML manual.

Attached Scripts

Teneo brings two types of attached scripts:

  • Propagation Scripts which are regular scripts with a dynamic script context which depends on where the script is defined; the propagation scripts allow developers to assign values to NLU variables and propagate up NLU Variables through the Language Object and Entity hierarchy
  • Predicate Scripts allow developers to attach NLU/annotation variable value dependent constraints to TLML syntax.

Please find a summary of the two below; more details are available in the TLML reference manual.

Propagation Scripts

Propagation scrips allow developers to attach an action to a specific section of a TLML syntax, where that action is only executed when that specific part of the syntax is involved in the final matching - the syntax essentially holds a piece of Groovy script. The propagation script is attached via a caret symbol (^) to the right of a Language Object, Entity or a bracketed expression, followed by curly brackets { } containing the Groovy script:

(%MYTEST.REC / %TESTING.PHR)^{globalVarTest="Test"}

A propagation script is executed only after the syntax it is attached to has been evaluated to true by Teneo Engine and only the part(s) of the syntax that actually matched is used for initialization of NLU variables and execution of propagation scripts.

Predicate Scripts

Predicate scripts allow users to attach NLU/annotation variable value dependent constraints to syntaxes. Predicate scripts are syntactially attached to the syntax with a colon (:) symbol and embedded inside curly brackets:

%CITY_ENTITY:{lob.sCity=="New York"}

The predicate script has access to the special variable _USED_WORDS and to the read-only variable lob (the lob variable being a read-only map which grants access to the NLU/annotation variable values from the Language Object, Entity or annotation it is directly attached to). This allows to match a syntax only if a variable fulfill a specified criterion, for example, only match on an annotation if its variable for confidence score lies within a given range or only match an Entity if a given NLU variable contain a specfic value.

Following the same attach rules as propagation scripts, predicate scripts can be attached to:

  • bracketed syntaxes: (*):{_USED_WORDS!="hello"}
  • Language Object syntaxes: %ANIMALS.LIST:{lob.sAnimalType=="Pet"}
  • Entity syntaxes: %CITY_ENTITY:{lob.sCity=="New York"} and
  • annotation syntaxes: %$NUMBER:{lob.numbericValue>100}

More details, such as access rules for the attached scripts, can be found in the TLML Manual.