from dialogue_state import default_state # Monitor stanu dialogu class DST: def __init__(self): self.state = default_state() def update(self, user_act=None): for intent, domain, slot, value in user_act: domain = domain.lower() intent = intent.lower() slot = slot.lower() k = slot if 'inform' in intent: if k is None: continue domain_dic = self.state['belief_state'][domain] if k in domain_dic['semi']: self.state['belief_state'][domain]['semi'][k] = value elif k in domain_dic['book']: self.state['belief_state'][domain]['book'][k] = value if 'request' in intent: if domain not in self.state['request_state']: self.state['request_state'][domain] = {} if k not in self.state['request_state'][domain]: self.state['request_state'][domain][k] = 0 self.state['user_action'].append([intent, domain, slot, value]) return self.state def init_session(self): self.state = default_state() # Przykładowe uruchomienie dla kodu w izolacji """ dst = DST() print(dst.state) dst.update([['hello_inform', 'Cinema', 'Price', '15 zł'], ['Inform', 'Cinema', 'Movie', 'Batman']]) print(dst.state) """