This commit is contained in:
s444510 2023-05-05 00:42:26 +02:00
parent de703d016c
commit 777e6fa497
2 changed files with 15 additions and 13 deletions

11
dp.py
View File

@ -6,14 +6,13 @@ class DP:
def update_system_action(self, state, last_user_act, last_system_act, slots): def update_system_action(self, state, last_user_act, last_system_act, slots):
if state == UserActType['order']: if state == UserActType['order']:
if 'kind' not in slots[state]: if 'kind' not in slots[state]:
system_act = {'act': SystemActType['request'], 'slot': 'kind'} return {'act': SystemActType['request'], 'slot': 'kind'}
return system_act
elif 'size' not in slots[state]: elif 'size' not in slots[state]:
system_act = {'act': SystemActType['request'], 'slot': 'size'} return {'act': SystemActType['request'], 'slot': 'size'}
return system_act
elif 'plates' not in slots[state]: elif 'plates' not in slots[state]:
system_act = {'act': SystemActType['request'], 'slot': 'plates'} return {'act': SystemActType['request'], 'slot': 'plates'}
return system_act else:
return {'act': SystemActType['confirm_domain']}
else: else:
if last_user_act == UserActType['hello']: if last_user_act == UserActType['hello']:

17
nlg.py
View File

@ -5,14 +5,17 @@ from UserActType import UserActType
class NLG: class NLG:
def generate_response(self, state, last_user_act, last_system_act, slots, system_act): def generate_response(self, state, last_user_act, last_system_act, slots, system_act):
if state == UserActType['order']: if state == UserActType['order']:
if system_act.act == SystemActType['request']: if system_act['act'] == SystemActType['request']:
if system_act.slot == 'kind': if system_act['slot'] == 'kind':
return "Jaką pizzę chcesz zamówić?" return 'Jaką pizzę chcesz zamówić?'
elif system_act.slot == 'size': elif system_act['slot'] == 'size':
return 'Jakiego rozmiaru chcesz pizzę?' return 'Jakiego rozmiaru chcesz pizzę?'
elif system_act.slot == 'plates': elif system_act['slot'] == 'plates':
return 'Dla ilu osób ma to być?' return 'Dla ilu osób ma to być?'
elif system_act['act'] == SystemActType['confirm_domain']:
return 'Czy mam dodać tę pizzę do zamówienia?\nPizza: {}\nRozmiar: {}\nIlość osób: {}'.\
format(slots['order']['kind'], slots['order']['size'], slots['order']['plates'])
elif last_user_act == UserActType['hello']: elif last_user_act == UserActType['hello']:
return "Dzień dobry, w czym mogę pomóc?" return 'Dzień dobry, w czym mogę pomóc?'
else: else:
return "Przepraszam. Zdanie nie jest mi zrozumiałe. Spróbuj je sformułować w inny sposób." return 'Przepraszam. Zdanie nie jest mi zrozumiałe. Spróbuj je sformułować w inny sposób.'