From 777e6fa497c91e6190895879ca238e942cfa0bad Mon Sep 17 00:00:00 2001 From: s444510 Date: Fri, 5 May 2023 00:42:26 +0200 Subject: [PATCH] fixes --- dp.py | 11 +++++------ nlg.py | 17 ++++++++++------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/dp.py b/dp.py index 5c81132..a839bf7 100644 --- a/dp.py +++ b/dp.py @@ -6,14 +6,13 @@ class DP: def update_system_action(self, state, last_user_act, last_system_act, slots): if state == UserActType['order']: if 'kind' not in slots[state]: - system_act = {'act': SystemActType['request'], 'slot': 'kind'} - return system_act + return {'act': SystemActType['request'], 'slot': 'kind'} elif 'size' not in slots[state]: - system_act = {'act': SystemActType['request'], 'slot': 'size'} - return system_act + return {'act': SystemActType['request'], 'slot': 'size'} elif 'plates' not in slots[state]: - system_act = {'act': SystemActType['request'], 'slot': 'plates'} - return system_act + return {'act': SystemActType['request'], 'slot': 'plates'} + else: + return {'act': SystemActType['confirm_domain']} else: if last_user_act == UserActType['hello']: diff --git a/nlg.py b/nlg.py index 2fc9f91..93ea65b 100644 --- a/nlg.py +++ b/nlg.py @@ -5,14 +5,17 @@ from UserActType import UserActType class NLG: def generate_response(self, state, last_user_act, last_system_act, slots, system_act): if state == UserActType['order']: - if system_act.act == SystemActType['request']: - if system_act.slot == 'kind': - return "Jaką pizzę chcesz zamówić?" - elif system_act.slot == 'size': + if system_act['act'] == SystemActType['request']: + if system_act['slot'] == 'kind': + return 'Jaką pizzę chcesz zamówić?' + elif system_act['slot'] == 'size': return 'Jakiego rozmiaru chcesz pizzę?' - elif system_act.slot == 'plates': + elif system_act['slot'] == 'plates': 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']: - return "Dzień dobry, w czym mogę pomóc?" + return 'Dzień dobry, w czym mogę pomóc?' else: - return "Przepraszam. Zdanie nie jest mi zrozumiałe. Spróbuj je sformułować w inny sposób." \ No newline at end of file + return 'Przepraszam. Zdanie nie jest mi zrozumiałe. Spróbuj je sformułować w inny sposób.' \ No newline at end of file