question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Extracting multiple entities with same name from user message.

See original GitHub issue

Description

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:closed
  • Created 10 months ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
oleg-fikselcommented, Dec 9, 2022

Maybe we can use the role to create a unique variable name. Example:

  • {name: "city", role: "departure"}
  • the output will be {"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 ‼️ 🙂

0reactions
gsanasWcommented, Dec 12, 2022

What Rasa version are you using and how do you run it? Rasa Version : 3.3.1 Minimum Compatible Version: 3.0.0 Rasa SDK Version : 3.3.0 Python Version : 3.9.15

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can we extract two different name within one user utternace?
Yes, you can extract multiple entities in the same sentence. The last entity of a specific type that is extracted will be used...
Read more >
Extracting multiple entities in a single user message #1140
I want to extract multiple entities from a single user message. Example: user: Please fix my meeting with Mahesh on Monday.
Read more >
Solved: Extracting multiple entities requried from respons... - Google ...
Now I only want two fields such as number & username from each entity. So I used extract variable and javascript policy in...
Read more >
Named Entity Recognition in NLP - Towards Data Science
In natural language processing, named entity recognition (NER) is the problem of recognizing and extracting specific types of entities in text.
Read more >
How to extract named entity in NLP - Komunicate Blog
The following guide will show you how to use Kompose to extract named entity and use them in conversations. Read the article to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found