biolm/utils_classification.py [332:376]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    disease_pattern = '@DISEASE$'
    gene_pattern = '@GENE$'
    fold = 1

    def get_example_from_tensor_dict(self, tensor_dict):
        """See base class."""
        return InputExample(
            tensor_dict["idx"].numpy(),
            tensor_dict["sentence"].numpy().decode("utf-8"),
            None,
            str(tensor_dict["label"].numpy()),
        )

    def get_train_examples(self, data_dir):
        """See base class."""
        return self._create_examples(self._read_tsv(os.path.join(data_dir, str(self.fold), f"train.tsv")), "train")

    def get_dev_examples(self, data_dir):
        """See base class."""
        return self._create_examples(self._read_tsv(os.path.join(data_dir, str(self.fold), f"test.tsv")), "dev")

    def get_test_examples(self, data_dir):
        """See base class."""
        return self._create_examples(self._read_tsv(os.path.join(data_dir,  str(self.fold), f"test.tsv")), "test")

    def get_labels(self):
        """See base class."""
        return ['0', '1']

    def _create_examples(self, lines, set_type):
        """Creates examples for the training and dev sets."""
        examples = []
        for (i, line) in enumerate(lines):
            if len(line) == 2:
                line = [i] + line
            if line[0] == 'index':
                continue

            guid = "%s-%s-%s" % (str(i), set_type, line[0])
            text_a = line[1]
            text_a = text_a.replace('@DISEASE$', self.disease_pattern).replace(
                '@GENE$', self.gene_pattern)
            label = line[2]
            examples.append(InputExample(guid=guid, text_a=text_a, text_b=None, label=label))
        return examples
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



biolm/utils_classification.py [382:426]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    disease_pattern = '@DISEASE$'
    gene_pattern = '@GENE$'
    fold = 1

    def get_example_from_tensor_dict(self, tensor_dict):
        """See base class."""
        return InputExample(
            tensor_dict["idx"].numpy(),
            tensor_dict["sentence"].numpy().decode("utf-8"),
            None,
            str(tensor_dict["label"].numpy()),
        )

    def get_train_examples(self, data_dir):
        """See base class."""
        return self._create_examples(self._read_tsv(os.path.join(data_dir, str(self.fold), f"train.tsv")), "train")

    def get_dev_examples(self, data_dir):
        """See base class."""
        return self._create_examples(self._read_tsv(os.path.join(data_dir,  str(self.fold), f"test.tsv")), "dev")

    def get_test_examples(self, data_dir):
        """See base class."""
        return self._create_examples(self._read_tsv(os.path.join(data_dir,  str(self.fold), f"test.tsv")), "test")

    def get_labels(self):
        """See base class."""
        return ['0', '1']

    def _create_examples(self, lines, set_type):
        """Creates examples for the training and dev sets."""
        examples = []
        for (i, line) in enumerate(lines):
            if len(line) == 2:
                line = [i] + line
            if line[0] == 'index':
                continue

            guid = "%s-%s-%s" % (str(i), set_type, line[0])
            text_a = line[1]
            text_a = text_a.replace('@DISEASE$', self.disease_pattern).replace(
                '@GENE$', self.gene_pattern)
            label = line[2]
            examples.append(InputExample(guid=guid, text_a=text_a, text_b=None, label=label))
        return examples
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



