Compare commits
2 Commits
6cd5dcad5c
...
283f26a164
Author | SHA1 | Date | |
---|---|---|---|
|
283f26a164 | ||
|
be761cfb54 |
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.idea/
|
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