def load_dataset_for_dgi(self, split):
        file_path = pjoin(self.data_path,
                          self.FILENAMES_MAP[self.graph_type][split])
        with open(file_path) as f:
            data = json.load(f)

        graph_dataset = GraphDataset.loads(data["graph_index"])
        self.dataset[split]["graph_dataset"] = graph_dataset

        desc = "Loading {}".format(os.path.basename(file_path))
        for example in tqdm(data["examples"], desc=desc):
            graph = example["graph"]
            self.dataset[split]["graph"].append(graph)
예제 #2
0
    def load_dataset_for_ap(self, split):
        file_path = pjoin(self.data_path, self.FILENAMES_MAP[self.graph_type][split])
        with open(file_path) as f:
            data = json.load(f)

        graph_dataset = GraphDataset.loads(data["graph_index"])
        self.dataset[split]["graph_dataset"] = graph_dataset

        desc = "Loading {}".format(os.path.basename(file_path))
        for example in tqdm(data["examples"], desc=desc):
            target_action = example["target_action"]
            curr_graph = example["current_graph"]
            prev_graph = example["previous_graph"]
            candidates = example["action_choices"]

            self.dataset[split]["current_graph"].append(curr_graph)
            self.dataset[split]["previous_graph"].append(prev_graph)
            self.dataset[split]["target_action"].append(target_action)
            self.dataset[split]["action_choices"].append(candidates)
    def load_dataset_for_cmd_gen(self, split):
        file_path = pjoin(self.data_path, self.FILENAMES_MAP[split])
        desc = "Loading {}".format(os.path.basename(file_path))
        print(desc)
        with open(file_path) as f:
            data = json.load(f)

        graph_dataset = GraphDataset.loads(data["graph_index"])
        self.dataset[split]["graph_dataset"] = graph_dataset

        for example in tqdm(data["examples"], desc=desc):
            observation = "{feedback} <sep> {action}".format(
                feedback=example["observation"],
                action=example["previous_action"])
            # Need to sort target commands to enable the seq2seq model to learn the ordering.
            target_commands = " <sep> ".join(
                sort_target_commands(example["target_commands"]))

            self.dataset[split]["observation_strings"].append(observation)
            self.dataset[split]["previous_triplets"].append(
                example["previous_graph_seen"])
            self.dataset[split]["target_commands"].append(target_commands)