From 4483747021a271f606bbef948afcb53702050bea Mon Sep 17 00:00:00 2001 From: Patryk Date: Sun, 9 Jun 2024 23:05:07 +0200 Subject: [PATCH] =?UTF-8?q?Usuni=C4=99cie=20convlaba=20z=20DSM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/service/dialog_state_monitor.py | 16 ++++------------ src/test/dialog_state_monitor.py | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/service/dialog_state_monitor.py b/src/service/dialog_state_monitor.py index c4728d0..b01e808 100644 --- a/src/service/dialog_state_monitor.py +++ b/src/service/dialog_state_monitor.py @@ -1,5 +1,4 @@ -from model.frame import Frame -from convlab.dst.dst import DST +from src.model.frame import Frame import copy @@ -8,14 +7,9 @@ def normalize(value): return ' '.join(value.split()) -class DialogStateMonitor(DST): - domain = 'restaurant' - +class DialogStateMonitor: def __init__(self): - DST.__init__(self) - self.__initial_state = dict(user_action=[], - system_action=[], - belief_state={ + self.__initial_state = dict(belief_state={ 'order': [], 'address': {}, 'order-complete': False, @@ -25,13 +19,11 @@ class DialogStateMonitor(DST): 'time': {}, 'name': {}, }, - booked={}, - request_state={}, - terminated=False, history=[]) self.state = copy.deepcopy(self.__initial_state) def update(self, frame: Frame): + self.state['history'].append(frame) if frame.source != 'user': return if frame.act == 'inform/order': diff --git a/src/test/dialog_state_monitor.py b/src/test/dialog_state_monitor.py index 922b26e..8614126 100644 --- a/src/test/dialog_state_monitor.py +++ b/src/test/dialog_state_monitor.py @@ -4,15 +4,22 @@ from src.model.slot import Slot dst = DialogStateMonitor() -dst.update(Frame('user', 'inform/order', [Slot('pizza', 'margaritta'), Slot('sauce', 'ketchup')])) -dst.update(Frame('user', 'inform/order', [Slot('pizza', 'carbonara')])) -dst.update(Frame('user', 'inform/order-complete', [])) +frame1 = Frame('user', 'inform/order', [Slot('pizza', 'margaritta'), Slot('sauce', 'ketchup')]) +frame2 = Frame('user', 'inform/order', [Slot('pizza', 'carbonara')]) +frame3 = Frame('user', 'inform/order-complete', []) +dst.update(frame1) +dst.update(frame2) +dst.update(frame3) assert dst.state['belief_state']['order'][0]['pizza'] == 'margaritta' assert dst.state['belief_state']['order'][0]['sauce'] == 'ketchup' -assert dst.state['belief_state']['order-complete'] == True +assert dst.state['belief_state']['order-complete'] is True +assert dst.state['history'][0] == frame1 +assert dst.state['history'][1] == frame2 +assert dst.state['history'][2] == frame3 dst.reset() assert dst.state['belief_state']['order'] == [] -assert dst.state['belief_state']['order-complete'] == False +assert dst.state['belief_state']['order-complete'] is False +assert len(dst.state['history']) == 0