@@ -95,7 +95,6 @@ def _tiebreak_intents(intents, confidences):
95
95
)
96
96
return classification , score
97
97
98
- intent , score = self .detect_intents (msg )
99
98
lower_utterance = msg .utterance_text .lower ()
100
99
intents = []
101
100
confidences = []
@@ -108,37 +107,39 @@ def _tiebreak_intents(intents, confidences):
108
107
if self ._contains_phrase (lower_utterance , QUESTION_KEYPHRASES ):
109
108
intents .append (INTENT_LABELS [2 ])
110
109
confidences .append (0.5 )
110
+
111
111
if not intents :
112
112
colored_utterance = colored (msg .utterance_text , "light_blue" )
113
- self .log .info (f'No intents detected for:\n >>> "{ colored_utterance } ":' )
113
+ self .log .info (
114
+ f'No intents detected for:\n >>> "{ colored_utterance } ":' )
114
115
return None , - 1.0
116
+ else :
117
+ classification , confidence = _tiebreak_intents (intents , confidences )
118
+ classification = colored (classification , "light_green" )
119
+ self .publish_message (msg .utterance_text , classification , confidence )
115
120
116
- classification , confidence = _tiebreak_intents (intents , confidences )
117
- classification = colored (classification , "light_green" )
118
-
119
- if intent :
120
- self .publish_msg (msg .utterance_text , intent , score )
121
-
122
- def publish_msg (self , msg : DialogueUtterance , intent : str , score : float ):
121
+ def publish_message (self , msg : DialogueUtterance , intent : str ,
122
+ score : float ):
123
123
"""
124
124
Handles message publishing for an utterance with a detected intent.
125
125
"""
126
- pub_msg = self .copy_dialogue_utterance (msg ,
127
- node_name = "Intent Detection" ,
128
- copy_time = self .get_clock ().now ().to_msg ())
126
+ pub_msg = self .copy_dialogue_utterance (
127
+ msg , node_name = "Intent Detection" ,
128
+ copy_time = self .get_clock ().now ().to_msg ())
129
129
# Overwrite the user intent with the latest classification information.
130
130
pub_msg .intent = intent
131
131
pub_msg .intent_confidence_score = score
132
132
133
133
# Decide which intent topic to publish the message to.
134
134
published_topic = None
135
- if self ._contains_phrase (pub_msg .utterance_text .lower (), OVERRIDE_KEYPHRASES ):
135
+ if self ._contains_phrase (pub_msg .utterance_text .lower (),
136
+ OVERRIDE_KEYPHRASES ):
137
+ published_topic = PARAM_EXPECT_USER_INTENT_TOPIC
136
138
pub_msg .intent_confidence_score = 1.0
137
139
self ._expected_publisher .publish (pub_msg )
138
- published_topic = PARAM_EXPECT_USER_INTENT_TOPIC
139
140
else :
140
- self ._interp_publisher .publish (pub_msg )
141
141
published_topic = PARAM_INTERP_USER_INTENT_TOPIC
142
+ self ._interp_publisher .publish (pub_msg )
142
143
143
144
colored_utterance = colored (pub_msg .utterance_text , "light_blue" )
144
145
colored_intent = colored (pub_msg .intent , "light_green" )
0 commit comments