How can we handle cursing?

Heya everyone,

How do you guys handle cursing? I want to make the bot say a specific thing after someone curses (curse words). I can make a new intent, but it’s reasonable to assume that the user will curse during a different intent (Hey I can’t fucking find what I’m looking for).

No clue how to handle this. Any ideas?

Regex/lookup table perhaps? Or even a custom NLU pipeline component that adds a profanity flag/entity?

@Remy thinking a little more about this, do you want to add the extra response into the dialogue training data - or would a programmatic detection and additional utterance be better done in custom code?

If I were looking to train the core for it, I would probably just add a new profanity entity and slot and train the NLU layer recognise it using ner_crf. I could then check for that slot being set in my core stories and emit an additional utterance and reset the slot.

1 Like

that’s something I’ve been trying to figure out as well.

This would mean I’d have to copy and paste every story in my bot with additional intent{entity} (hello{“curse”:“shit”}) variations to teach the core that any intent can come with a curse. That’ll take a while considering my already 1400+ stories :exploding_head:

Ok, that’s a lot of stories. And I guess you are looking at profanity potentially occurring as part of any of your intents.

If you can’t drop the requirement of handling the profanity as part of an existing intent then I think you are going to have to respond to this programmatically by altering the processing somewhere. But, where? Perhaps in or There’s an example of using custom agent code in the rasa-addons repository.

If you can alter your requirement to recognise profanities as a new kind of intent, then perhaps you could just use augmentation when training your core and add one additional story…

* profanity
    -  utter_profanity_reply

Another option might be to write a small script to augment your training data with the profanity entity as per your example above.

Or wait until Rasa 0.14 comes out and use Mapping policy to have the profanity intent trigger a specific action.

1 Like

I think you could do it in the processor. I’m going to try to see how to handle this. It’s an interesting special case to handle

@lgrinberg Sure - if Remy’s case can be reduced to one of having a profanity intent. That’s an interesting new feature you mentioned, I wasn’t aware of it - thanks!

Anyway, I would be very interested to see what you come up with in the Processor (or other location) to handle this. With suitable generalisation, this could be useful in a number of situations other than just replying to user input which contains profanities.

Hiya all,

Thanks for all the replies. After posting this topic I read about the Mapping policy and decided to wait until it comes out so I can map cursing to that policy!