From bf8e5f0f55c40d7c56a64d1803e04b3fecc97bb0 Mon Sep 17 00:00:00 2001 From: zqwerty <zhuq96@hotmail.com> Date: Wed, 29 Jun 2022 16:33:37 +0800 Subject: [PATCH] updatte TemplateNLGfor mMultiwoz to support unified format dialog acts --- convlab/nlg/template/multiwoz/nlg.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/convlab/nlg/template/multiwoz/nlg.py b/convlab/nlg/template/multiwoz/nlg.py index c570408e..c72c752b 100755 --- a/convlab/nlg/template/multiwoz/nlg.py +++ b/convlab/nlg/template/multiwoz/nlg.py @@ -10,7 +10,9 @@ import numpy as np 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 +reverse_da = relative_import_module_from_unified_datasets('multiwoz21', 'preprocess.py', 'reverse_da') def lower_keys(x): if isinstance(x, list): @@ -164,6 +166,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 = self.noisy_dialog_acts( dialog_acts) if self.is_user else dialog_acts dialog_acts = self.sorted_dialog_act(dialog_acts) -- GitLab