DST in dialogue_systems.py
This commit is contained in:
parent
372358b1a2
commit
8401deb358
@ -1,25 +1,22 @@
|
||||
# Adrian
|
||||
class DST:
|
||||
def __init__(self, slots):
|
||||
self.slots = slots
|
||||
|
||||
def getDialogueState(self, userActs):
|
||||
# iterate over speech acts
|
||||
|
||||
"""for k, v in userActs['inform'].items():
|
||||
for slot in self.slots:
|
||||
if slot == k:
|
||||
self.slots['name'] = v
|
||||
print(self.slots)"""
|
||||
if userActs['act']=='book':
|
||||
for (k,v) in userActs['slots']:
|
||||
print(k)
|
||||
if k in self.slots:
|
||||
self.slots[k]=v
|
||||
if userActs['act'] == 'book':
|
||||
if userActs['slots']:
|
||||
for (k, v) in userActs['slots']:
|
||||
print(k)
|
||||
if k in self.slots:
|
||||
self.slots[k] = v
|
||||
|
||||
# returns all slots
|
||||
return self.slots
|
||||
|
||||
|
||||
dst = DST()
|
||||
#userActs = {'inform': {'name': 'edyta', 'age': 18}, 'reqmore': {'date', 'time'}}
|
||||
ivona_acts={'act':'book','slots':[('name','ewa'), ('hour','dziesiąta'), ('size','trzech')]}
|
||||
print(dst.getDialogueState(ivona_acts))
|
||||
#dst = DST()
|
||||
# userActs = {'inform': {'name': 'edyta', 'age': 18}, 'reqmore': {'date', 'time'}}
|
||||
#ivona_acts = {'act': 'book', 'slots': [('name', 'ewa'), ('hour', 'dziesiąta'), ('size', 'trzech')]}
|
||||
#print(dst.getDialogueState(ivona_acts))
|
||||
|
@ -1,22 +1,30 @@
|
||||
from components.NLU import NLU
|
||||
from components.NLG import NLG
|
||||
from components.DST import DST
|
||||
|
||||
slots = [
|
||||
("title", None),
|
||||
("date", None),
|
||||
("time", None),
|
||||
("quantity", None),
|
||||
("location", None),
|
||||
("seats", None),
|
||||
("reservation_id", None),
|
||||
("goal", None),
|
||||
("area", None),
|
||||
]
|
||||
("title", None),
|
||||
("date", None),
|
||||
("time", None),
|
||||
("quantity", None),
|
||||
("location", None),
|
||||
("seats", None),
|
||||
("reservation_id", None),
|
||||
("goal", None),
|
||||
("area", None),
|
||||
]
|
||||
|
||||
|
||||
def generate_response(input):
|
||||
result = NLU.nlu(input)
|
||||
return result
|
||||
# nlu
|
||||
nlu = NLU.nlu(input)
|
||||
|
||||
# dst
|
||||
dst_obj = DST(slots)
|
||||
dst = dst_obj.getDialogueState(nlu)
|
||||
|
||||
return dst
|
||||
|
||||
|
||||
inputText = 'Cześć, jak masz na imię?'
|
||||
print(NLG.getResponse(generate_response(inputText)))
|
||||
|
Loading…
Reference in New Issue
Block a user