Define Concepts In Your Entity Data With Rasa

And Improve The Structure Of The Entity Data You Extract

Introduction

Adding Entity Roles

## intent:exchange- I want to [change](transaction) [US dollars]{"entity": "currency", "role": "change_from"} to [Euros]{"entity": "currency", "role": "change_to"} on [Friday](date_time)- Can I [exchange](transaction) [euros]{"entity": "currency", "role": "change_from"} for [Rand]{"entity": "currency", "role": "change_to"} on [Saturday](date_time)- give me a rate to [change](transaction) [pounds sterling]{"entity": "currency", "role": "change_from"} for [Japanese Yen]{"entity": "currency", "role": "change_to"} on [Monday](date_time)- what are rates to [convert](transaction) [Australian Dollar]{"entity": "currency", "role": "change_from"} for [Russian Ruble]{"entity": "currency", "role": "change_to"} on [next week Thursday](date_time)- I want to [change](transaction) [US dollars]{"entity": "currency", "role": "change_from"} to [Canadian dollar]{"entity": "currency", "role": "change_to"} on [Friday](date_time)
Image for post
Image for post
User utterance example with multiple compound entities.
Image for post
Image for post
The intent is identified as exchange with the entities and respective roles.

Adding Entity Groups

## intent:tiers- [Silver]{"entity": "tiers", "group": "1"} accounts have lower interest for saving than [Platinum]{"entity": "tiers", "group": "2"} - [Gold]{"entity": "tiers", "group": "1"} accounts have lower interest for saving than [black]{"entity": "tiers", "group": "2"}- [Bronze]{"entity": "tiers", "group": "1"} accounts have lower interest for saving than [Platinum]{"entity": "tiers", "group": "2"}
Image for post
Image for post
User utterance with different tiers which can be grouped.
Image for post
Image for post
The intent tiers is correctly identified, with the group value for each entity.

Rasa Entities

Contextual & Compound

Image for post
Image for post
Rasa ~ Compound & Contextual Entities in Rasa-X

Entity Roles

## intent:travel_details- I want to travel by [train](travel_mode) from [Berlin](from_city) to [Stuttgart](to_city) on [Friday](date_time)
## intent:travel_details
- I want to travel by [train](travel_mode) from [Berlin]{"entity": "city", "role": "depart"} to [Stuttgart]{"entity": "city", "role": "arrive"} on [Friday](date_time)
I want to travel by train from Berlin to Stuttgart on next week Wednesday.
{
"intent": {
"name": "travel_details",
"confidence": 0.9981381893157959
},
"entities": [
{
"entity": "travel_mode",
"start": 20,
"end": 25,
"value": "train",
"extractor": "DIETClassifier"
},
{
"entity": "city",
"start": 31,
"end": 37,
"role": "depart",
"value": "Berlin",
"extractor": "DIETClassifier"
},
{
"entity": "city",
"start": 41,
"end": 49,
"role": "arrive",
"value": "Stuttgart",
"extractor": "DIETClassifier"
}
],
"intent_ranking": [
{
"name": "travel_details",
"confidence": 0.9981381893157959
},

Entity Groups

## intent:teams
- The first team will be [John]{"entity": "teamMember", "group": "1"}, [Mary]{"entity": "teamMember", "group": "1"} and [Geoff]{"entity": "teamMember", "group": "1"} and the second groupto travel will be [Martha]{"entity": "teamMember", "group": "2"}, [Adam]{"entity": "teamMember", "group": "2"} and [Frank]{"entity": "teamMember", "group": "2"}.
The first team will be John, Mary and Geoff and the second group to travel will be Martha, Adam and Frank.
{
"intent": {
"name": "teams",
"confidence": 0.9999754428863525
},
"entities": [
{
"entity": "teamMember",
"start": 23,
"end": 33,
"group": "1",
"value": "John, Mary",

"extractor": "DIETClassifier"
},
{
"entity": "teamMember",
"start": 38,
"end": 43,
"group": "1",
"value": "Geoff",

"extractor": "DIETClassifier"
},
{
"entity": "teamMember",
"start": 83,
"end": 95,
"group": "2",
"value": "Martha, Adam",

"extractor": "DIETClassifier"
},
{
"entity": "teamMember",
"start": 100,
"end": 105,
"group": "2",
"value": "Frank",

"extractor": "DIETClassifier"
}

Conclusion

Read More Here

Written by

NLP/NLU, Chatbots, Voice, Conversational UI/UX, CX Designer, Developer, Ubiquitous User Interfaces. www.cobusgreyling.me

Get the Medium app