diff --git a/convlab/dst/rule/multiwoz/dst.py b/convlab/dst/rule/multiwoz/dst.py index eb7d31cf4d5fd59089164210a08c2bf10e51b6ad..57e438a88e8c214b995acbab7fec1210b4f63e5e 100755 --- a/convlab/dst/rule/multiwoz/dst.py +++ b/convlab/dst/rule/multiwoz/dst.py @@ -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', - 'parking': '', - 'pricerange': '', - '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': '', - 'departure': '', - 'arriveBy': ''}}, - 'train': {'book': {'booked': [], 'people': ''}, - 'semi': {'leaveAt': '', - 'destination': '', - 'day': '', - 'arriveBy': '', - 'departure': ''}}}, + 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', + 'type': ''}, + 'restaurant': {'area': '', + 'book day': '', + 'book people': '', + 'book time': '', + 'food': '', + 'name': '', + 'price range': ''}, + 'taxi': {'arrive by': '', + 'departure': '', + 'destination': '', + 'leave at': ''}, + 'train': {'arrive by': '', + 'book people': '', + 'day': '', + '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': '', - 'parking': '', - 'pricerange': '', - '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': '', - 'departure': '', - 'arriveBy': ''}}, - 'train': {'book': {'booked': [], 'people': ''}, - 'semi': {'leaveAt': '', - 'destination': '', - 'day': '', - 'arriveBy': '19:45', - 'departure': ''}}}, + assert state == {'belief_state': {'attraction': {'area': '', 'name': '', 'type': ''}, + 'hospital': {'department': ''}, + 'hotel': {'area': '', + 'book day': '', + 'book people': '', + 'book stay': '', + 'internet': '', + 'name': '', + 'parking': '', + 'price range': '', + 'stars': '', + 'type': ''}, + 'restaurant': {'area': '', + 'book day': '', + 'book people': '', + 'book time': '', + 'food': '', + 'name': '', + 'price range': ''}, + 'taxi': {'arrive by': '', + 'departure': '', + 'destination': '', + 'leave at': ''}, + 'train': {'arrive by': '19:45', + 'book people': '', + 'day': '', + 'departure': '', + 'destination': '', + 'leave at': ''}}, + 'booked': {}, + 'history': [], 'request_state': {}, + 'system_action': [], 'terminated': False, - 'history': []} + 'user_action': []}