@@ -70,13 +70,13 @@ def filter_entities(self, parse_data):
7070
7171 if len (filtered ) < len (parse_data ['entities' ]):
7272 # logging first
73- logger .warn ("entity(ies) were removed from parse stories" )
73+ logger .warning ("entity(ies) were removed from parse stories" )
7474 parse_data ['entities' ] = filtered
7575
7676 def run_swap_intent_rules (self , parse_data , tracker ):
77- # don't do anything if no intent is present
78- if parse_data ["intent" ]["name" ] is None or parse_data ["intent" ]["name" ] == "" :
79- return
77+ # # don't do anything if no intent is present
78+ # if parse_data["intent"]["name"] is None or parse_data["intent"]["name"] == "":
79+ # return
8080
8181 previous_action = self ._get_previous_action (tracker )
8282
@@ -87,24 +87,29 @@ def run_swap_intent_rules(self, parse_data, tracker):
8787 @staticmethod
8888 def _swap_intent (parse_data , previous_action , rule ):
8989 # don't do anything if no intent is present
90- if parse_data ["intent" ]["name" ] is None or parse_data ["intent" ]["name" ] == "" :
91- return
90+ # if parse_data["intent"]["name"] is None or parse_data["intent"]["name"] == "":
91+ # return
9292
9393 # for an after rule
9494 if previous_action and 'after' in rule and re .match (rule ['after' ], previous_action ):
9595 return Rules ._swap_intent_after (parse_data , rule )
9696
9797 # for a general substitution
98- elif 'after' not in rule and re .match (rule ['intent' ], parse_data ['intent' ]['name' ]):
99- return Rules .swap_intent_with (parse_data , rule )
98+ elif 'after' not in rule :
99+ if rule ['intent' ] is None or parse_data ['intent' ]['name' ] is None :
100+ return
101+ if (rule ['intent' ] is None and parse_data ['intent' ]['name' ] is None ) \
102+ or (re .match (rule ['intent' ], parse_data ['intent' ]['name' ])):
103+ return Rules .swap_intent_with (parse_data , rule )
100104
101105 @staticmethod
102106 def _swap_intent_after (parse_data , rule ):
103107 rule ['unless' ] = rule ['unless' ] if 'unless' in rule else []
104- if parse_data ['intent' ]['name' ] not in rule ['unless' ]:
105- logger .warn (
108+ if parse_data ['intent' ]['name' ] is None or parse_data [ 'intent' ][ 'name' ] not in rule ['unless' ]:
109+ logger .warning (
106110 "intent '{}' was replaced with '{}'" .format (parse_data ['intent' ]['name' ], rule ['intent' ]))
107111 parse_data ['intent' ]['name' ] = rule ['intent' ]
112+ parse_data ['intent' ]['confidence' ] = 1.0
108113 parse_data .pop ('intent_ranking' , None )
109114 return True
110115
0 commit comments