aitech-sd-lab/makieta.py

57 lines
929 B
Python

acts_list = {'hello': 'welcomemsg'}
class Act_frame:
text = ''
act = []
class Dialogue_state_frame:
user_history = []
system_history = []
def NLU(text):
user_frame = Act_frame()
user_frame.text = text
if text == 'Cześć, jak masz na imię?':
user_frame.act = 'hello'
else:
pass
return user_frame
def DST(user_frame):
dialogue_frame = Dialogue_state_frame()
dialogue_frame.user_history.append((user_frame.text, user_frame.act))
# ...
return dialogue_frame
def DP(dialogue_frame):
system_frame = Act_frame()
system_frame.act = acts_list[dialogue_frame.user_history[-1][1]]
return system_frame
def NLG(system_frame):
answer = ''
if system_frame.act == 'welcomemsg':
answer = 'Witaj, nazywam się Usher'
else:
pass
return answer
text = 'Cześć, jak masz na imię?'
print(NLG(DP(DST(NLU(text)))))