Datasets:

Languages:
English
Multilinguality:
monolingual
Size Categories:
10K<n<100K
Language Creators:
unknown
Annotations Creators:
unknown
Source Datasets:
unknown
License:
wzkariampuzha commited on
Commit
7f5c208
1 Parent(s): cbe2744

Create EpiClassify4GARD.py

Browse files
Files changed (1) hide show
  1. EpiClassify4GARD.py +70 -0
EpiClassify4GARD.py ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
29
+ _TRAIN_DOWNLOAD_URL = "https://huggingface.co/datasets/ncats/EpiClassify4GARD/raw/main/train.tsv"
30
+ _VAL_DOWNLOAD_URL = "https://huggingface.co/datasets/ncats/EpiClassify4GARD/raw/main/validation.tsv"
31
+ _TEST_DOWNLOAD_URL = "https://huggingface.co/datasets/ncats/EpiClassify4GARD/raw/main/test.tsv"
32
+
33
+
34
+ class EpiClassify4GARD(datasets.GeneratorBasedBuilder):
35
+ """EpiClassify4GARD text classification dataset."""
36
+
37
+ def _info(self):
38
+ return datasets.DatasetInfo(
39
+ description=_DESCRIPTION,
40
+ features=datasets.Features(
41
+ {
42
+ "text": datasets.Value("string"),
43
+ "label": datasets.features.ClassLabel(names=["1 = IsEpi", "0 = IsNotEpi"]),
44
+ }
45
+ ),
46
+ homepage="https://github.com/ncats/epi4GARD/tree/master/Epi4GARD#epi4gard",
47
+ citation=_CITATION,
48
+ task_templates=[TextClassification(text_column="abstract", label_column="label")],
49
+ )
50
+
51
+ def _split_generators(self, dl_manager):
52
+ train_path = dl_manager.download_and_extract(_TRAIN_DOWNLOAD_URL)
53
+ val_path = dl_manager.download_and_extract(_VAL_DOWNLOAD_URL)
54
+ test_path = dl_manager.download_and_extract(_TEST_DOWNLOAD_URL)
55
+ return [
56
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": train_path}),
57
+ datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": val_path }),
58
+ datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": test_path}),
59
+ ]
60
+
61
+ def _generate_examples(self, filepath):
62
+ """Generate examples."""
63
+ with open(filepath, encoding="utf-8") as csv_file:
64
+ csv_reader = csv.reader(
65
+ csv_file, quotechar='"', delimiter="\t", quoting=csv.QUOTE_ALL, skipinitialspace=True
66
+ )
67
+ next(csv_reader)
68
+ for id_, row in enumerate(csv_reader):
69
+ abstract, label = row
70
+ yield id_, {"abstract": abstract, "label": int(label)}