Entity extraction in Actions - Getting Started with Rasa / Tutorials, Resources & Videos - Rasa Community Forum
👋 Introducing the Rasa Playground
Entity extraction in Actions
post by shanub on Dec 10, 2019
Below is my configuration details. I am trying to use the spacy entity extractor to extract the entity “time” in actions, but not working. Can any one help or refer some examples.
I am trying to extract anything related to date from the user input. I read duckling extractor or pretrained_embeddings_spacy can extract the entities, but not sure how to get the extracted value in the actions.
I don’t want to hardcode all the possible dates what the user will provide in nlu.
==============
config.yaml.
language: en
pipeline: pretrained_embeddings_spacy
policies:
- name: MemoizationPolicy
- name: KerasPolicy
- name: MappingPolicy
==============
nlu.md
intent:intent_ask_office_hours
- what is the office hours today?
==============
story ask open hours general - happy path
- intent_greeting
- utter_greet_firsttime
- intent_ask_office_hours
- action_find_office_hours
- intent_thanks
- utter_thanks_bye
============
domain.yaml
entities:
- time
============
actions.py
class Action_find_office_hours(Action):
def name(self):
return "action_find_office_hours"
def run(self, dispatcher, tracker, domain):
prediction = tracker.latest_message
entity_type = prediction['entities'][0]['entity']
print(entity_type)
dispatcher.utter_message(entity_type)
return [SlotSet("entity", entity_type)]
=====================
raceback (most recent call last): File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/sanic/app.py”, line 942, in handle_request response = await response File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/rasa_sdk/endpoint.py”, line 86, in webhook result = await executor.run(action_call) File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/rasa_sdk/executor.py”, line 280, in run events = action(dispatcher, tracker, domain) File “/Users/XXXXXXXXXXXXXXXXBot/actions.py”, line 44, in run entity_type = prediction[‘entities’][0][‘entity’] IndexError: list index out of range
2.1k views 1 link
15 days later
post by stephens on Dec 26, 2019
You should have many examples for each intent in your nlu data and your stories should have examples of the slot filling as shown in the docs here