Skip to content
Snippets Groups Projects
Commit bf8e5f0f authored by zqwerty's avatar zqwerty
Browse files

updatte TemplateNLGfor mMultiwoz to support unified format dialog acts

parent 7d5388bb
Branches
Tags
No related merge requests found
...@@ -10,7 +10,9 @@ import numpy as np ...@@ -10,7 +10,9 @@ import numpy as np
from convlab.nlg import NLG from convlab.nlg import NLG
from convlab.nlg.template.multiwoz.noise_functions import delete_random_token, random_token_permutation, spelling_noise 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.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): def lower_keys(x):
if isinstance(x, list): if isinstance(x, list):
...@@ -164,6 +166,9 @@ class TemplateNLG(NLG): ...@@ -164,6 +166,9 @@ class TemplateNLG(NLG):
Returns: Returns:
generated sentence 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 = self.noisy_dialog_acts(
dialog_acts) if self.is_user else dialog_acts dialog_acts) if self.is_user else dialog_acts
dialog_acts = self.sorted_dialog_act(dialog_acts) dialog_acts = self.sorted_dialog_act(dialog_acts)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment