mockup #7

Merged
s444519 merged 19 commits from mockup into master 2022-05-04 12:47:45 +02:00
2 changed files with 32 additions and 27 deletions
Showing only changes of commit 8401deb358 - Show all commits

View File

@ -1,25 +1,22 @@
# Adrian # Adrian
class DST: class DST:
def __init__(self, slots):
self.slots = slots
def getDialogueState(self, userActs): def getDialogueState(self, userActs):
# iterate over speech acts # iterate over speech acts
if userActs['act'] == 'book':
"""for k, v in userActs['inform'].items(): if userActs['slots']:
for slot in self.slots: for (k, v) in userActs['slots']:
if slot == k: print(k)
self.slots['name'] = v if k in self.slots:
print(self.slots)""" self.slots[k] = v
if userActs['act']=='book':
for (k,v) in userActs['slots']:
print(k)
if k in self.slots:
self.slots[k]=v
# returns all slots # returns all slots
return self.slots return self.slots
dst = DST() #dst = DST()
#userActs = {'inform': {'name': 'edyta', 'age': 18}, 'reqmore': {'date', 'time'}} # userActs = {'inform': {'name': 'edyta', 'age': 18}, 'reqmore': {'date', 'time'}}
ivona_acts={'act':'book','slots':[('name','ewa'), ('hour','dziesiąta'), ('size','trzech')]} #ivona_acts = {'act': 'book', 'slots': [('name', 'ewa'), ('hour', 'dziesiąta'), ('size', 'trzech')]}
print(dst.getDialogueState(ivona_acts)) #print(dst.getDialogueState(ivona_acts))

View File

@ -1,22 +1,30 @@
from components.NLU import NLU from components.NLU import NLU
from components.NLG import NLG from components.NLG import NLG
from components.DST import DST
slots = [ slots = [
("title", None), ("title", None),
("date", None), ("date", None),
("time", None), ("time", None),
("quantity", None), ("quantity", None),
("location", None), ("location", None),
("seats", None), ("seats", None),
("reservation_id", None), ("reservation_id", None),
("goal", None), ("goal", None),
("area", None), ("area", None),
] ]
def generate_response(input): def generate_response(input):
result = NLU.nlu(input) # nlu
return result nlu = NLU.nlu(input)
# dst
dst_obj = DST(slots)
dst = dst_obj.getDialogueState(nlu)
return dst
inputText = 'Cześć, jak masz na imię?' inputText = 'Cześć, jak masz na imię?'
print(NLG.getResponse(generate_response(inputText))) print(NLG.getResponse(generate_response(inputText)))