# Rule policy
Rule policy is a rule based **system** dialog policy. It takes a dialog state as input and generates system's dialog act. We implement it on Multiwoz dataset.

## How to use

Example:

```python
from convlab.policy.rule.multiwoz.rule_based_multiwoz_bot import RuleBasedMultiwozBot
sys_policy = RuleBasedMultiwozBot()

# Policy takes dialog state as input. Please refer to convlab.util.multiwoz.state

state = {'user_action': [["Inform", "Hotel", "Area", "east"], ["Inform", "Hotel", "Stars", "4"]],
'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': ''}}},
 'request_state': {},
 'terminated': False,
 'history': []}

# Please call `init_session` before a new session, this clears policy's history info.
sys_policy.init_session()
    
# method `predict` takes state output from tracker, and generates system's dialog act.
sys_da = sys_policy.predict(state)
```

# Agenda Policy

Agenda policy is a rule based **user** dialog policy. It takes a system's dialog act as input and generates user's dialog act. It maintains a stack-like structure containing the pending user dialogue acts that are needed to elicit the information specified in the goal. We implement it on Multiwoz dataset.

## How to use

```
user_simulator = UserPolicyAgendaMultiWoz()
user_simulator.init_session()
user_action, session_over = user_simulator.predict({'system_action': sys_action})
```

## Reference

```
@inproceedings{schatzmann2007agenda,
  title={Agenda-based user simulation for bootstrapping a POMDP dialogue system},
  author={Schatzmann, Jost and Thomson, Blaise and Weilhammer, Karl and Ye, Hui and Young, Steve},
  booktitle={Human Language Technologies 2007: The Conference of the North American Chapter of the Association for Computational Linguistics; Companion Volume, Short Papers},
  pages={149--152},
  year={2007},
  organization={Association for Computational Linguistics}
}
```

