DialogueState.py correction

This commit is contained in:
Wiktor 2021-04-26 14:26:52 +02:00
parent a6169d14c1
commit 3c8b0f7e88
5 changed files with 39 additions and 30 deletions

View File

@ -1,6 +1,6 @@
class DialogueState: class DialogueState:
def init(self): def __init__(self):
self.currentActs = [] self.currentActs = []
self.previousActs = [] self.previousActs = []
self.botName = 'Dia' self.botName = 'Dia'

15
model/SystemActFrame.py Normal file
View File

@ -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

View File

@ -1,9 +1,13 @@
from presenter.chatbot_modules.DialogueStateTracker import DialogueStateTracker
from presenter.chatbot_modules.NaturalLanguageUnderstanding import NaturalLanguageUnderstanding from presenter.chatbot_modules.NaturalLanguageUnderstanding import NaturalLanguageUnderstanding
class Presenter: class Presenter:
dialogue_state_tracker = DialogueStateTracker()
nlu = NaturalLanguageUnderstanding()
def process_user_input(self, user_input): def process_user_input(self, user_input):
nlu = NaturalLanguageUnderstanding() user_frames = self.nlu.text_to_user_frame(user_input)
user_frames = nlu.text_to_user_frame(user_input) dialogue_state = self.dialogue_state_tracker.processUserAct(user_frames)
return '' return ''

View File

@ -1,10 +1,9 @@
from model import DialogueState from model.DialogueState import DialogueState
class DialoguePolicy: class DialoguePolicy:
pass
def init(self): def __init__(self):
pass pass
def resolveSystemActs(self, dialogueState): def resolveSystemActs(self, dialogueState):
pass pass

View File

@ -1,40 +1,31 @@
from model import DialogueState from model.DialogueState import DialogueState
class DialogueStateTracker: class DialogueStateTracker:
def init(self, dialogueState): def __init__(self):
pass self.dialogueState = DialogueState()
def processinformFrame(self, userActsFrame, dialogueState): def processUserAct(self, userActsFrame):
"""
:param userActsFrame:
:param dialogueState:
:return:
"""
def processUserAct(self, userActsFrame, dialogueState):
""" """
:param userActsFrame: input of user acts incoming :param userActsFrame: input of user acts incoming
:return: dialogueState :return: dialogueState
""" """
dialogueState.currentActs=userActsFrame self.dialogueState.currentActs = userActsFrame
if userActsFrame.act == 'hello()': if userActsFrame.act == 'hello()':
pass pass
elif userActsFrame.act == 'request': elif userActsFrame.act == 'request':
pass pass
elif userActsFrame.act == 'inform': elif userActsFrame.act == 'inform':
dialogueState=self.processinformFrame(userActsFrame, dialogueState) pass
else: else:
pass pass
return dialogueState return self.dialogueState
def setDialogueState(self, dialogueState):
self.dialogueState = dialogueState
# def setDialogueState(self, dialogueState): def getDialogueState(self, dialogueState):
# self.DialogueState=dialogueState return self.dialogueState
#
# def getDialogueState(self, dialogueState):
# return self.DialogueState