# Entity Extraction in Stories

**URL:** <https://forum.rasa.com/t/entity-extraction-in-stories/13253>\
**Category:** Rasa Open Source\
**Created:** [July 21, 2019, 5:28pm UTC](https://forum.rasa.com/t/entity-extraction-in-stories/13253 "2019-07-21T17:28:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![taimoor-ahmed](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/taimoor-ahmed/32/4108_2.png) [@taimoor-ahmed](https://forum.rasa.com/u/taimoor-ahmed)\
**Post date:** [July 21, 2019, 5:28pm UTC](https://forum.rasa.com/t/entity-extraction-in-stories/13253/1 "2019-07-21T17:28:56Z")

</div>

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. 🙂

---

<div class="post-metadata">

**Author:** ![hajoura](https://avatars.discourse-cdn.com/v4/letter/h/5f8ce5/32.png) [@hajoura](https://forum.rasa.com/u/hajoura)\
**Post date:** [July 21, 2019, 7:40pm UTC](https://forum.rasa.com/t/entity-extraction-in-stories/13253/2 "2019-07-21T19:40:51Z")

</div>

you must use slot that looks like the memory of your bot here you can name it as location . I think that help you a lot [Domain](https://rasa.com/docs/rasa/core/slots/)

---

<div class="post-metadata">

**Author:** ![taimoor-ahmed](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/taimoor-ahmed/32/4108_2.png) [@taimoor-ahmed](https://forum.rasa.com/u/taimoor-ahmed)\
**Post date:** [July 22, 2019, 5:29am UTC](https://forum.rasa.com/t/entity-extraction-in-stories/13253/3 "2019-07-22T05:29:46Z")

</div>

@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.

- tell\_location {“location”: “pakistan”}
- utter\_affirm\_location

---

<div class="post-metadata">

**Author:** ![hajoura](https://avatars.discourse-cdn.com/v4/letter/h/5f8ce5/32.png) [@hajoura](https://forum.rasa.com/u/hajoura)\
**Post date:** [July 22, 2019, 2:52pm UTC](https://forum.rasa.com/t/entity-extraction-in-stories/13253/4 "2019-07-22T14:52:34Z")

</div>

you can use rasa interaction to create story in your bot and save it helps you

---

<div class="post-metadata">

**Author:** ![BrunoRoth95](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/brunoroth95/32/4165_2.png) [@BrunoRoth95](https://forum.rasa.com/u/BrunoRoth95)\
**Post date:** [July 23, 2019, 6:15pm UTC](https://forum.rasa.com/t/entity-extraction-in-stories/13253/5 "2019-07-23T18:15:55Z")

</div>

Hi @taimoor-ahmed,

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](https://rasa.com/docs/rasa/core/forms/#custom-slot-mappings)).

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.

Hope it helps.

---

<div class="post-metadata">

**Author:** ![taimoor-ahmed](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/taimoor-ahmed/32/4108_2.png) [@taimoor-ahmed](https://forum.rasa.com/u/taimoor-ahmed)\
**Post date:** [July 24, 2019, 5:44am UTC](https://forum.rasa.com/t/entity-extraction-in-stories/13253/6 "2019-07-24T05:44:21Z")

</div>

@BrunoRoth95 thank you for your response. I’ll try to implement your solution and let you know if I got it right.

---

<div class="post-metadata">

**Author:** ![superprg](https://avatars.discourse-cdn.com/v4/letter/s/858c86/32.png) [@superprg](https://forum.rasa.com/u/superprg)\
**Post date:** [October 11, 2019, 5:20pm UTC](https://forum.rasa.com/t/entity-extraction-in-stories/13253/7 "2019-10-11T17:20:38Z")

</div>

Just curious, if I get these values from user

tell\_location {“location”: “chicago”}

tell\_location {“location”: “new york”}

tell\_location {“location”: “seattle”}

tell\_location {“location”: “trenton”}

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?
