Compare commits
No commits in common. "d789fcc10be49d27bcbc08e88deb7f45ce353691" and "d02bd4b5ae04665e35da6a73f59734c4521fe37d" have entirely different histories.
d789fcc10b
...
d02bd4b5ae
@ -4,12 +4,7 @@ import json
|
|||||||
import copy
|
import copy
|
||||||
|
|
||||||
|
|
||||||
def normalize(value):
|
class DialogStateMonitor:
|
||||||
value = value.lower()
|
|
||||||
return ' '.join(value.split())
|
|
||||||
|
|
||||||
|
|
||||||
class DialogStateMonitor(DST):
|
|
||||||
def __init__(self, initial_state_file: str = '../attributes.json'):
|
def __init__(self, initial_state_file: str = '../attributes.json'):
|
||||||
DST.__init__(self)
|
DST.__init__(self)
|
||||||
with open(initial_state_file) as file:
|
with open(initial_state_file) as file:
|
||||||
@ -30,28 +25,28 @@ class DialogStateMonitor(DST):
|
|||||||
if frame.act == 'inform/order':
|
if frame.act == 'inform/order':
|
||||||
new_order = dict()
|
new_order = dict()
|
||||||
for slot in frame.slots:
|
for slot in frame.slots:
|
||||||
new_order[slot.name] = normalize(slot.value)
|
new_order[slot.name] = slot.value
|
||||||
self.__memory['order'].append(new_order)
|
self.__memory['order'].append(new_order)
|
||||||
elif frame.act == 'inform/address':
|
elif frame.act == 'inform/address':
|
||||||
for slot in frame.slots:
|
for slot in frame.slots:
|
||||||
self.__memory['address'][slot.name] = normalize(slot.value)
|
self.__memory['address'][slot.name] = slot.value
|
||||||
elif frame.act == 'inform/phone':
|
elif frame.act == 'inform/phone':
|
||||||
for slot in frame.slots:
|
for slot in frame.slots:
|
||||||
self.__memory['phone'][slot.name] = normalize(slot.value)
|
self.__memory['phone'][slot.name] = slot.value
|
||||||
elif frame.act == 'inform/order-complete':
|
elif frame.act == 'inform/order-complete':
|
||||||
self.__memory['order-complete'] = True
|
self.__memory['order-complete'] = True
|
||||||
elif frame.act == 'inform/delivery':
|
elif frame.act == 'inform/delivery':
|
||||||
for slot in frame.slots:
|
for slot in frame.slots:
|
||||||
self.__memory['delivery'][slot.name] = normalize(slot.value)
|
self.__memory['delivery'][slot.name] = slot.value
|
||||||
elif frame.act == 'inform/payment':
|
elif frame.act == 'inform/payment':
|
||||||
for slot in frame.slots:
|
for slot in frame.slots:
|
||||||
self.__memory['payment'][slot.name] = normalize(slot.value)
|
self.__memory['payment'][slot.name] = slot.value
|
||||||
elif frame.act == 'inform/time':
|
elif frame.act == 'inform/time':
|
||||||
for slot in frame.slots:
|
for slot in frame.slots:
|
||||||
self.__memory['time'][slot.name] = normalize(slot.value)
|
self.__memory['time'][slot.name] = slot.value
|
||||||
elif frame.act == 'inform/name':
|
elif frame.act == 'inform/name':
|
||||||
for slot in frame.slots:
|
for slot in frame.slots:
|
||||||
self.__memory['name'][slot.name] = normalize(slot.value)
|
self.__memory['name'][slot.name] = slot.value
|
||||||
|
|
||||||
def read(self) -> dict:
|
def read(self) -> dict:
|
||||||
return self.__memory
|
return self.__memory
|
||||||
|
Loading…
Reference in New Issue
Block a user