From d85e9c0d46cbf81ce9426b525d9806560706c62d Mon Sep 17 00:00:00 2001 From: zqwerty <zhuq96@hotmail.com> Date: Wed, 29 Jun 2022 17:15:26 +0800 Subject: [PATCH] update TemplateNLG to accept flatten dialog acts in unified format --- convlab/nlg/template/multiwoz/nlg.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/convlab/nlg/template/multiwoz/nlg.py b/convlab/nlg/template/multiwoz/nlg.py index c72c752b..f83a6db4 100755 --- a/convlab/nlg/template/multiwoz/nlg.py +++ b/convlab/nlg/template/multiwoz/nlg.py @@ -11,6 +11,7 @@ from convlab.nlg import NLG from convlab.nlg.template.multiwoz.noise_functions import delete_random_token, random_token_permutation, spelling_noise from convlab.util.multiwoz.multiwoz_slot_trans import REF_SYS_DA from convlab.util import relative_import_module_from_unified_datasets +from convlab.policy.rule.multiwoz.policy_agenda_multiwoz import unified_format, act_dict_to_flat_tuple reverse_da = relative_import_module_from_unified_datasets('multiwoz21', 'preprocess.py', 'reverse_da') @@ -166,9 +167,9 @@ class TemplateNLG(NLG): Returns: generated sentence """ - if isinstance(dialog_acts, dict): - # dialog acts are in the unified format - dialog_acts = reverse_da(dialog_acts) + dialog_acts = unified_format(dialog_acts) + dialog_acts = reverse_da(dialog_acts) + dialog_acts = act_dict_to_flat_tuple(dialog_acts) dialog_acts = self.noisy_dialog_acts( dialog_acts) if self.is_user else dialog_acts dialog_acts = self.sorted_dialog_act(dialog_acts) -- GitLab