Regex to entity

@divyank have you considered using forms for that case? you can read about it in the slot filling section of our docs

@akelad I want my bot to take my Employee id and then go back to the database and fetch my user name. My bot is working fine for only those entries which i have provided in nlu.md. For ex.

intent:example

  • My Employee id is [98987676] (person_id)

So when bot is uttering back results then it is only working for the emp id which i have given in nlu.md. Note i am not using regex. Please advise.

You have to give multiple examples with entities matching that regex and none without so that the bot will learn that matching that regex is a good sign for that entity.

How to use regex in nlu.md. Can you help ?

Here’s an example for a german zipcode

## regex:zipcode
- \b\d{5}\b

so ## regex:{entity_name} follow by the regular expression(s), you want to match. Additionaly, the RegexFeaturizer has to be part of your NLU pipeline (before your intent classifier)

That’s what the docs say

I have a Pipeline pipeline: supervised_embeddings in my config.yml. What should be the format for adding another pipeline ?

Looks likes the RegexFeaturizer is part of the supervised_embeddings pipeline per default. If the RegexFeaturizer is active, it should be mentioned in the model’s training log. If you want to be 100% sure, just copy the supervised_embedding pipeline from the docs

I tried by running this but now Bot is not returning any name. I have mentioned the following

regex:empid

  • [0-9]{6}

As much i understand this means from digit 0-9 repeated 6 times. Am i correct? Also after training the data i don’t see empid entry in - Found intents.

Did you add several examples like this?

## intent:example
* My Employee id is [98987676] (person_id)

Around 10 examples with person_id-entities should do the job.

btw I just noted that your example here is an 8-digit string, but your regex says 6 digits. This has to be consistent

Ok so now my training data should look like

regex:empid

  • [0-9]{6}
  • My empid is [123456] (person_id)
  • Here is my emp id [654321] (person_id) and so on

No, the examples sentences have to be in an intent section like usual.

do i need to mention regex name in my stories ?

No. Use the entity with regex like any other entity without a regex. Only difference is that you add the lines mentioned above.

## regex:zipcode
- \b\d{5}\b

Hi,

i have tried the same thing you said @IgNoRaNt23, but still it didnot work,can you help me in this

How do you know, that it did not work?

Hi,

i tried this and on putting more than 10 entries, it started working, thanks for your help. Regards, Pausali

how you configured domain file for this?

There don’t have to be any changes in the domain-file as long as the entity is specified.