Datasets:
Tasks:
Text Classification
Modalities:
Text
Sub-tasks:
multi-class-classification
Languages:
English
Size:
10K - 100K
File size: 6,232 Bytes
bdc8e75 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# coding=utf-8
"""HoC : Hallmarks of Cancer Corpus"""
import datasets
from pathlib import Path
logger = datasets.logging.get_logger(__name__)
_CITATION = """
@article{baker2015automatic,
title={Automatic semantic classification of scientific literature according to the hallmarks of cancer},
author={Baker, Simon and Silins, Ilona and Guo, Yufan and Ali, Imran and H{\"o}gberg, Johan and Stenius, Ulla and Korhonen, Anna},
journal={Bioinformatics},
volume={32},
number={3},
pages={432--440},
year={2015},
publisher={Oxford University Press}
}
@article{baker2017cancer,
title={Cancer Hallmarks Analytics Tool (CHAT): a text mining approach to organize and evaluate scientific literature on cancer},
author={Baker, Simon and Ali, Imran and Silins, Ilona and Pyysalo, Sampo and Guo, Yufan and H{\"o}gberg, Johan and Stenius, Ulla and Korhonen, Anna},
journal={Bioinformatics},
volume={33},
number={24},
pages={3973--3981},
year={2017},
publisher={Oxford University Press}
}
@article{baker2017cancer,
title={Cancer hallmark text classification using convolutional neural networks},
author={Baker, Simon and Korhonen, Anna-Leena and Pyysalo, Sampo},
year={2016}
}
@article{baker2017initializing,
title={Initializing neural networks for hierarchical multi-label text classification},
author={Baker, Simon and Korhonen, Anna},
journal={BioNLP 2017},
pages={307--315},
year={2017}
}
"""
_LICENSE = """
GNU General Public License v3.0
"""
_DESCRIPTION = """
The Hallmarks of Cancer Corpus for text classification
The Hallmarks of Cancer (HOC) Corpus consists of 1852 PubMed
publication abstracts manually annotated by experts according
to a taxonomy. The taxonomy consists of 37 classes in a
hierarchy. Zero or more class labels are assigned to each
sentence in the corpus. The labels are found under the "labels"
directory, while the tokenized text can be found under "text"
directory. The filenames are the corresponding PubMed IDs (PMID).
In addition to the HOC corpus, we also have the
[Cancer Hallmarks Analytics Tool](http://chat.lionproject.net/)
which classifes all of PubMed according to the HoC taxonomy.
"""
_HOMEPAGE = "https://github.com/sb895/Hallmarks-of-Cancer"
_URLs = {
"corpus": "https://github.com/sb895/Hallmarks-of-Cancer/archive/refs/heads/master.zip",
"split_indices": "https://microsoft.github.io/BLURB/sample_code/data_generation.tar.gz",
}
_CLASS_NAMES = [
"evading growth suppressors",
"tumor promoting inflammation",
"enabling replicative immortality",
"cellular energetics",
"resisting cell death",
"activating invasion and metastasis",
"genomic instability and mutation",
"none",
"inducing angiogenesis",
"sustaining proliferative signaling",
"avoiding immune destruction",
]
class HoC(datasets.GeneratorBasedBuilder):
"""HoC : Hallmarks of Cancer Corpus"""
BUILDER_CONFIGS = [
datasets.BuilderConfig(
name = "HoC",
version = datasets.Version("1.0.0"),
description = f"The HoC corpora",
)
]
DEFAULT_CONFIG_NAME = "HoC"
def _info(self):
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=datasets.Features(
{
"document_id": datasets.Value("string"),
"text": datasets.Value("string"),
"label": [datasets.ClassLabel(names=_CLASS_NAMES)],
},
),
supervised_keys=None,
homepage=_HOMEPAGE,
citation=_CITATION,
license=_LICENSE,
)
def _split_generators(self, dl_manager):
"""Returns SplitGenerators."""
data_dir = dl_manager.download_and_extract(_URLs)
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN,
gen_kwargs={
"corpus_path": Path(data_dir["corpus"]),
"indices_path": Path(data_dir["split_indices"]) / "data_generation/indexing/HoC/train_pmid.tsv",
},
),
datasets.SplitGenerator(
name=datasets.Split.VALIDATION,
gen_kwargs={
"corpus_path": Path(data_dir["corpus"]),
"indices_path": Path(data_dir["split_indices"]) / "data_generation/indexing/HoC/dev_pmid.tsv",
},
),
datasets.SplitGenerator(
name=datasets.Split.TEST,
gen_kwargs={
"corpus_path": Path(data_dir["corpus"]),
"indices_path": Path(data_dir["split_indices"]) / "data_generation/indexing/HoC/test_pmid.tsv",
},
),
]
def _generate_examples(self, corpus_path: Path, indices_path: Path):
indices = indices_path.read_text(encoding="utf8").strip("\n").split(",")
dataset_dir = corpus_path / "Hallmarks-of-Cancer-master"
texts_dir = dataset_dir / "text"
labels_dir = dataset_dir / "labels"
for document_index, document in enumerate(indices):
text_file = texts_dir / document
label_file = labels_dir / document
text = text_file.read_text(encoding="utf8").strip("\n")
labels = label_file.read_text(encoding="utf8").strip("\n")
sentences = text.split("\n")
labels = labels.split("<")[1:]
for example_index, example_pair in enumerate(zip(sentences, labels)):
sentence, label = example_pair
label = label.strip()
if label == "":
label = "none"
multi_labels = [m_label.strip() for m_label in label.split("AND")]
unique_multi_labels = {m_label.split("--")[0].lower().lstrip() for m_label in multi_labels if m_label != "NULL"}
unique_key = 100 * document_index + example_index
yield unique_key, {
"document_id": f"{text_file.name.split('.')[0]}_{example_index}",
"text": sentence,
"label": list(unique_multi_labels),
} |