Usunięcie convlaba z DSM
This commit is contained in:
parent
caea45471c
commit
4483747021
@ -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':
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user