Regex pattern for mobile number not working properly - Rasa Open Source - Rasa Community Forum

👋 Introducing the Rasa Playground

Regex pattern for mobile number not working properly

4.2k views 4 links

post by NikhilBansal21 on Sep 7, 2018

I have added this regex pattern in my training data file

[0-9]{9}$

This regex picks up possible outcomes like indian mobile numbers but the issue is it is not limiting the digit to 10 i.e if i enter like 12345 or even 123 it is taking it into slots also i have tested this regex here

https://regex101.com/

pattern is working fine but i am facing issue with my bot


  1. 789 ↩︎

Me too

4.2k views 4 links

post by akelad on Sep 7, 2018

Can you post the regex section of your training data file?

post by NikhilBansal21 on Sep 7, 2018

"regex_features": [\
  {\
    "name": "email",\
    "pattern": "^([a-zA-Z0-9_\\-\\.]+)@([a-zA-Z0-9_\\-\\.]+)\\.([a-zA-Z]{2,5})$"\
  },\
  {\
    "name": "IncidentID",\
    "pattern": "(?i)(SR)[0-9]*"\
  },\
  {\
    "name": "empCode",\
    "pattern": "\\b\\d{8}\\b"\
  },\
  {\
    "name": "otp",\
    "pattern": "\\b\\d{6}\\b"\
  },\
  {\
    "name": "MobNumberInt",\
    "pattern": "[(+]*[0-9]{10}[()+. -]*"\
  }\
],

post by NikhilBansal21 on Sep 7, 2018

i am facing issue with mobile number regex pattern their are two mentioned both are facing this issue

post by akelad on Sep 7, 2018

I’m confused, I thought you said there was a problem with the number regex?

post by NikhilBansal21 on Sep 7, 2018

i have mentioned mobile numbers above, i want my bot to accept mobile numbers not random numbers like 123456 or anything of that sort! right now bot is accepting any numeric value into the slot

post by akelad on Sep 10, 2018

Can you also post what your training data looks like? Do you have any other shorter numbers that are present in it as well (doesn’t have to be the same entity)?

post by NikhilBansal21 on Sep 10, 2018

no in my training data for fetching mobile number i dont have less that 10 digit input.

post by NikhilBansal21 on Sep 10, 2018

training data - https://gist.github.com/NikhilBansal21/98028418102128453593a30885d38e1f

post by akelad on Sep 12, 2018

Ok so the thing is it doesn’t just pay attention to the actual word, but also the context. This is why it might accept shorter numbers too. Also you do have a short number as a mobile number entity towards the bottom of your training data. I saw that you have a lot of different numbers that you extract as different entities, my suggestion would be just to extract these with duckling and then store them in slots with a custom action. That way you can validate them to see if they’re in the correct format too

post by NikhilBansal21 on Sep 12, 2018

yes i added less digits because every time i enter like -

U- my employee id is 9999852419 (a mobile number string)

My bot picks up mobile number intent in this case which i don’t want my bot to do. even if user enters a mobile number in case of employee id or otp i want my bot to process it and guide user that input is wrong. Yes you are right i want it to handle at that context itself !

post by NikhilBansal21 on Sep 14, 2018

i have implemented duckling

pipeline:

after using this bot is not extracting entities at all

post by souvikg10 on Sep 14, 2018

you need to provide the server for duckling

post by NikhilBansal21 on Sep 14, 2018

what server ?? the port where my core runs?

post by souvikg10 on Sep 14, 2018

duckling server

post by NikhilBansal21 on Sep 14, 2018

here it says that

To use this component you need to run a duckling server. The easiest option is to spin up a docker container using docker run -p 8000:8000 rasa/duckling .

How can i run it without docker?

post by souvikg10 on Sep 14, 2018

the installation instructions are here

post by NikhilBansal21 on Sep 14, 2018

thanks

post by Akhil on Aug 25, 2020

Hi @NikhilBansal21. I’m facing the same issue. Were you able to solve it?