[英]PyQt4: Signal slot mechanism doesn't work correctly for 'List of buttons'
[英]Slot validation in formaction doesn't work
大家好,我有一个问题。 自从我开始使用rasa-nlu
和rasa-core
已有一段时间以来,我的问题是为什么对我的阵型的验证不能正确进行? 我正在打印slotvalues
,它总是返回空。 我想知道如何解决这个问题,它只要求第一个插槽,然后就吹了!
这是我的代码:
def validate(self,dispatcher: CollectingDispatcher,tracker: Tracker,domain: Dict[Text, Any]) -> List[Dict]:
slot_values = self.extract_other_slots(dispatcher, tracker, domain)
print('slot values:',slot_values)
slot_to_fill = tracker.get_slot(REQUESTED_SLOT)
if slot_to_fill:
slot_values.update(self.extract_requested_slot(dispatcher,tracker, domain))
if not slot_values:
raise ActionExecutionRejection(self.name(),"Failed to validate slot {0} with action {1}".format(slot_to_fill,self.name()))
for slot, value in slot_values.items():
print('Slot: ',slot)
print('valor: ',values)
if slot == 'tipo_habitacion':
if value.lower() not in self.habitaciones_db():
dispatcher.utter_template('utter_wrong_tipo_habitacion', tracker)
# validation failed, set slot to None
slot_values[slot] = None
if slot == 'mes':
if value.lower() not in self.meses_db():
dispatcher.utter_template('utter_wrong_mes', tracker)
# validation failed, set slot to None
slot_values[slot] = None
elif slot == 'num_adultos':
if not self.is_int(value) or int(value) <= 0:
dispatcher.utter_template('utter_wrong_num_adultos',tracker)
# validation failed, set slot to None
slot_values[slot] = None
elif slot == 'num_niños':
if not self.is_int(value) or int(value) <= 0:
dispatcher.utter_template('utter_wrong_num_niños',tracker)
# validation failed, set slot to None
slot_values[slot] = None
elif slot == 'dia':
if not self.is_int(value) or int(value) <= 0:
dispatcher.utter_template('utter_wrong_dia',tracker)
# validation failed, set slot to None
slot_values[slot] = None
# validation succeed, set the slots values to the extracted values
return [SlotSet(slot, value) for slot, value in slot_values.items()]
我可以看到的一个问题是
if not slot_values:
raise ActionExecutionRejection(self.name(),"Failed to validate slot {0} with action {1}".format(slot_to_fill,self.name()))
if slot_to_fill:
应该从内部if slot_to_fill:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.