shaysi
(Shaysi)
June 24, 2021, 10:04pm
1
Hello! I’m trying to test an user input and this user input should follow a regex pattern.
So, in NLU , my intent is defined by:
- regex: regex_phone_number
examples: |
- ^\(?\d{2}\)?[\s-]?[\s9]?\d{4}-?\d{4}$
- intent: phone_number ## If the number doesn't follow the regex pattern, another intent called "invalid_number" should appear.
examples: |
- [62995346785](regex_phone_number)
in DOMAIN file, there is an entity created:
entities:
- regex_phone_number
In STORIES file I’m doing this way:
- action: utter_send_phone_number
- or:
- intent: disagree
- intent: phone_number
entities:
- regex_phone_number
- action: continue_conversation
So, finally, my tests are like this:
(...)
- action: utter_ask_phone_number
- user: |
[61995213456](regex_phone_number)
intent: phone_number
- slot_was_set:
- regex_phone_number: "61995213456"
- action: continue_conversation
The output from my test was:
- action: utter_ask_phone_number
- intent: phone_number # predicted: invalid_number: [61995213456](regex_phone_number)
My number has the correct pattern as I check here: regex101.com/ , so I don’t know what’s the problem. I checked this post but I couldn’t figure it out what’s happening.
Any help would be great!
nik202
(NiK202)
June 24, 2021, 10:07pm
2
@shaysi can you post the scenario you following and following output?
Where you set the slot regex_phone_number in domain.yml?
shaysi
(Shaysi)
June 24, 2021, 10:11pm
3
Sorry if it’s a noob question, but what do you mean by scenario?
I’m declaring the slot in domain.
regex_phone_number:
type: rasa.shared.core.slots.FloatSlot
initial_value: null
auto_fill: true
influence_conversation: true
nik202
(NiK202)
June 24, 2021, 10:13pm
4
@shaysi bot/user scenario. I mean. Can you also show slot mention in domain.yml please. Is the above one is your slot in domain?
shaysi
(Shaysi)
June 24, 2021, 10:18pm
5
nik202:
slot in domain?
yes, above is the regex_phone_number slot declared in domain
nik202
(NiK202)
June 24, 2021, 10:21pm
6
@shaysi It is a custom slot you created ? or some custom slot.py file also? Did you have enough training example in intent?
Please see this blog also Build Contextual Assistants with Rasa Forms | The Rasa Blog | Rasa
I hope your pipeline have RegexEntityExtractor
shaysi
(Shaysi)
June 24, 2021, 10:26pm
7
The scenario is:
bot (utter_send_phone_number): "Can you send me your phone number?"
user (phone_number): 62982764567
bot (action_continue_conversation): continue the form
And I’m didn’t created any custom slot…
I read that post and I don’t know if it fits in my situation.
http://forum.rasa.com/t/failed-test-stories-for-inform/43802
nik202
(NiK202)
June 24, 2021, 10:28pm
8
@shaysi why you mention this rather then any
regex_phone_number:
type: rasa.shared.core.slots.FloatSlot
See this Domain and see the custom slot example. Your example look like the same.
shaysi
(Shaysi)
June 24, 2021, 10:28pm
9
yes, in my pipeline have RegexEntityExtractor. The bot-user flow is correct, but the tests are failing.
nik202
(NiK202)
June 24, 2021, 10:32pm
10
@shaysi
I hope you remember this video https://youtu.be/tMR1PNe0JB4 please see how this guy used regex in NLU.yml.
shaysi
(Shaysi)
June 25, 2021, 2:59pm
11
Yes, I remember, thanks.
But the problem here now is that I’m extracting correctly and the conversation between the user and bot is going great. Only the tests are failing
nik202
(NiK202)
June 25, 2021, 3:04pm
12
@shaysi can you share the error please?
shaysi
(Shaysi)
June 25, 2021, 3:17pm
13
These are the lines from my test output:
- action: utter_ask_phone_number
- intent: phone_number # ERROR HERE predicted: invalid_number: [61995213456](regex_phone_number)
shaysi
(Shaysi)
June 25, 2021, 3:18pm
14
So, it took a valid number, but classified it as a invalid_number
nik202
(NiK202)
June 25, 2021, 3:19pm
15
@shaysi check the indentation please for intent? some where you mention without - in intent?
shaysi
(Shaysi)
June 25, 2021, 3:30pm
16
Sure, this is my test
- story: User agree to use phone number
steps:
(...)
- action: utter_send_phone_number
- user: |
[61995213456](regex_phone_number)
intent: phone_number
- slot_was_set:
- regex_phone_number: "61995213456"
nik202
(NiK202)
June 25, 2021, 3:32pm
17
@shaysi still the same error? check all yml file http://www.yamllint.com/
shaysi
(Shaysi)
June 25, 2021, 5:11pm
18
yes, the same error.
And this link you sent me results in a valid yaml
nik202
(NiK202)
June 25, 2021, 7:28pm
19
@shaysi your code seem fine, do check the indentations for others too. You data validation fails right?
action: utter_ask_phone_number
intent: phone_number # predicted: invalid_number: 61995213456
shaysi
(Shaysi)
June 29, 2021, 4:14pm
20
yes, exactly! checked everything, but still no success