Matías Rojas commited on
Commit
1f5cc7e
1 Parent(s): 834a470
Files changed (6) hide show
  1. .DS_Store +0 -0
  2. data/.DS_Store +0 -0
  3. data/dev.conll +0 -0
  4. data/test.conll +0 -0
  5. data/train.conll +0 -0
  6. shared-task.py +113 -0
.DS_Store ADDED
Binary file (6.15 kB). View file
 
data/.DS_Store ADDED
Binary file (6.15 kB). View file
 
data/dev.conll ADDED
The diff for this file is too large to render. See raw diff
 
data/test.conll ADDED
The diff for this file is too large to render. See raw diff
 
data/train.conll ADDED
The diff for this file is too large to render. See raw diff
 
shared-task.py ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import datasets
2
+
3
+
4
+ logger = datasets.logging.get_logger(__name__)
5
+
6
+
7
+ _CITATION = """\
8
+
9
+ """
10
+
11
+ _DESCRIPTION = """\
12
+
13
+
14
+ """
15
+
16
+ _URL = "https://huggingface.co/datasets/mrojas/finding/resolve/main/data/"
17
+ _TRAINING_FILE = "train.conll"
18
+ _DEV_FILE = "dev.conll"
19
+ _TEST_FILE = "test.conll"
20
+
21
+
22
+ class FindingConfig(datasets.BuilderConfig):
23
+ """BuilderConfig for Shared Task"""
24
+
25
+ def __init__(self, **kwargs):
26
+ """BuilderConfig for Shared Task.
27
+ Args:
28
+ **kwargs: keyword arguments forwarded to super.
29
+ """
30
+ super(SharedConfig, self).__init__(**kwargs)
31
+
32
+
33
+ class Shared(datasets.GeneratorBasedBuilder):
34
+ """Shared dataset."""
35
+
36
+ BUILDER_CONFIGS = [
37
+ SharedConfig(name="shared", version=datasets.Version("1.0.0"), description="Shared dataset"),
38
+ ]
39
+
40
+ def _info(self):
41
+ return datasets.DatasetInfo(
42
+ description=_DESCRIPTION,
43
+ features=datasets.Features(
44
+ {
45
+ "tokens": datasets.Sequence(datasets.Value("string")),
46
+ "ner_tags": datasets.Sequence(
47
+ datasets.features.ClassLabel(
48
+ names=[
49
+ "B-EXPLORATION",
50
+ "I-EXPLORATION",
51
+ "B-PRESENT_ILLNESS",
52
+ "I-PRESENT_ILLNESS",
53
+ "B-TREATMENT",
54
+ "I-TREATMENT",
55
+ "B-EVOLUTION",
56
+ "I-EVOLUTION",
57
+ "B-PAST_MEDICAL_HISTORY",
58
+ "I-PAST_MEDICAL_HISTORY",
59
+ "B-DERIVED_FROM/TO",
60
+ "I-DERIVED_FROM/TO",
61
+ "B-FAMILY_HISTORY",
62
+ "I-FAMILY_HISTORY",
63
+ ]
64
+ )
65
+ ),
66
+ }
67
+ ),
68
+ supervised_keys=None,
69
+ homepage="",
70
+ citation=_CITATION,
71
+ )
72
+
73
+ def _split_generators(self, dl_manager):
74
+ """Returns SplitGenerators."""
75
+ urls_to_download = {
76
+ "train": f"{_URL}{_TRAINING_FILE}",
77
+ "dev": f"{_URL}{_DEV_FILE}",
78
+ "test": f"{_URL}{_TEST_FILE}",
79
+ }
80
+ downloaded_files = dl_manager.download_and_extract(urls_to_download)
81
+
82
+ return [
83
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
84
+ datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["dev"]}),
85
+ datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files["test"]}),
86
+ ]
87
+
88
+ def _generate_examples(self, filepath):
89
+ logger.info("⏳ Generating examples from = %s", filepath)
90
+ with open(filepath, encoding="utf-8") as f:
91
+ id_ = 0
92
+ tokens = []
93
+ ner_tags = []
94
+ for line in f:
95
+ if line == "" or line == "\n":
96
+ if tokens:
97
+ yield id_, {
98
+ "tokens": tokens,
99
+ "ner_tags": ner_tags,
100
+ }
101
+ id_ += 1
102
+ tokens = []
103
+ ner_tags = []
104
+ else:
105
+ # conll2003 tokens are space separated
106
+ splits = line.split(" ")
107
+ tokens.append(splits[0])
108
+ ner_tags.append(splits[1].rstrip())
109
+ # last example
110
+ yield id_, {
111
+ "tokens": tokens,
112
+ "ner_tags": ner_tags,
113
+ }