Hi
I have a numeric data with tax id(numeric and length 9),routing number (numeric and length 9) and account number (numeric and length 5 to 15) but in some cases routing number is recognized as account number or tax id and account number as routing number or tax id and slots are getting set
Can you please let me know how to fix this problem
i am using forms in actions.py file because of this when ever i give some number it is setting any of the above slots by extracting entity from the input (even though that entity is not correct) without executing validation in forms due to which that slot gets skipped in forms as it is not none so can you please tell me how can i make it to validate slot before setting it with entity
Also please let me know how can i take text free with out checking it on NLU data as i have a name slots in my form
Below is training data,config file,actions.py file attached.
data nlu:
intent:inform
-
the grp number for my plan is O09911 and tax id is 678789811
-
tax id is 274950677
-
the tax id for my group number is 571952676
-
my tax id is 411751881
-
tax id 630170819
-
the tax id for my group number is 331470899
-
tax id is 611974874
-
my tax id is 510370611
-
my tax id is 831450835
-
tax id 510680191
-
tax id is 123479835
-
my tax id 504410110
-
tax is for my account 157508110
-
tax id for my plan is 248501011
-
tax id for my plan is 339510530
-
tax id for my account 420150362
-
my tax id is 531750813
-
the grp number for my plan is O01991 and tax id is 178189111
-
the grp number for my plan is B01771 and tax id is 118181811
-
the grp number for my plan is R11811 and tax id is 171581855
-
the account number is 12345
-
account no is 12349
-
acc number is 9991119
-
acc no is 78908794
-
the account number is 7284578
-
account no is 9879049
-
acc number is 9871119
-
acc no is 76701799
-
the account number is 52345
-
account no is 62741
-
acc number is 67891119
-
acc no is 12389087
-
the account number is 42345
-
account no is 82249
-
acc number is 5691122
-
acc no is 5608751
-
the routing number is 123123123
-
routing no 523163125
-
routing num 143143143
-
the routing number is 525153521
-
routing no 123173444
-
routing num 703103143
-
the routing number is 109193199
-
routing no 120103105
-
routing num 747147199
-
the routing number is 525125125
-
routing no 929169129
-
routing num 443743743
config.yml:
Configuration for Rasa NLU.
Components
language: en pipeline: supervised_embeddings
Configuration for Rasa Core.
Policies
policies:
- name: MemoizationPolicy max_history: 10
- name: KerasPolicy max_history: 10
- name: MappingPolicy
- name: FormPolicy
- name: FallbackPolicy nlu_threshold: 0.5 core_threshold: 0.5 fallback_action_name: âaction_custom_fallbackâ
actions.py: class UserLoginForm2(FormAction): âââExample of a custom form actionâ""
def name(self):
"""Unique identifier of the form"""
return "user_easypay2_form"
@staticmethod
def required_slots(tracker: Tracker) -> List[Text]:
"""A list of required slots that the form has to fill"""
print("*************required slots form has to fill started 2****************")
return ["accholdername","routingnumber","accountno"]
def slot_mappings(self):
# type: () -> Dict[Text: Union[Dict, List[Dict]]]
"""A dictionary to map required slots to
- an extracted entity
- intent: value pairs
- a whole message
or a list of them, where a first match will be picked"""
print("*****slot mappings*******")
return {"accholdername": [self.from_text()],
"routingnumber": [
self.from_entity(
entity="routingnumber", intent=["inform"]
),
self.from_entity(entity="number")
],
"accountno": [
self.from_entity(
entity="accountno", intent=["inform"]
),
self.from_entity(entity="number")
]}
def validate_slots(self,
slot_dict: Dict,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict]:
print("Enters into validation part in which we will validate the slots entered in form2")
slot_values = self.extract_other_slots(dispatcher, tracker, domain)
print("slot_values",slot_values)
slot_to_fill = tracker.get_slot(REQUESTED_SLOT)
print("slot_to_fill",slot_to_fill)
if slot_to_fill:
slot_values.update(self.extract_requested_slot(dispatcher, tracker, domain))
#print("slot values",slot_values)
for slot, value in slot_values.items():
print("******** Slot Validation started for form 2 **********")
##common_url=tracker.get_slot('common_url')
print("******** Slot Validation started for form 2 **********")
if slot == 'accholdername':
print("value in accounterholdername",value)
if(value.isalpha()):
print("Account holder name does not contain any alpha numeric characters")
else:
dispatcher.utter_message("Bank Account Holder's Name must be alphabatic")
print("Account holder name has alpha numeric characters or numbers")
dispatcher.utter_template('utter_ask_accholdername', tracker)
slot_values[slot] = None
elif slot == 'routingnumber':
print("value for routing number is",value,type(value))
try:
Num=int(value)
print("Roating number is Numeric",Num,type(Num))
except:
print("Error",sys.exc_info()[0])
print("Value conversion to numeric fail")
dispatcher.utter_template('Routing Number must be numeric', tracker)
slot_values[slot] = None
if (value.isnumeric()):
print("Roating number is numeric")
if (len(value)==9):
print("Roating number length matches")
## Roating number validation logic
routing_num_count = 0
number = 0
print("count",routing_num_count)
while(routing_num_count < len(value)):
number += int(value[routing_num_count]) * 3 + int(value[routing_num_count+1]) * 7 + int(value[routing_num_count+2])
routing_num_count= routing_num_count +3
print("Count value is",routing_num_count)
print("The value of number is : ",number,type(number))
if(number !=0 and number%10 ==0):
print("Routing Number check validated successfully")
else:
dispatcher.utter_message("Invalid Routing number. Please check and enter valid number.")
print("Routing Number check validation fail")
dispatcher.utter_template('utter_ask_routingnumber', tracker)
slot_values[slot] = None
else:
dispatcher.utter_message("Routing Number must be 9 digits.")
print("Roating number is non numeric")
dispatcher.utter_template('utter_ask_routingnumber', tracker)
slot_values[slot] = None
else:
dispatcher.utter_message("Routing Number must be numeric.")
print("Roating number is non numeric")
dispatcher.utter_template('utter_ask_routingnumber', tracker)
slot_values[slot] = None
elif slot == 'accountno':
print("value for account number is",value,type(value))
##In story roating number is defined as unfeaturized so we are converting it before
if (value.isnumeric()):
print("Account number is numeric")
if (len(value) > 5 or len(value) < 17):
print("Account number length matches")
else:
dispatcher.utter_message("Account Number must be at least 5 digits and max 17 digits")
print("Account number length not valid")
dispatcher.utter_template('utter_ask_accountno', tracker)
slot_values[slot] = None
else:
dispatcher.utter_message("Account Number must be numeric.")
print("Account number is not numeric")
dispatcher.utter_template('utter_ask_accountno', tracker)
slot_values[slot] = None
return [SlotSet(slot, value) for slot, value in slot_values.items()]
def submit(self,dispatcher: CollectingDispatcher,tracker: Tracker,domain: Dict[Text, Any],) -> List[Dict]:
"""Define what the form has to do after all required slots are filled"""
print("******Submitted button activated**********")
# utter submit template
accholdername= tracker.get_slot('accholdername')
routingnumber= tracker.get_slot('routingnumber')
accountno= tracker.get_slot('accountno')
print("accholdername",accholdername)
print("routingnumber",routingnumber)
print("accountno",accountno)
return[]