article by Frank Nimphius, December 2020

 

 

The System.Intent component in Oracle Digital Assistant resolves intents and extracts entities from a user message. Entities can be extracted if the message contains the entity value or a synonym defined for it. 

For example, when asking for a currency code for a country, the following user messages work if Germany, German, Portugal, Portuguese or UK were defined as synonyms 

"What is the currency code for Germany"
"What is the German currency code"
"Which currency code is mapped to UK"
"What is the currency code Portugal has"
"What is the currency code of Portuguese money"

There are use cases, where the synonym that resolves an entity actually matters. Lets take the example of an expense report. An expense report may have a value list entity entry for transportation to identify the type of an expense.

While "transportation" is the value to extract, the kind of transportation matters too. So if "train" "car" "plane" "flight", "ship" would be defined as synonyms, then the following messages would all resolve to transportation.

"I want to expense a flight"
"I expense a train ticket"
"my expense is for a train to London"

However, knowing which type of transportation was used saves the user from being prompted for this kind of information. This article explains how you can determine the value (which could be a synonym) that resolved an entity using Oracle Digital Assistant 20.09 or later.

Example

As mentioned, the ability to tell which value or synonym resolved an entity is available since Oracle Digital Assistant 20.09. Before you could only determine the value that was resolved for an entity. 

In this example, I have a value list entities with currency codes. 

 

 

The image below shows the intent tester in Oracle Digital Assistant. You launch the intent tester from the Try It Out! link that is displayed in the intent panel. If, for the sample skill you can download at the end of this article, you type "What is the currency code of German money", then you see that the currency code gets resolved as EUR for Euro. 

 

Doing the same for "What currency code is used by the British" correctly resolves to GBP. Both, the "German" and "British" strings in the message actually matched to synonyms defined for an entry in the currency code value list entity. 

A functionality that is easy to overlook in the intent tester is the JSON node. If you expand the JSON code then you see the actual JSON response for a message.

The JSON payload for the "What currency code is used by the British" message contains two entries of interest. The first entry is the entityMatches object that also exists in versions before Oracle Digital Assistant 20.09. The object can be accessed from BotML through the nlpresult variable (usually named "iResult"). 

New is the fullEntityMatches object. As you can see, this object does return an object and not just a string. The response contains information about the resolved entity value (canonicalName), the value or synonym that resolved the entity (originalString) as well as the name of the entity itself. 

The fullEntityMatches object too is accessible from BotML using Apache FreeMarker expressions. The image below shows the sample skill in the conversation tester. Here the printed message shows the canonicalName and the originalString values.

Below image shows another example.

In BotML, the information is read through Apache FreeMarker expressions shown in the image below.

Note that one addition you would need to put into the code is to check whether the entity got resolved or not. I omitted this check in my sample to keep the expression short. But apparently the expression below would fail if "list.CurrencyCodes" wasn't extracted in the user message.

A way to check the existence of an entity is iResult.value.fullEntityMatches['list.CurrencyCodes']?has_content?then(<read content>,<do something else>)

The Expression To Know About

And here are the two expressions for you to copy and paste into your own skill projects

iResult.value.fullEntityMatches['entityName'][0].canonicalName
iResult.value.fullEntityMatches['entityName'][0].originalString

Downloads

Download the skill and import the ZIP file to your own Oracle Digital Assistant instance (version 20.09 or later). Then open the skill and train it before you run the tests shown in this article

DOWNLOAD SKILL (ZIP)

Related Content

TechExchange Quick-Tip: Understanding Oracle Digital Assistant Skill Entity Properties – Or, What Does "Fuzzy Match" Do?

TechExchange: Take Advantage of Fuzziness When Extracting Entities in Oracle Digital Assistant

TechExchange: Use Entities To Build Powerful, Robust And Speech-Ready Action Menus

 

 

Author