From eecfcb2b0368582d261048fb24bfdaecf0cae474 Mon Sep 17 00:00:00 2001 From: Dominik Strzako Date: Mon, 31 May 2021 15:28:48 +0200 Subject: [PATCH] Final version for DP and DST --- Code/Modules/DP_module.py | 43 ++++++++------------------------------ Code/Modules/DST_module.py | 1 + 2 files changed, 10 insertions(+), 34 deletions(-) diff --git a/Code/Modules/DP_module.py b/Code/Modules/DP_module.py index bccdd0e..6a9b08b 100644 --- a/Code/Modules/DP_module.py +++ b/Code/Modules/DP_module.py @@ -23,6 +23,10 @@ class DP(): for user_act in user_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 @@ -36,16 +40,11 @@ class DP(): def update_system_action(self, user_act, user_action, state, system_action): 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 if domain == 'appointment': + constraints = [(slot, value) for slot, value in state['belief_state'][domain.lower()].items() if value != ''] if len(constraints) == 0: system_action[(domain, 'NoOffer')] = [] elif intent == 'appointment/create_appointment': @@ -88,12 +87,12 @@ class DP(): ################################################################################################# # Reguła 3 if domain == 'end_conversation': - system_action[(domain, 'End_Conversation')] = [] + system_action[(domain, 'End_Conversation')].append(['0', '0']) ################################################################################################# # Reguła 4 if domain == 'greeting': - system_action[(domain, 'Greeting')] = [] + system_action[(domain, 'Greeting')].append(['0', '0']) ################################################################################################# # Reguła 5 @@ -117,30 +116,6 @@ class DP(): if len(constraints_v2) == 0: system_action[(domain, 'NoOffer')] = [] - print(system_action) + #return system_action - ## 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']]) \ No newline at end of file + ## Brakuje: Rejestracja, Login, Hasło, affirm, deny \ No newline at end of file diff --git a/Code/Modules/DST_module.py b/Code/Modules/DST_module.py index fd87aba..ffeda1d 100644 --- a/Code/Modules/DST_module.py +++ b/Code/Modules/DST_module.py @@ -53,4 +53,5 @@ class Rules_DST(): #Dialogue State Tracker self.state['request_state'][domain][slot] = value print(self.state) + print("\n") return self.state