Zmiany dla dialog policy
This commit is contained in:
parent
a928c925fc
commit
49d4b93245
@ -5,29 +5,46 @@ from model.slot import Slot
|
||||
class DialogPolicy:
|
||||
|
||||
def predict(self, dsm):
|
||||
system_action = defaultdict(list)
|
||||
last_frame = dsm.state['history'][-1]
|
||||
if(dsm.state['was_previous_order_invalid'] == False):
|
||||
match(last_frame.act.strip('/')):
|
||||
if("inform" in last_frame.act):
|
||||
act = last_frame.act.split('/')[0]
|
||||
else:
|
||||
act = last_frame.act
|
||||
match(act):
|
||||
case "inform" | "affirm":
|
||||
current_active_status = dsm.get_current_active_stage()
|
||||
match(current_active_status):
|
||||
case "collect_food":
|
||||
system_action["inform"].append(["menu", dsm.state['constants']['menu']])
|
||||
return Frame(source="system", act = "request/food")
|
||||
case "collect_drinks":
|
||||
system_action["inform"].append(["drink", dsm.state['constants']['drink']])
|
||||
return Frame(source="system", act = "request/drinks")
|
||||
case "collect_address":
|
||||
system_action["request"].append(["address"])
|
||||
return Frame(source="system", act = "request/address")
|
||||
if(current_active_status == None):
|
||||
system_action["inform"].append(["order", dsm.belief_state])
|
||||
case "request":
|
||||
for slot in last_frame.slots:
|
||||
system_action["inform"].append([slot, dsm.state['constants'][slot]])
|
||||
dsm.state['was_previous_order_invalid'] = False
|
||||
return Frame(source="system", act = "end")
|
||||
case "request/menu":
|
||||
return Frame(source="system", act = "inform", slots = [Slot("menu", dsm.state['constants']['menu'])])
|
||||
case "request/price":
|
||||
return Frame(source="system", act = "inform", slots = [Slot("price", dsm.state['total_cost'])])
|
||||
case "request/ingredients":
|
||||
return Frame(source="system", act = "inform", slots = [Slot("ingredients", dsm.state['constants']['ingredients'])])
|
||||
case "request/sauce":
|
||||
return Frame(source="system", act = "inform", slots = [Slot("sauce", dsm.state['constants']['sauce'])])
|
||||
case "request/time":
|
||||
return Frame(source="system", act = "inform", slots = [Slot("time", dsm.state['belief_state']['time'])])
|
||||
case "request/size":
|
||||
return Frame(source="system", act = "inform", slots = [Slot("size", dsm.state['constants']['size'])])
|
||||
case "request/delivery-price":
|
||||
return Frame(source="system", act = "inform", slots = [Slot("delivery-price", "10")])
|
||||
case "request/drinks":
|
||||
return Frame(source="system", act = "inform", slots = [Slot("drink", dsm.state['constants']['drink'])])
|
||||
case "welcomemsg":
|
||||
system_action["inform"].append(["menu", dsm.state['constants']['menu']])
|
||||
return Frame(source="system", act = "inform", slots = [Slot("menu", dsm.state['constants']['menu'])])
|
||||
case "bye":
|
||||
system_action["bye"].append([[], None])
|
||||
return Frame(source="system", act = "bye")
|
||||
case "negate":
|
||||
system_action["affirm"].append([[], None])
|
||||
return Frame(source="system", act = "affirm")
|
||||
|
||||
return system_action
|
||||
return Frame(source="system", act = "repeat")
|
Loading…
Reference in New Issue
Block a user