From 3c8b0f7e88fc64cc80fefa5372805d63ae39f680 Mon Sep 17 00:00:00 2001 From: Wiktor Date: Mon, 26 Apr 2021 14:26:52 +0200 Subject: [PATCH] DialogueState.py correction --- model/DialogueState.py | 4 +-- model/SystemActFrame.py | 15 +++++++++ presenter/Presenter.py | 8 +++-- presenter/chatbot_modules/DialoguePolicy.py | 9 +++-- .../chatbot_modules/DialogueStateTracker.py | 33 +++++++------------ 5 files changed, 39 insertions(+), 30 deletions(-) create mode 100644 model/SystemActFrame.py diff --git a/model/DialogueState.py b/model/DialogueState.py index 980bb2d..a486c67 100644 --- a/model/DialogueState.py +++ b/model/DialogueState.py @@ -1,7 +1,7 @@ class DialogueState: - def init(self): + def __init__(self): self.currentActs = [] self.previousActs = [] self.botName = 'Dia' - self.date = None \ No newline at end of file + self.date = None diff --git a/model/SystemActFrame.py b/model/SystemActFrame.py new file mode 100644 index 0000000..2f6c515 --- /dev/null +++ b/model/SystemActFrame.py @@ -0,0 +1,15 @@ +class SystemActFrame: + + def __init__(self, act, parameters): + self.act = act + self.parameters = parameters + + def __str__(self): + result = "" + result += "Act: " + self.act + " Parameters: { " + for index, parameter in enumerate(self.parameters): + result += parameter + if index < len(self.parameters) - 1: + result += ', ' + result += ' }' + return result diff --git a/presenter/Presenter.py b/presenter/Presenter.py index f837ab6..8ce77e6 100644 --- a/presenter/Presenter.py +++ b/presenter/Presenter.py @@ -1,9 +1,13 @@ +from presenter.chatbot_modules.DialogueStateTracker import DialogueStateTracker from presenter.chatbot_modules.NaturalLanguageUnderstanding import NaturalLanguageUnderstanding class Presenter: + dialogue_state_tracker = DialogueStateTracker() + nlu = NaturalLanguageUnderstanding() def process_user_input(self, user_input): - nlu = NaturalLanguageUnderstanding() - user_frames = nlu.text_to_user_frame(user_input) + user_frames = self.nlu.text_to_user_frame(user_input) + dialogue_state = self.dialogue_state_tracker.processUserAct(user_frames) + return '' diff --git a/presenter/chatbot_modules/DialoguePolicy.py b/presenter/chatbot_modules/DialoguePolicy.py index 6515838..e5bb8e0 100644 --- a/presenter/chatbot_modules/DialoguePolicy.py +++ b/presenter/chatbot_modules/DialoguePolicy.py @@ -1,10 +1,9 @@ -from model import DialogueState - +from model.DialogueState import DialogueState class DialoguePolicy: - pass - def init(self): + def __init__(self): pass def resolveSystemActs(self, dialogueState): - pass \ No newline at end of file + + pass diff --git a/presenter/chatbot_modules/DialogueStateTracker.py b/presenter/chatbot_modules/DialogueStateTracker.py index 78b4899..46315f0 100644 --- a/presenter/chatbot_modules/DialogueStateTracker.py +++ b/presenter/chatbot_modules/DialogueStateTracker.py @@ -1,40 +1,31 @@ -from model import DialogueState +from model.DialogueState import DialogueState + class DialogueStateTracker: - def init(self, dialogueState): - pass + def __init__(self): + self.dialogueState = DialogueState() - def processinformFrame(self, userActsFrame, dialogueState): - """ - - :param userActsFrame: - :param dialogueState: - :return: - """ - - - def processUserAct(self, userActsFrame, dialogueState): + def processUserAct(self, userActsFrame): """ :param userActsFrame: input of user acts incoming :return: dialogueState """ - dialogueState.currentActs=userActsFrame + self.dialogueState.currentActs = userActsFrame if userActsFrame.act == 'hello()': pass elif userActsFrame.act == 'request': pass elif userActsFrame.act == 'inform': - dialogueState=self.processinformFrame(userActsFrame, dialogueState) + pass else: pass - return dialogueState + return self.dialogueState + def setDialogueState(self, dialogueState): + self.dialogueState = dialogueState - # def setDialogueState(self, dialogueState): - # self.DialogueState=dialogueState - # - # def getDialogueState(self, dialogueState): - # return self.DialogueState \ No newline at end of file + def getDialogueState(self, dialogueState): + return self.dialogueState