Skip to content
Snippets Groups Projects
Unverified Commit b71aea12 authored by zhuqi's avatar zhuqi Committed by GitHub
Browse files

Merge pull request #69 from ConvLab/clean_code

updatte TemplateNLGfor mMultiwoz to support unified format dialog acts
parents f38ba33c bf8e5f0f
Branches
No related tags found
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