add DST backbone
This commit is contained in:
parent
be761cfb54
commit
283f26a164
34
dst.py
Normal file
34
dst.py
Normal file
@ -0,0 +1,34 @@
|
||||
class SimpleRuleDST:
|
||||
def __init__(self):
|
||||
self.state = None
|
||||
self.init_session()
|
||||
|
||||
def update(self, user_act=None):
|
||||
for intent, domain, slot, value in user_act:
|
||||
domain = domain.lower()
|
||||
intent = intent.lower()
|
||||
slot = slot.lower()
|
||||
value = slot.lower()
|
||||
|
||||
if domain not in self.state['belief_state']:
|
||||
continue
|
||||
|
||||
if intent == 'inform':
|
||||
if slot == 'none' or slot == '':
|
||||
continue
|
||||
|
||||
domain_dic = self.state['belief_state'][domain]
|
||||
|
||||
if slot in domain_dic:
|
||||
self.state['belief_state'][domain][slot] = value
|
||||
|
||||
elif intent == 'request':
|
||||
if domain not in self.state['request_state']:
|
||||
self.state['request_state'][domain] = {}
|
||||
if slot not in self.state['request_state'][domain]:
|
||||
self.state['request_state'][domain][slot] = 0
|
||||
|
||||
return self.state
|
||||
|
||||
def init_session(self):
|
||||
self.state = None
|
Loading…
Reference in New Issue
Block a user