Compare commits

..

2 Commits

Author SHA1 Message Date
s444510
283f26a164 add DST backbone 2023-05-04 16:27:18 +02:00
s444510
be761cfb54 add .gitignore 2023-05-04 16:26:42 +02:00
2 changed files with 35 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.idea/

34
dst.py Normal file
View 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