Final version for DP and DST
This commit is contained in:
parent
2fd3de96b4
commit
eecfcb2b03
@ -23,6 +23,10 @@ class DP():
|
|||||||
|
|
||||||
for user_act in user_action:
|
for user_act in user_action:
|
||||||
self.update_system_action(user_act, user_action, state, system_action)
|
self.update_system_action(user_act, user_action, state, system_action)
|
||||||
|
|
||||||
|
system_acts = [[intent, domain, slot, value] for (domain, intent), slots in system_action.items() for slot, value in slots]
|
||||||
|
state['system_action'] = system_acts
|
||||||
|
return system_acts
|
||||||
|
|
||||||
|
|
||||||
# # Reguła 3
|
# # Reguła 3
|
||||||
@ -36,16 +40,11 @@ class DP():
|
|||||||
|
|
||||||
def update_system_action(self, user_act, user_action, state, system_action):
|
def update_system_action(self, user_act, user_action, state, system_action):
|
||||||
domain, intent = user_act
|
domain, intent = user_act
|
||||||
constraints = [(slot, value) for slot, value in state['belief_state'][domain.lower()].items() if value != '']
|
|
||||||
|
|
||||||
|
|
||||||
print(domain)
|
|
||||||
print(intent)
|
|
||||||
print(constraints)
|
|
||||||
|
|
||||||
# Reguła 1
|
# Reguła 1
|
||||||
|
|
||||||
if domain == 'appointment':
|
if domain == 'appointment':
|
||||||
|
constraints = [(slot, value) for slot, value in state['belief_state'][domain.lower()].items() if value != '']
|
||||||
if len(constraints) == 0:
|
if len(constraints) == 0:
|
||||||
system_action[(domain, 'NoOffer')] = []
|
system_action[(domain, 'NoOffer')] = []
|
||||||
elif intent == 'appointment/create_appointment':
|
elif intent == 'appointment/create_appointment':
|
||||||
@ -88,12 +87,12 @@ class DP():
|
|||||||
#################################################################################################
|
#################################################################################################
|
||||||
# Reguła 3
|
# Reguła 3
|
||||||
if domain == 'end_conversation':
|
if domain == 'end_conversation':
|
||||||
system_action[(domain, 'End_Conversation')] = []
|
system_action[(domain, 'End_Conversation')].append(['0', '0'])
|
||||||
|
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
# Reguła 4
|
# Reguła 4
|
||||||
if domain == 'greeting':
|
if domain == 'greeting':
|
||||||
system_action[(domain, 'Greeting')] = []
|
system_action[(domain, 'Greeting')].append(['0', '0'])
|
||||||
|
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
# Reguła 5
|
# Reguła 5
|
||||||
@ -117,30 +116,6 @@ class DP():
|
|||||||
if len(constraints_v2) == 0:
|
if len(constraints_v2) == 0:
|
||||||
system_action[(domain, 'NoOffer')] = []
|
system_action[(domain, 'NoOffer')] = []
|
||||||
|
|
||||||
print(system_action)
|
#return system_action
|
||||||
|
|
||||||
## Brakuje: Rejestracja, Login, Hasło, affirm, deny
|
## Brakuje: Rejestracja, Login, Hasło, affirm, deny
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# if len(constraints) == 0:
|
|
||||||
# system_action[(domain, 'NoOffer')] = []
|
|
||||||
# else:
|
|
||||||
# for slot in user_action[user_act]:
|
|
||||||
# kb_slot_name = REF_SYS_DA[domain].get(slot[0], slot[0])
|
|
||||||
|
|
||||||
# if kb_slot_name in self.results[0]:
|
|
||||||
# system_action[(domain, 'Inform')].append([slot[0], self.results[0].get(kb_slot_name, 'unknown')])
|
|
||||||
|
|
||||||
# # Reguła 2
|
|
||||||
# elif intent == 'Inform':
|
|
||||||
# if len(self.results) == 0:
|
|
||||||
# system_action[(domain, 'NoOffer')] = []
|
|
||||||
# else:
|
|
||||||
# system_action[(domain, 'Inform')].append(['Choice', str(len(self.results))])
|
|
||||||
# choice = self.results[0]
|
|
||||||
|
|
||||||
# if domain in ["Hotel", "Attraction", "Police", "Restaurant"]:
|
|
||||||
# system_action[(domain, 'Recommend')].append(['Name', choice['name']])
|
|
@ -53,4 +53,5 @@ class Rules_DST(): #Dialogue State Tracker
|
|||||||
self.state['request_state'][domain][slot] = value
|
self.state['request_state'][domain][slot] = value
|
||||||
|
|
||||||
print(self.state)
|
print(self.state)
|
||||||
|
print("\n")
|
||||||
return self.state
|
return self.state
|
||||||
|
Loading…
Reference in New Issue
Block a user