Entity recognition and negation?

I’m slightly confused about entity recognition in Rasa.

I would like to be able to detect the presence or not of an entity, and that entity could be referred to in different ways.

If I’m looking to ask “is it painful?” What would be the best way to set up my training data to detect the presence/absence of pain in the free text? Along with recognising syonyms (hurt, ache, agony, throbbing etc.)

Would something like this work? Is there way of adding the synonyms for “pain” separately rather than having to provide an example sentence using every single synonym?


- it [is painful](pain:yes)
- it [isn't painful](pain:no)
- it [is not painful](pain:no)
- it [really hurts](pain:yes)
- it [doesn't hurt](pain:no) much

In a form I can have:


- pain
    auto_fill: true
    type: unfeaturized
  - buttons:
    - payload: '/choose{"pain": "yes"}'
      title: 'yes'
    - payload: '/choose{"pain": "no"}'
      title: 'no'
    text: Is it painful?

Not an answer to your question but

- it [is not painful](pain:yes)

seems to be mislabeled

Good spot!

Try this:

## synonym: yes
- is painful
- really hurts

## synonym: no
- isn't painful
- is not painful
- doesn't hurt

Thanks, but I should have specified, I have a number of attributes like pain (e.g. is it hot?, is it broken?)

I need to get yes/no values for all of these, i.e. pain:yes is different to hot:yes so a simple mapping to yes and no won’t work in this instance.

Anyone have any ideas on this?

Hello @jaravo,

I can see that you use button for the user to confirm if it is painful or not, which seems efficient enough. Does that not solve your problem ?

hi @fuih

That’s fine for getting the response from a form question. What I’m trying to do is extract the information from free text too.

If someone has entered “it is painful”, “i’m in agony” etc. then I wouln’t have to ask the direct question with the button. The form question is basically a fall back if the entities haven’t already been captured from free text.

@jaravo Is there any situation in which an user will reply “It is not painful” when they didn’t get ask “Is it painful” ? I can understand they may answer “It is painful” if they are asked “What is the symptom”, but not “It is not painful”.

Anyway, i feel like there is really no elegant solution to this problem without having to provide a lot of nlu training data for it. I can suggest a way like below but i don’t know if it’s better than what you are doing:

## intent:yes_symptom:
- It is [painful](symptom)
- I'm in [agony](symptom)
- I feel like it's [throbbing](symptom)

## intent:no_symptom:
- No, it is not [painful](symptom)
- Not so much [agony](symptom)
- I don't feel any [pain](symptom:painful) at all

Then maybe you can handle stories depends on these 2 intents, checking the symptom slot, etc…

I was hoping to use an open question like “can you describe the situation?” to get an intial overview, before then clarifying other questions. In this situation the user could describe absence of issues (e.g. not painful) as well as presence.

Sounds like there’s not an elegant way of doing this.