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