Skip to content
Snippets Groups Projects
Commit b22e3bd2 authored by zqwerty's avatar zqwerty
Browse files

update RuleDST test script

parent 8417eb23
No related branches found
No related tags found
No related merge requests found
...@@ -70,82 +70,88 @@ if __name__ == '__main__': ...@@ -70,82 +70,88 @@ if __name__ == '__main__':
dst = RuleDST() dst = RuleDST()
# Action is a dict. Its keys are strings(domain-type pairs, both uppercase and lowercase is OK) and its values are list of lists. # Action (dialog acts) is a list of (intent, domain, slot, value) tuples.
# The domain may be one of ('Attraction', 'Hospital', 'Booking', 'Hotel', 'Restaurant', 'Taxi', 'Train', 'Police'). # RuleDST will only handle `inform` and `request` actions
# The type may be "inform" or "request".
# For example, the action below has a key "Hotel-Inform", in which "Hotel" is domain and "Inform" is action type.
# Each list in the value of "Hotel-Inform" is a slot-value pair. "Area" is slot and "east" is value. "Star" is slot and "4" is value.
action = [ action = [
["Inform", "Hotel", "Area", "east"], ["inform", "hotel", "area", "east"],
["Inform", "Hotel", "Stars", "4"] ["inform", "hotel", "stars", "4"]
] ]
# method `update` updates the attribute `state` of tracker, and returns it. # method `update` updates the attribute `state` of tracker, and returns it.
state = dst.update(action) state = dst.update(action)
assert state == dst.state assert state == dst.state
assert state == {'user_action': [], assert state == {'belief_state': {'attraction': {'area': '', 'name': '', 'type': ''},
'system_action': [], 'hospital': {'department': ''},
'belief_state': {'police': {'book': {'booked': []}, 'semi': {}}, 'hotel': {'area': 'east',
'hotel': {'book': {'booked': [], 'people': '', 'day': '', 'stay': ''}, 'book day': '',
'semi': {'name': '', 'book people': '',
'area': 'east', 'book stay': '',
'internet': '',
'name': '',
'parking': '', 'parking': '',
'price range': '', 'price range': '',
'stars': '4', 'stars': '4',
'internet': '', 'type': ''},
'type': ''}}, 'restaurant': {'area': '',
'attraction': {'book': {'booked': []}, 'book day': '',
'semi': {'type': '', 'name': '', 'area': ''}}, 'book people': '',
'restaurant': {'book': {'booked': [], 'people': '', 'day': '', 'time': ''}, 'book time': '',
'semi': {'food': '', 'pricerange': '', 'name': '', 'area': ''}}, 'food': '',
'hospital': {'book': {'booked': []}, 'semi': {'department': ''}}, 'name': '',
'taxi': {'book': {'booked': []}, 'price range': ''},
'semi': {'leaveAt': '', 'taxi': {'arrive by': '',
'destination': '',
'departure': '', 'departure': '',
'arriveBy': ''}},
'train': {'book': {'booked': [], 'people': ''},
'semi': {'leaveAt': '',
'destination': '', 'destination': '',
'leave at': ''},
'train': {'arrive by': '',
'book people': '',
'day': '', 'day': '',
'arriveBy': '', 'departure': '',
'departure': ''}}}, 'destination': '',
'leave at': ''}},
'booked': {},
'history': [],
'request_state': {}, 'request_state': {},
'system_action': [],
'terminated': False, 'terminated': False,
'history': []} 'user_action': []}
# Please call `init_session` before a new dialog. This initializes the attribute `state` of tracker with a default state, which `convlab.util.multiwoz.state.default_state` returns. But You needn't call it before the first dialog, because tracker gets a default state in its constructor. # Please call `init_session` before a new dialog. This initializes the attribute `state` of tracker with a default state, which `convlab.util.multiwoz.state.default_state` returns. But You needn't call it before the first dialog, because tracker gets a default state in its constructor.
dst.init_session() dst.init_session()
action = [["Inform", "Train", "Arrive", "19:45"]] action = [["inform", "train", "arrive by", "19:45"]]
state = dst.update(action) state = dst.update(action)
assert state == {'user_action': [], assert state == {'belief_state': {'attraction': {'area': '', 'name': '', 'type': ''},
'system_action': [], 'hospital': {'department': ''},
'belief_state': {'police': {'book': {'booked': []}, 'semi': {}}, 'hotel': {'area': '',
'hotel': {'book': {'booked': [], 'people': '', 'day': '', 'stay': ''}, 'book day': '',
'semi': {'name': '', 'book people': '',
'area': '', 'book stay': '',
'internet': '',
'name': '',
'parking': '', 'parking': '',
'price range': '', 'price range': '',
'stars': '', 'stars': '',
'internet': '', 'type': ''},
'type': ''}}, 'restaurant': {'area': '',
'attraction': {'book': {'booked': []}, 'book day': '',
'semi': {'type': '', 'name': '', 'area': ''}}, 'book people': '',
'restaurant': {'book': {'booked': [], 'people': '', 'day': '', 'time': ''}, 'book time': '',
'semi': {'food': '', 'pricerange': '', 'name': '', 'area': ''}}, 'food': '',
'hospital': {'book': {'booked': []}, 'semi': {'department': ''}}, 'name': '',
'taxi': {'book': {'booked': []}, 'price range': ''},
'semi': {'leaveAt': '', 'taxi': {'arrive by': '',
'destination': '',
'departure': '', 'departure': '',
'arriveBy': ''}},
'train': {'book': {'booked': [], 'people': ''},
'semi': {'leaveAt': '',
'destination': '', 'destination': '',
'leave at': ''},
'train': {'arrive by': '19:45',
'book people': '',
'day': '', 'day': '',
'arriveBy': '19:45', 'departure': '',
'departure': ''}}}, 'destination': '',
'leave at': ''}},
'booked': {},
'history': [],
'request_state': {}, 'request_state': {},
'system_action': [],
'terminated': False, 'terminated': False,
'history': []} 'user_action': []}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment