Datasets:

Languages:
English
License:
wzkariampuzha commited on
Commit
d8a4214
1 Parent(s): 93d7d1f

Create EpiSet4BinaryClassification.py

Browse files
Files changed (1) hide show
  1. EpiSet4BinaryClassification.py +74 -0
EpiSet4BinaryClassification.py ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2020 The TensorFlow Datasets Authors and the HuggingFace Datasets Authors.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ # Lint as: python3
17
+ """EpiClassify4GARD dataset."""
18
+
19
+
20
+ import csv
21
+ import datasets
22
+ from datasets.tasks import TextClassification
23
+
24
+
25
+ _DESCRIPTION = """\
26
+ INSERT DESCRIPTION
27
+ """
28
+ _CITATION = """\
29
+ John JN, Sid E, Zhu Q. Recurrent Neural Networks to Automatically Identify Rare Disease Epidemiologic Studies from PubMed. AMIA Jt Summits Transl Sci Proc. 2021 May 17;2021:325-334. PMID: 34457147; PMCID: PMC8378621.
30
+ """
31
+
32
+ _TRAIN_DOWNLOAD_URL = "https://raw.githubusercontent.com/ncats/epi4GARD/master/dataset/train.tsv"
33
+ _VAL_DOWNLOAD_URL = "https://raw.githubusercontent.com/ncats/epi4GARD/master/dataset/val.tsv"
34
+ _TEST_DOWNLOAD_URL = "https://raw.githubusercontent.com/ncats/epi4GARD/master/dataset/test.tsv"
35
+
36
+
37
+ class EpiClassify4GARD(datasets.GeneratorBasedBuilder):
38
+ """EpiClassify4GARD text classification dataset."""
39
+
40
+ def _info(self):
41
+ return datasets.DatasetInfo(
42
+ description=_DESCRIPTION,
43
+ features=datasets.Features(
44
+ {
45
+ "abstract": datasets.Value("string"),
46
+ "label": datasets.features.ClassLabel(names=["1 = IsEpi", "0 = IsNotEpi"]),
47
+ }
48
+ ),
49
+ homepage="https://github.com/ncats/epi4GARD/tree/master/Epi4GARD#epi4gard",
50
+ citation=_CITATION,
51
+ task_templates=[TextClassification(text_column="abstract", label_column="label")],
52
+ )
53
+
54
+ def _split_generators(self, dl_manager):
55
+ train_path = dl_manager.download_and_extract(_TRAIN_DOWNLOAD_URL)
56
+ val_path = dl_manager.download_and_extract(_VAL_DOWNLOAD_URL)
57
+ test_path = dl_manager.download_and_extract(_TEST_DOWNLOAD_URL)
58
+ return [
59
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": train_path}),
60
+ datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": val_path }),
61
+ datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": test_path}),
62
+ ]
63
+
64
+ def _generate_examples(self, filepath):
65
+ """Generate examples."""
66
+ with open(filepath, encoding="utf-8") as csv_file:
67
+ csv_reader = csv.reader(
68
+ csv_file, quotechar='"', delimiter="\t", quoting=csv.QUOTE_ALL, skipinitialspace=True
69
+ )
70
+ next(csv_reader)
71
+ for id_, row in enumerate(csv_reader):
72
+ abstract = row[0]
73
+ label = row[1]
74
+ yield id_, {"abstract": abstract, "label": int(label)}