matirojasg commited on
Commit
e4f94af
1 Parent(s): 7e3f831

disease files added

Browse files
Files changed (4) hide show
  1. dev.conll +0 -0
  2. disease.py +95 -0
  3. test.conll +0 -0
  4. train.conll +0 -0
dev.conll ADDED
The diff for this file is too large to render. See raw diff
 
disease.py ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import datasets
2
+
3
+
4
+ logger = datasets.logging.get_logger(__name__)
5
+
6
+
7
+ _LICENSE = "Creative Commons Attribution 4.0 International"
8
+
9
+ _VERSION = "1.1.0"
10
+
11
+ _URL = "https://huggingface.co/datasets/mrojas/disease/resolve/main/"
12
+ _TRAINING_FILE = "train.conll"
13
+ _DEV_FILE = "dev.conll"
14
+ _TEST_FILE = "test.conll"
15
+
16
+ class DiseaseConfig(datasets.BuilderConfig):
17
+ """BuilderConfig for Disease dataset."""
18
+
19
+ def __init__(self, **kwargs):
20
+ super(DiseaseConfig, self).__init__(**kwargs)
21
+
22
+
23
+ class Disease(datasets.GeneratorBasedBuilder):
24
+ """Disease dataset."""
25
+
26
+ BUILDER_CONFIGS = [
27
+ DiseaseConfig(
28
+ name="Disease",
29
+ version=datasets.Version(_VERSION),
30
+ description="Disease dataset"),
31
+ ]
32
+
33
+ def _info(self):
34
+ return datasets.DatasetInfo(
35
+ features=datasets.Features(
36
+ {
37
+ "id": datasets.Value("string"),
38
+ "tokens": datasets.Sequence(datasets.Value("string")),
39
+ "ner_tags": datasets.Sequence(
40
+ datasets.features.ClassLabel(
41
+ names=[
42
+ "O",
43
+ "B-Disease",
44
+ "I-Disease",
45
+ ]
46
+ )
47
+ ),
48
+ }
49
+ ),
50
+ supervised_keys=None,
51
+ )
52
+
53
+ def _split_generators(self, dl_manager):
54
+ """Returns SplitGenerators."""
55
+ urls_to_download = {
56
+ "train": f"{_URL}{_TRAINING_FILE}",
57
+ "dev": f"{_URL}{_DEV_FILE}",
58
+ "test": f"{_URL}{_TEST_FILE}",
59
+ }
60
+ downloaded_files = dl_manager.download_and_extract(urls_to_download)
61
+
62
+ return [
63
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
64
+ datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["dev"]}),
65
+ datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files["test"]}),
66
+ ]
67
+
68
+ def _generate_examples(self, filepath):
69
+ logger.info("⏳ Generating examples from = %s", filepath)
70
+ with open(filepath, encoding="utf-8") as f:
71
+ guid = 0
72
+ tokens = []
73
+ pos_tags = []
74
+ ner_tags = []
75
+ for line in f:
76
+ if line == "\n":
77
+ if tokens:
78
+ yield guid, {
79
+ "id": str(guid),
80
+ "tokens": tokens,
81
+ "ner_tags": ner_tags,
82
+ }
83
+ guid += 1
84
+ tokens = []
85
+ ner_tags = []
86
+ else:
87
+ splits = line.split(" ")
88
+ tokens.append(splits[0])
89
+ ner_tags.append(splits[-1].rstrip())
90
+ # last example
91
+ yield guid, {
92
+ "id": str(guid),
93
+ "tokens": tokens,
94
+ "ner_tags": ner_tags,
95
+ }
test.conll ADDED
The diff for this file is too large to render. See raw diff
 
train.conll ADDED
The diff for this file is too large to render. See raw diff