Extracting multiple entities with same name from user message.
See original GitHub issueDescription
Hi, I am trying to build chatbot with opsdroid, matrix and rasanlu. When I try to extract entities from user message, if message contains multiple entities with same name we are able to extract single entity with highest confidence.
For example: user_message: I want to travel from Berlin to San Francisco.
Expected Functionality
Desired output: extract both entities i.e. {‘Berlin’ & ‘San Francisco’}
The RASA NLU is able to extract all entities correctly, but opsdroid returns single entity only.
Rasa nlu response:
{"text": "i want to travel from Berlin to San Fransisco", "intent": {"name": "knowledge", "confidence": 0.9999788999557495}, "entities": [{"entity": "city", "start": 22, "end": 28, "confidence_entity": 0.9633104801177979, "role": "departure", "confidence_role": 0.9610307812690735, "value": "Berlin", "extractor": "DIETClassifier"}, {"entity": "city", "start": 32, "end": 45, "confidence_entity": 0.7566294074058533, "role": "destination", "confidence_role": 0.8198645114898682, "value": "San Fransisco", "extractor": "DIETClassifier"}], "text_tokens": [[0, 1], [2, 6], [7, 9], [10, 16], [17, 21], [22, 28], [29, 31], [32, 35], [36, 45]] }}
Experienced Functionality
on message.entities
am able extract only single value for entity city.
{"city":{"value":"San Francisco", "confidence": 0.9977127313613892}}
Versions
- Opsdroid version: v0.28.0
- Python version:3.9.15
- OS/Docker version: 20.10.21
Configuration File
Please include your version of the configuration file below.
welcome-message: false
logging:
level: debug
path: false
rich: false # to get rich formated logs but does not work in the docker container
console: true #true - remove all colours and rich styles
timestamp: true # to keep or remove timestamp in the logs
extended: true # to enable/disable log location
connectors:
test-bot:
repo: $TEST_REPO_URL
homeserver: $TEST_HOMESERVER_URL
mxid: $MXID
access_token: $ACCESS_TOKEN
rooms:
main: $ROOM_MAIN
bot_name: $BOT_NAME
parsers:
regex:
enabled: true
rasanlu:
url: $RASA_URL
token: $RASA_TOKEN
min-score: 0.6
models-path: /rasa_model/path
model_filename: $RASA_MODEL_NAME
train: False
skills:
common:
path: /path/to/skills/__init__.py
Additional Details
intents.yml
version: "3.1"
intents:
- greetings
- bye
- help
- travel
entities:
- city:
roles:
- departure
- destination
- intent: travel
examples: |
- I want to fly from [Berlin]{"entity": "city","role":"departure"} to [San Francisco]{"entity": "city","role":"destination"}
- I want to fly from [Berlin]{"entity": "city","role":"departure"} to [San Francisco]{"entity": "city","role":"destination"}
- I want to fly from [Berlin]{"entity": "city","role":"departure"} to [San Francisco]{"entity": "city","role":"destination"}
- I want to fly from [Berlin]{"entity": "city","role":"departure"} to [San Francisco]{"entity": "city","role":"destination"}
- I want to fly from [Berlin]{"entity": "city","role":"departure"} to [San Francisco]{"entity": "city","role":"destination"}
Issue Analytics
- State:
- Created 10 months ago
- Comments:11 (8 by maintainers)
Top GitHub Comments
Maybe we can use the
role
to create a unique variable name. Example:{name: "city", role: "departure"}
{"city_departure":{"value":"Berlin", "confidence": 0.9977127313613892}}
This will not a a breaking change but will not be obvious for a user, so we have to document it with big ‼️ 🙂
well, I’m training rasa model separately with rasa. and then using this model in opsdroid.
In rasa, we can simply use
rasa train
command to train the model.