Skip to content
Snippets Groups Projects
Unverified Commit 6109627b authored by zhuqi's avatar zhuqi Committed by GitHub
Browse files

Merge pull request #131 from ConvLab/readme

update RuleDST test script
parents e0245c1b b22e3bd2
No related branches found
No related tags found
No related merge requests found
......@@ -70,82 +70,88 @@ if __name__ == '__main__':
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.
# The domain may be one of ('Attraction', 'Hospital', 'Booking', 'Hotel', 'Restaurant', 'Taxi', 'Train', 'Police').
# 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 (dialog acts) is a list of (intent, domain, slot, value) tuples.
# RuleDST will only handle `inform` and `request` actions
action = [
["Inform", "Hotel", "Area", "east"],
["Inform", "Hotel", "Stars", "4"]
["inform", "hotel", "area", "east"],
["inform", "hotel", "stars", "4"]
]
# method `update` updates the attribute `state` of tracker, and returns it.
state = dst.update(action)
assert state == dst.state
assert state == {'user_action': [],
'system_action': [],
'belief_state': {'police': {'book': {'booked': []}, 'semi': {}},
'hotel': {'book': {'booked': [], 'people': '', 'day': '', 'stay': ''},
'semi': {'name': '',
'area': 'east',
assert state == {'belief_state': {'attraction': {'area': '', 'name': '', 'type': ''},
'hospital': {'department': ''},
'hotel': {'area': 'east',
'book day': '',
'book people': '',
'book stay': '',
'internet': '',
'name': '',
'parking': '',
'price range': '',
'stars': '4',
'internet': '',
'type': ''}},
'attraction': {'book': {'booked': []},
'semi': {'type': '', 'name': '', 'area': ''}},
'restaurant': {'book': {'booked': [], 'people': '', 'day': '', 'time': ''},
'semi': {'food': '', 'pricerange': '', 'name': '', 'area': ''}},
'hospital': {'book': {'booked': []}, 'semi': {'department': ''}},
'taxi': {'book': {'booked': []},
'semi': {'leaveAt': '',
'destination': '',
'type': ''},
'restaurant': {'area': '',
'book day': '',
'book people': '',
'book time': '',
'food': '',
'name': '',
'price range': ''},
'taxi': {'arrive by': '',
'departure': '',
'arriveBy': ''}},
'train': {'book': {'booked': [], 'people': ''},
'semi': {'leaveAt': '',
'destination': '',
'leave at': ''},
'train': {'arrive by': '',
'book people': '',
'day': '',
'arriveBy': '',
'departure': ''}}},
'departure': '',
'destination': '',
'leave at': ''}},
'booked': {},
'history': [],
'request_state': {},
'system_action': [],
'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.
dst.init_session()
action = [["Inform", "Train", "Arrive", "19:45"]]
action = [["inform", "train", "arrive by", "19:45"]]
state = dst.update(action)
assert state == {'user_action': [],
'system_action': [],
'belief_state': {'police': {'book': {'booked': []}, 'semi': {}},
'hotel': {'book': {'booked': [], 'people': '', 'day': '', 'stay': ''},
'semi': {'name': '',
'area': '',
assert state == {'belief_state': {'attraction': {'area': '', 'name': '', 'type': ''},
'hospital': {'department': ''},
'hotel': {'area': '',
'book day': '',
'book people': '',
'book stay': '',
'internet': '',
'name': '',
'parking': '',
'price range': '',
'stars': '',
'internet': '',
'type': ''}},
'attraction': {'book': {'booked': []},
'semi': {'type': '', 'name': '', 'area': ''}},
'restaurant': {'book': {'booked': [], 'people': '', 'day': '', 'time': ''},
'semi': {'food': '', 'pricerange': '', 'name': '', 'area': ''}},
'hospital': {'book': {'booked': []}, 'semi': {'department': ''}},
'taxi': {'book': {'booked': []},
'semi': {'leaveAt': '',
'destination': '',
'type': ''},
'restaurant': {'area': '',
'book day': '',
'book people': '',
'book time': '',
'food': '',
'name': '',
'price range': ''},
'taxi': {'arrive by': '',
'departure': '',
'arriveBy': ''}},
'train': {'book': {'booked': [], 'people': ''},
'semi': {'leaveAt': '',
'destination': '',
'leave at': ''},
'train': {'arrive by': '19:45',
'book people': '',
'day': '',
'arriveBy': '19:45',
'departure': ''}}},
'departure': '',
'destination': '',
'leave at': ''}},
'booked': {},
'history': [],
'request_state': {},
'system_action': [],
'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