I am new to Rasa NLU and I wanted to know how do we extract entities in stories regardless of their value. For example, I want to ask the user his location and then extract the entity “location” from their reply and pass it to a custom action/template.
my stories.md file :
emergency path
greet
utter_greet
inform
utter_ask_location
tell_location
utter_affirm_location
accept
utter_goodbye
I want to extract the entity in the tell_location intent.
looking forward for insight.
@hajoura thank you for your response. I tried slots but i don’t want to hardcode key-value pairs. I want the slot in tell_location regardless of the value.
The below example works fine but I do not want to define the value and fire utter_affirm_location.
If I understood you correctly you want to fill the tell_location slot regardless of the value. The best way t do it is to have a well trained NER for locations (spacy got one for english). Another way to do it (but I think it’s not the best choice) is to custom fill the slot through forms. You can do a custom slot mapping, and fill a slot with the users input (check here).
It would look something like this:
def slot_mappings(self):
# type: () -> Dict[Text: Union[Dict, List[Dict]]]
"""A dictionary to map required slots to
- an extracted entity
- intent: value pairs
- a whole message
or a list of them, where a first match will be picked"""
return { "tell_location": [self.from_text()] }
This way your slot will be filled with any string given by the user.
but some of these values are not even defined in my stories.md file
tell_location {“location”: “new york”}
utter_ask_confirm
tell_location {“location”: “seattle”}
utter_ask_confirm
How would this work for missing values? Do we end up adding all the possible locations is a good idea or AI would understand and interpret accordingly?