How to create and configure Slots

icon picker
Entity Recognition | Synonym slot

Purpose and general information

The
@Synonym Slot
allows you to perform a semantic search for an
@Entity
using a table of a certain format with data — a
@Vocabulary
— and save the found information in a
@Context Variable
. Semantic search — recognition of various word forms of synonyms, and not just complete matches with them — is available for the languages ​​listed in the table
Broken link
. For other languages, a complete match search works.
When expressing an intention in natural language, the
@Bot User
can use an
@Entity
in the
@Request
. For example, in the
@Request
“How to get to New York by train” there are
@Entity
“city” (New York) and
@Entity
“transport" (train). In some cases, you need to allocate
@Entity
values and write them to a
@Context Variable
for later use in the
@Script
. The essence can be expressed in different words — synonyms. For example, “New York” can be called “NY” and “train” — “electric rain" or “railway”.
Some scenarios require you to extract
@Entity
values and write them to a
@Context Variable
for later use in the
@Script
. To search for an
@Entity
, the
@Synonym Slot
is used in combination with the
@Vocabulary
functionality.
image.png
Examples:
It is necessary to determine the full official name of the city to transfer it to the external system. For this, a
@Vocabulary
is created, consisting of a number of
@Entity
es, each of which corresponds to a specific city and contains various variations of its name, for example: the name of the
@Entity
is “St. Petersburg”, the contents are synonyms “Saint Petersburg, SPB, Leningrad”. The
@Bot user’s Message
is run by the
@Synonym Slot
through this
@Vocabulary
and the name
@Entity
found in it is used further in the
@Script
.
It is necessary to divide the
@Script
after determining the Intent depending on the
@Entity
contained in the Replica.
Intent: “How to find <
@Entity
>?”.
Set of
@Entity
es: “boss’s office”, “dressing room”, “meeting room”, “cafeteria”, “doctor’s office”, “kitchen”, “toilet”
Using the
@Synonym Slot
, the
@Entity
is searched for in the
@Bot user’s Message
, then, using the
@Transition Rule
@Slot
, the
@Script
is divided into several
@Script Branch
s depending on the
@Entity
.

Slot creation and settings

Slot attributes

image.png
Name — the name of the
@Slot
, which will be displayed in the
@Script Tree
. The maximum length of a field value is 40 characters.
Source — an
@Expression
that gives the result — a string (
@Test String
) in which the search for
@Synonym
s from the
@Vocabulary
will be performed. Either a full
@Expression
with operators or an
@Expression
from a single
@Context Variable
can be specified, for example {{ variable }} or {{ places[0].name }}
RESULT VARIABLE — name of the
@Context Variable
into which the information found by the
@Slot
will be written. Format: string without parentheses, for example var1.
VOCABULARY
@Vocabulary
from
@Resourses Tab
. Incremental case-insensitive search in the list works. There can be several RESULT VARIABLE + VOCABULARY pairs. To add a new pair, click on the Add search button. ​
add search.png
As each additional RESULT VARIABLE + VOCABULARY pair is added to the VOCABULARY field, the drop-down list displays those
@Company
@Vocabulary
s that are not used in other VOCABULARY fields of this
@Slot
. Thus, the RESULT VARIABLE + VOCABULARY pairs in one
@Synonym Slot
can be a maximum of 20 (20 is the maximum number of
@Vocabulary
in the
@Company
).

Using syntax in Slot

In the
@Synonym Slot
, it is possible to use
@Expression
and
@Expression with Control Structure
in the Source field. Read more: .

Vocabularies

The
@Vocabulary
is a
@Company Resources
object, so it is accessible from all
@Agent
s of this
@Company
.
About creating a
@Vocabulary
: .

Slot operation

When going through a
@Synonym Slot
, the following operations are performed in the order listed:
Removing from the
@Chat Context
all
@Context Variable
s specified in the RESULT VARIABLE field of this
@Slot
;
Calculation of the
@Expression
specified in the Source field, obtaining the
@Test String
.
If the
@Expression
failed to evaluate and obtain the string (the
@Context Variable
specified in the
@Expression
does not exist or the
@Expression
is incorrectly formed), then the
@Context Variable
@error
with the value Template rendering (source of synonym extraction) error occurred will be created in the
@Chat Context
.
Converting the contents of the
@Test String
to lower case;
Separating the contents the
@Test String
by words using a special model (for example, by a space, by a comma, etc.) — obtaining an array of words;
For each completed RESULT VARIABLE - VOCABULARY pair: Search for each word from the
@Test String
in the
@Vocabulary
specified in the VOCABULARY field, and write the result to the
@Context Variable
specified in the corresponding RESULT VARIABLE field:
If one or more words from the
@Test String
match
with word forms of
@Synonym
s for the languages listed in the table
@Vocabulary
languages available for recognition
or with the exact meaning of the
@Synonym
for any languages
Important: the case of
@Synonym
s in the
@Vocabulary
and the
@Test String
does not affect the recognition result.
The value of the
@Context Variable
specified in the RESULT VARIABLE field is an array of objects, where each element of the array is an object containing a positive word recognition result (positive result = the word was found in the
@Vocabulary
).
The result format is JSON with information, in this example only the first element of the array of result objects is described: ​[ {'synonym': 'synonym found in variable', 'reference': 'first synonym in line', 'entity': 'entity name', 'start': serial number of the first character found in the synonym variable, 'end': serial number of the last character found in the synonym variable }, ... { <Nth element - search result> }, ]
Example: ​[ {'synonym': 'honda', 'reference': 'HONDA', 'entity': 'car_brand', 'start': 0, 'end': 5} ]
The array can have several elements, their number is equal to the number of matches found when checking in the
@Vocabulary
, this is possible in the following cases:
one word from the
@Test String
matches several in the given
@Vocabulary
(found in several strings)
Example:
@Test String
: I need two tickets to NY Recognition result: ​[ {'synonym': 'NY', 'reference': 'New York', 'entity': 'New York', 'start': 24, 'end': 25}, {'synonym': 'NY', 'reference': 'New York', 'entity': 'New York', 'start': 24, 'end': 25} ] The word NY was found in 2
@Entity
in one
@Vocabulary
.
several words from the
@Test String
found in different
@Entity
es in this
@Vocabulary
Example:
@Test String
: I want to buy tickets from LA to NY Recognition result: ​[ {'synonym': 'LA', 'reference': 'LA', 'entity': 'LA', 'start': 22, 'end': 23}, {'synonym': 'NY', 'reference': 'NY', 'entity': 'NY', 'start': 32, 'end': 33} ] The word LA was found in 1
@Entity
in the
@Vocabulary
, the word NY was found in 1
@Entity
in the
@Vocabulary
.
Several words from the
@Test String
found in one
@Entity
in this
@Vocabulary
. For example, in a phrase one city is mentioned twice, each mention is a separate word that will give its own result object in the RESULT VARIABLE variable.
Example: ​
@Test String
: buy tickets Moscow - St. Petersburg - Moscow[ {'synonym': 'Moscow', 'reference': 'Moscow', 'entity': 'Moscow', 'start': 14, 'end': 20}, {'synonym': 'Peter', 'reference': 'St. Petersburg', 'entity': 'St. Petersburg', 'start': 21, 'end': 26}, {'synonym': 'Moscow', 'reference': 'Moscow', 'entity': 'Moscow', 'start': 27, 'end': 33} ] The word Moscow matches the
@Entity
'Moscow' in the
@Vocabulary
and is present in the
@Test String
twice.
If nothing is found, the
@Context Variable
specified in the RESULT VARIABLE field will not be created in the
@Chat Context
.

Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.