WB_Branch #2

Merged
s470609 merged 2 commits from WB_Branch into master 2021-04-26 15:03:18 +02:00
6 changed files with 27 additions and 28 deletions
Showing only changes of commit 4747e3bb21 - Show all commits

View File

@ -3,5 +3,4 @@ class DialogueState:
def __init__(self):
self.currentActs = []
self.previousActs = []
self.botName = 'Dia'
self.date = None

View File

@ -1,13 +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):
user_frames = self.nlu.text_to_user_frame(user_input)
dialogue_state = self.dialogue_state_tracker.processUserAct(user_frames)
return ''
system_frames = self.policy.resolve_system_acts(dialogue_state)
msg = self.nlg.generate_text(system_frames)
return msg

View File

@ -1,9 +1,13 @@
from model.DialogueState import DialogueState
from model.SystemActFrame import SystemActFrame
class DialoguePolicy:
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

View File

@ -14,18 +14,4 @@ class DialogueStateTracker:
"""
self.dialogueState.currentActs = userActsFrame
if userActsFrame.act == 'hello()':
pass
elif userActsFrame.act == 'request':
pass
elif userActsFrame.act == 'inform':
pass
else:
pass
return self.dialogueState
def setDialogueState(self, dialogueState):
self.dialogueState = dialogueState
def getDialogueState(self, dialogueState):
return self.dialogueState

View File

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

View File

@ -5,8 +5,7 @@ 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__":