WB_Branch #2
@ -1,7 +1,6 @@
|
||||
class DialogueState:
|
||||
|
||||
def init(self):
|
||||
def __init__(self):
|
||||
self.currentActs = []
|
||||
self.previousActs = []
|
||||
self.botName = 'Dia'
|
||||
self.date = None
|
||||
self.date = None
|
||||
|
15
model/SystemActFrame.py
Normal file
15
model/SystemActFrame.py
Normal 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
|
@ -1,9 +1,18 @@
|
||||
from presenter.chatbot_modules.DialogueStateTracker import DialogueStateTracker
|
||||
from presenter.chatbot_modules.NaturalLanguageGeneration import NaturalLanguageGeneration
|
||||
from presenter.chatbot_modules.NaturalLanguageUnderstanding import NaturalLanguageUnderstanding
|
||||
from presenter.chatbot_modules.DialoguePolicy import DialoguePolicy
|
||||
|
||||
|
||||
class Presenter:
|
||||
dialogue_state_tracker = DialogueStateTracker()
|
||||
nlu = NaturalLanguageUnderstanding()
|
||||
policy = DialoguePolicy()
|
||||
nlg = NaturalLanguageGeneration()
|
||||
|
||||
def process_user_input(self, user_input):
|
||||
nlu = NaturalLanguageUnderstanding()
|
||||
user_frames = nlu.text_to_user_frame(user_input)
|
||||
return ''
|
||||
user_frames = self.nlu.text_to_user_frame(user_input)
|
||||
dialogue_state = self.dialogue_state_tracker.processUserAct(user_frames)
|
||||
system_frames = self.policy.resolve_system_acts(dialogue_state)
|
||||
msg = self.nlg.generate_text(system_frames)
|
||||
return msg
|
||||
|
@ -1,10 +1,13 @@
|
||||
from model import DialogueState
|
||||
from model.SystemActFrame import SystemActFrame
|
||||
|
||||
|
||||
class DialoguePolicy:
|
||||
pass
|
||||
|
||||
def init(self):
|
||||
pass
|
||||
def resolve_system_acts(self, dialogueState):
|
||||
system_acts = []
|
||||
for act in dialogueState.currentActs:
|
||||
if "request()" in act.act:
|
||||
if 'imię' in act.parameters:
|
||||
system_acts.append(SystemActFrame("inform()", ["imię"]))
|
||||
|
||||
def resolveSystemActs(self, dialogueState):
|
||||
pass
|
||||
return system_acts
|
||||
|
@ -1,40 +1,17 @@
|
||||
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)
|
||||
else:
|
||||
pass
|
||||
return dialogueState
|
||||
|
||||
|
||||
# def setDialogueState(self, dialogueState):
|
||||
# self.DialogueState=dialogueState
|
||||
#
|
||||
# def getDialogueState(self, dialogueState):
|
||||
# return self.DialogueState
|
||||
return self.dialogueState
|
||||
|
@ -1,3 +1,9 @@
|
||||
class NaturalLanguageGeneration:
|
||||
def get_frame(self, input_from_user):
|
||||
pass
|
||||
|
||||
def generate_text(self, system_frames):
|
||||
for system_frame in system_frames:
|
||||
if system_frame.act == 'inform()':
|
||||
if 'imię' in system_frame.parameters:
|
||||
return 'Nazywam się Dia.'
|
||||
else:
|
||||
return 'Nie rozumiem co masz na myśli.'
|
||||
|
@ -5,9 +5,8 @@ def init_chat():
|
||||
print('Witamy w systemie elektronicznej rezerwacji Biletów! W czym mogę pomóc?')
|
||||
user_input = input()
|
||||
result = Presenter().process_user_input(user_input)
|
||||
for r in result:
|
||||
print(r)
|
||||
print(result)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
init_chat()
|
||||
init_chat()
|
||||
|
Loading…
Reference in New Issue
Block a user