When Teneo matches a condition against user input it also keeps track of the words of the input that are involved in the match. These words are called _USED_WORDS in Teneo, and they can be referred to from listeners and from attached scripts.
Listeners in Teneo consist of two parts: a condition part and a script part. Every word that matches the expression of the condition part is stored in the special _USED_WORDS variable from where they can be used for further processing. An example is given below.
When used in attached scripts, the _USED_WORDS variable contains the words that matched the part of the condition that the script has been attached to. An example is given below, where _USED_WORDS is used in a script attached to the language object COFFEES_SERVED.NN.LIST.
Teneo features a scripting API method called _.getUsedWords() that allows access to different stages of the input processing. This means that you can access different versions of the user input, depending on the parameter you pass. You may access the user utterance as it was (_.ORIGINAL), a simplified version of it (_.SIMPLIFIED), or its final version after having passed the whole input processing pipeline (_.FINAL).
|_.getUsedWords(_.ORIGINAL)||Returns the words spelled exactly as given in the input text, without any further word processing.|
|_.getUsedWords(_.SIMPLIFIED)||Returns the simplified words of the input text.|
|_.getUsedWords(_.FINAL)||Returns the words of the input text after all preprocessing steps (e.g. simplification, auto-correction, compound splitting, etc.)|
In contrast to the _USED_WORDS variable which stores the user input as one string, these methods return the user input as a list of strings. For example the sentence "I want to order a cappuccino" is returned as ["I", "want", "to", "order", "a", "cappuccino"]. If you want them to look good in your output you thus have to add a .join(" ") at the end of the call which will join everything into one string separated with whitespaces:
Note that there is also an API method called _.getNotUsedWords() that maps the words that have not matched the condition. For this method, the same parameters can be used as for _.getUsedWords().
Teneo features two ways of expressing optional words in an input: the optional match option (:O) (for example: I >> (really):O >> like >> you) and the maybe operator (~) (for example: (how+are+you) ~(doing/feeling/dear)). If the user input matches an optional part of a condition, the words of this match are also included in _USED_WORDS.
Was this page helpful?