Function and general information
The Synonym slot allows you to search through a data table – the Dictionary – and store the information found in a context variable. When expressing intention in natural language, the Interlocutor can use different Entities in the phrase. For example, in the phrase “How to get to NYC by train” there is an Entity “city” (NYC) and “transport” (train). The Entities can be expressed by different synonyms. For example, “NYC” can be called “New York”, or “NY”, and “train” – “train” or “railway”. Some scenarios require you to select Entity values and write them to Chat Context Variables for later use in the Script. The Synonym Slot is used to extract Entities in together with the Dictionaries functionality.
Examples:
- You need to determine the full official name of a city to pass it to an external system. To do this, search for the name of the city in the phrase and then use the name of its corresponding Entity in the Script.
- It is necessary to divide the Scenario after defining the Intent depending on the Entity contained in the phrase. Intent: “How do I find a <Entity>?” Set of Entities: “office”, “meeting room”, “cafeteria”, “doctor’s office”, “kitchen”. The Synonym slot searches for an Entity in the phrase, then the Transition Rule slot divides the script into several branches depending on the Entity. NB: The functionality is only available for the Agents with the new version of the syntax (read more: New Syntax)
Creating and configuring slot Properties
- NAME is the name of the Slot, which will be displayed in the Script Tree. The maximum length of the field value is 40 characters.
- Source is the string in which the Slot will search for Synonyms from the Dictionary. It can be a Context variable specified with {{ variable }} syntax, an Expression or a Control structure. Details:
- RESULT VARIABLE – The name of the User-declared Context Variable into which the information found by the slot will be written. When the slot is passed, the system will delete the Context Variable with the specified name; then, if a search of the Dictionary provides a result, the Context Variable will be recreated. Otherwise this Context Variable will not be in the Chat Context.
- VOCABULARY is a Vocabulary from Company Resources.
There can be several RESULT VARIABLE + VOCABULARY pairs. To add a new pair, click the Add search button. When each additional RESULT VARIABLE + VOCABULARY pair is added, the VOCABULARY field in the drop-down list shows those Company Dictionaries that are not used in other VOCABULARY fields of this Slot. Thus, RESULT VARIABLE + VOCABULARY pairs in one Synonym Slot can be maximum 20 (this is the maximum number of Vocabularies in a Company).
Use of syntax in the Slot
In the Synonym slot, it is allowed to use Expressions and Control structures in the Source field.
Dictionaries
To learn more about how to create and upload a dictionary, see the article.
Slot operation
- The slot accepts the string that is being checked and specified in the Source field;
- The slot splits the contents of the string that is being checked into words;
- The slot deletes from the Chat Context all Context Variables specified in the RESULT VARIABLE field of the given Slot;
- The slot searches for each word from the string that is being checked in the VOCABULARY specified in the VOCABULARY field;
- If one or more words from the string that is being checked match the Synonyms from one or several Dictionaries, the corresponding Context variable specified in the RESULT VARIABLE field will be created in the Chat Context and the result of the search will be written to it.
- The output format is a JSON file containing the following information: [{‘synonym’: ‘the synonym found in the variable’, ‘reference’: ‘the first synonym in the string’, ‘entity’: ‘the entity name’, ‘start’: numerical number of the first symbol of the synonym which has been found in the variable, ‘end’: numerical number of the last symbol of the synonym which has been found in the variable}]
- If there are several matches found in the Dictionary (in case different Entities contain the same Synonym or one string that is being checked contains several identical synonyms), there can be several JSON files, for example: [{‘synonym’: ‘honda’, ‘reference’: ‘HONDA’, ‘entity’: ‘42639f67-b170-11ea-b78c-0050568041d3’, ‘start’: 0, ‘end’: 5}, {‘synonym’: ‘honda’, ‘reference’: ‘HONDA’, ‘entity’: ‘42639f67-b170-11ea-b78c-0050568041d3’, ‘start’: 6, ‘end’: 11}]
- If there are several RESULT VARIABLE – VOCABULARY pairs, the slot processes each of them in order repeating the actions describes in items 4-5.
Important: The case of Synonyms in the Dictionary and the String that is being checked does not affect the result of recognition.