responding to "jak masz na imie" + basic logic

This commit is contained in:
Wiktor 2021-04-26 15:00:45 +02:00
parent 3c8b0f7e88
commit 4747e3bb21
6 changed files with 27 additions and 28 deletions

View File

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

View File

@ -1,13 +1,18 @@
from presenter.chatbot_modules.DialogueStateTracker import DialogueStateTracker 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.NaturalLanguageUnderstanding import NaturalLanguageUnderstanding
from presenter.chatbot_modules.DialoguePolicy import DialoguePolicy
class Presenter: class Presenter:
dialogue_state_tracker = DialogueStateTracker() dialogue_state_tracker = DialogueStateTracker()
nlu = NaturalLanguageUnderstanding() nlu = NaturalLanguageUnderstanding()
policy = DialoguePolicy()
nlg = NaturalLanguageGeneration()
def process_user_input(self, user_input): def process_user_input(self, user_input):
user_frames = self.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) dialogue_state = self.dialogue_state_tracker.processUserAct(user_frames)
system_frames = self.policy.resolve_system_acts(dialogue_state)
return '' 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: class DialoguePolicy:
def __init__(self): def resolve_system_acts(self, dialogueState):
pass 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): return system_acts
pass

View File

@ -14,18 +14,4 @@ class DialogueStateTracker:
""" """
self.dialogueState.currentActs = userActsFrame 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 return self.dialogueState

View File

@ -1,3 +1,9 @@
class NaturalLanguageGeneration: 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,9 +5,8 @@ def init_chat():
print('Witamy w systemie elektronicznej rezerwacji Biletów! W czym mogę pomóc?') print('Witamy w systemie elektronicznej rezerwacji Biletów! W czym mogę pomóc?')
user_input = input() user_input = input()
result = Presenter().process_user_input(user_input) result = Presenter().process_user_input(user_input)
for r in result: print(result)
print(r)
if __name__ == "__main__": if __name__ == "__main__":
init_chat() init_chat()