Beispiel #1
0
 def get(self, episode_idx, entry_idx=0):
     entry = self.data[episode_idx]
     entry['id'] = self.id
     entry['episode_done'] = True
     (
         entry['text'],
         entry['labels'],
         entry['label_candidates'],
     ) = convert_to_dialogData(
         premise_raw=entry[DNLI_PREMISE_KEY],
         hypo_raw=entry[DNLI_HYPO_KEY],
         answer_raw=DNLI_LABEL_DICT[entry[DNLI_ANSWER_KEY]],
         dialog_format=self.dialog_format,
         binary_classes=self.binary_classes,
     )
     new_entry = {k: entry[k] for k in ENTRY_FIELDS if k in entry}
     return new_entry
Beispiel #2
0
    def setup_data(self, path):
        print('loading: ' + path)
        with open(path, 'r') as data_file:
            for pair_line in data_file:
                pair = json.loads(pair_line)
                if pair[ANLI_ANSWER_KEY] == '-':
                    continue

                label_raw = pair[ANLI_ANSWER_KEY]
                if label_raw in ANLI_LABEL_DICT:
                    label_raw = ANLI_LABEL_DICT[label_raw]

                question, answers, clas = convert_to_dialogData(
                    premise_raw=pair[ANLI_PREMISE_KEY],
                    hypo_raw=pair[ANLI_HYPO_KEY],
                    answer_raw=label_raw,
                    dialog_format=self.dialog_format,
                    binary_classes=self.binary_classes,
                )

                yield (question, answers, None, clas), True