SystemyDialogowe/DialogueStateTracker.py

47 lines
1.4 KiB
Python
Raw Normal View History

2021-05-31 13:52:01 +02:00
from os import system
2021-04-26 00:29:07 +02:00
from UserActType import UserActType
from UserAct import UserAct
class DST:
def __init__(self):
self.state = None
2021-05-31 13:52:01 +02:00
self.last_user_act = None
self.last_system_act = None
self.slots = {}
2021-05-31 13:52:01 +02:00
def user_update(self, frame):
user_act = frame.getActType()
self.last_user_act = user_act
for slot in frame.getActParams():
if slot[0] == 'participant':
if 'participants' not in self.slots:
self.slots['participants'] = [slot[1]]
else:
self.slots['participants'].append(slot[1])
else:
self.slots[slot[0]] = slot[1]
if not self.state:
if user_act in [UserActType.CREATE_MEETING, UserActType.UPDATE_MEETING, UserActType.CANCEL_MEETING, UserActType.MEETING_LIST, UserActType.FREE_TIME]:
self.state = user_act
2021-04-26 00:29:07 +02:00
2021-05-31 13:52:01 +02:00
def system_update(self, system_act):
self.last_system_act = system_act
2021-04-26 00:29:07 +02:00
2021-05-31 13:52:01 +02:00
def insert_empty_slot(self, slot_name):
self.slots[slot_name] = None
def clear(self):
self.state = None
2021-05-31 14:53:20 +02:00
self.last_system_act = None
2021-05-31 13:52:01 +02:00
self.slots = {}
def clear_slots(self):
self.slots = {}
def get_dialogue_state(self):
return self.state, self.last_user_act, self.last_system_act
def get_dialogue_slots(self):
return self.slots