Entities

Entities are a special kind of language object. They cover words that have some characteristics in common. Each entity consists of one or more entries, which denote what the entity is matching and optionally also which features are assigned to this entry.

For your bot to understand what the user said, some words of the user's utterance are more important than others. Typical examples for such important words include so-called named entities like cities or product names.
One way of catching these is using entities.

What is an entity?

Each entity covers a collection of one or more words called 'entries', which all have some characteristic in common. For example, these all denote cities in the Netherlands:

Screenshot of Entity Editor for Cities in the Netherlands

To enhance natural understanding, the entries can have variables carrying additional information about each entry. For example, different names may denote the same city, like "Den Haag" and "The Hague". With variables, it is possible to map these different variants to the same city name. Another example is the code of the nearest airport, which is useful to have in-flight booking scenarios.

Screenshot of Entity Editor for Cities in the Netherlands

In the entity examples above, all entries are strings. It is also possible to have entities added as scripts where one example can be found in LUIS^Teneo. Note that entries may also consist of other entities or language objects.

How to use entities

In order to use the entity covering the cities of the Netherlands in your flow, simply add %CITIES_NETHERLANDS.ENTITY to your language condition.
The variables sCity and sAirportCode can be accessed using attached scripts and data actions.

Prebuilt entities

Teneo comes with a collection of pre-built entities that are ready to be used. Some of them have been machine-learned, like geographical entities like cities or addresses, while others have been hand-crafted, like a list of colors. A full list of available entities can be found here.

Create your own entities

Besides the pre-built entities, you may also create your own. See Entities for guidance. For an example of how to use them in a flow, see Extract Entities.

Entries

Entities allow for three different kinds of entries:

  1. a word,
  2. a sequence of words,
  3. a different entity,
  4. a different language object.

Internally, a sequence of words will be transformed into Teneo's condition syntax. For example, if the two words "Chai latte" are entered into the entry field of an entity, they will be interpreted as Chai>>latte which means that the word "Chai" is directly followed by the word "latte" without any intervening word allowed in between them. However, this holds only for sequences of strings. For any other combination of entries, e.g. sequences containing entities or language objects this is not possible. If you want to add such a sequence (for example HOT.ADJ.LEX WATER.NN.LEX) to an entity you will have to create a new language object (here: HOT_WATER.ADJNN.MUL) that contains the sequence of these two language objects in its language condition. This multiword language object can then be added to be an entry of the entity BEVERAGES_SERVED.ENTITY.

Entity variables

Entity variables can be used to add properties to the different entries of an entity. There are two variable types: strings and scripts. The variable type can be determined using the toggle below the variable name. An example is given below. The customized entity BEVERAGES_SERVED.ENTITY contains all kinds of beverages served at Longberry Baristas. Its consist of

  • four entries: two other entities (COFFEES_SERVED.ENTITY, TEAS_SERVED.ENTITY), a language object (WATER.NN.LEX) and a set of words ("Chai Latte"),
  • a string variable "temperature",
  • a script variable "beverageType", which is retrieved from the entity variables coffeeType and teaType that are defined in the nested entities COFFEES_SERVED.ENTITY and TEAS_SERVED.ENTITY. For 'water' and 'chai latte' the value of the "beverageType" is given directly as strings.

Different entity variables

As you can see, a string variable can only contain strings, whereas a script variable can contain script expressions or strings. However, if you add strings to a script variable, make sure to add quotes around them.

Accessing entity variables

In the example below we attached a propagation script to an entity in a listener condition. The flow variable orderedBeverage is assigned lob.beverageType. This lob is a special variable which points to the entity (or, more generally speaking the language object, hence lob) to which the script has been attached to, BEVERAGES_SERVED.ENTITY, and retrieves the value of the entity's variable beverageType.

Access entity variable from listener condition

Value propagation

So for example, if the user input is 'I want an Americano', then the value 'americano' will be assigned to the flow variable orderedBeverage.

What happens is the following:

  1. All entries of BEVERAGES_SERVED.ENTITY are searched through to match the user input.
  2. A match is found in the language object AMERICANO.NN.LEX of the nested entity COFFEES_SERVED.ENTITY.
  3. The value "americano" of the entity variable coffeeType is propagated up to the entity variable beverageType.
  4. The value of the variable beverageType is accessed via the propagation script in the listener condition and assigned to the flow variable orderedCoffeeType.

Nested entity variables

Was this page helpful?