Datasets:

Modalities:
Text
Languages:
English
Libraries:
Datasets
License:
gabrielaltay commited on
Commit
dff8822
1 Parent(s): cfc0d0a

Upload bigbiohub.py

Browse files
Files changed (1) hide show
  1. bigbiohub.py +144 -2
bigbiohub.py CHANGED
@@ -24,8 +24,6 @@ class BigBioConfig(datasets.BuilderConfig):
24
  subset_id: str = None
25
 
26
 
27
-
28
-
29
  # shamelessly compied from:
30
  # https://github.com/huggingface/datasets/blob/master/src/datasets/utils/metadata.py
31
  langs_json = json.load(open("languages.json", "r"))
@@ -51,12 +49,38 @@ class Tasks(Enum):
51
  QUESTION_ANSWERING = "QA"
52
  TEXTUAL_ENTAILMENT = "TE"
53
  SEMANTIC_SIMILARITY = "STS"
 
54
  PARAPHRASING = "PARA"
55
  TRANSLATION = "TRANSL"
56
  SUMMARIZATION = "SUM"
57
  TEXT_CLASSIFICATION = "TXTCLASS"
58
 
59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  entailment_features = datasets.Features(
61
  {
62
  "id": datasets.Value("string"),
@@ -65,3 +89,121 @@ entailment_features = datasets.Features(
65
  "label": datasets.Value("string"),
66
  }
67
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  subset_id: str = None
25
 
26
 
 
 
27
  # shamelessly compied from:
28
  # https://github.com/huggingface/datasets/blob/master/src/datasets/utils/metadata.py
29
  langs_json = json.load(open("languages.json", "r"))
 
49
  QUESTION_ANSWERING = "QA"
50
  TEXTUAL_ENTAILMENT = "TE"
51
  SEMANTIC_SIMILARITY = "STS"
52
+ TEXT_PAIRS_CLASSIFICATION = "TXT2CLASS"
53
  PARAPHRASING = "PARA"
54
  TRANSLATION = "TRANSL"
55
  SUMMARIZATION = "SUM"
56
  TEXT_CLASSIFICATION = "TXTCLASS"
57
 
58
 
59
+ TASK_TO_SCHEMA = {
60
+ Tasks.NAMED_ENTITY_RECOGNITION: "KB",
61
+ Tasks.NAMED_ENTITY_DISAMBIGUATION: "KB",
62
+ Tasks.EVENT_EXTRACTION: "KB",
63
+ Tasks.RELATION_EXTRACTION: "KB",
64
+ Tasks.COREFERENCE_RESOLUTION: "KB",
65
+ Tasks.QUESTION_ANSWERING: "QA",
66
+ Tasks.TEXTUAL_ENTAILMENT: "TE",
67
+ Tasks.SEMANTIC_SIMILARITY: "PAIRS",
68
+ Tasks.TEXT_PAIRS_CLASSIFICATION: "PAIRS",
69
+ Tasks.PARAPHRASING: "T2T",
70
+ Tasks.TRANSLATION: "T2T",
71
+ Tasks.SUMMARIZATION: "T2T",
72
+ Tasks.TEXT_CLASSIFICATION: "TEXT",
73
+ }
74
+
75
+ SCHEMA_TO_TASKS = defaultdict(set)
76
+ for task, schema in TASK_TO_SCHEMA.items():
77
+ SCHEMA_TO_TASKS[schema].add(task)
78
+ SCHEMA_TO_TASKS = dict(SCHEMA_TO_TASKS)
79
+
80
+ VALID_TASKS = set(TASK_TO_SCHEMA.keys())
81
+ VALID_SCHEMAS = set(TASK_TO_SCHEMA.values())
82
+
83
+
84
  entailment_features = datasets.Features(
85
  {
86
  "id": datasets.Value("string"),
 
89
  "label": datasets.Value("string"),
90
  }
91
  )
92
+
93
+ pairs_features = datasets.Features(
94
+ {
95
+ "id": datasets.Value("string"),
96
+ "document_id": datasets.Value("string"),
97
+ "text_1": datasets.Value("string"),
98
+ "text_2": datasets.Value("string"),
99
+ "label": datasets.Value("string"),
100
+ }
101
+ )
102
+
103
+ qa_features = datasets.Features(
104
+ {
105
+ "id": datasets.Value("string"),
106
+ "question_id": datasets.Value("string"),
107
+ "document_id": datasets.Value("string"),
108
+ "question": datasets.Value("string"),
109
+ "type": datasets.Value("string"),
110
+ "choices": [datasets.Value("string")],
111
+ "context": datasets.Value("string"),
112
+ "answer": datasets.Sequence(datasets.Value("string")),
113
+ }
114
+ )
115
+
116
+ text_features = datasets.Features(
117
+ {
118
+ "id": datasets.Value("string"),
119
+ "document_id": datasets.Value("string"),
120
+ "text": datasets.Value("string"),
121
+ "labels": [datasets.Value("string")],
122
+ }
123
+ )
124
+
125
+ text2text_features = datasets.Features(
126
+ {
127
+ "id": datasets.Value("string"),
128
+ "document_id": datasets.Value("string"),
129
+ "text_1": datasets.Value("string"),
130
+ "text_2": datasets.Value("string"),
131
+ "text_1_name": datasets.Value("string"),
132
+ "text_2_name": datasets.Value("string"),
133
+ }
134
+ )
135
+
136
+ kb_features = datasets.Features(
137
+ {
138
+ "id": datasets.Value("string"),
139
+ "document_id": datasets.Value("string"),
140
+ "passages": [
141
+ {
142
+ "id": datasets.Value("string"),
143
+ "type": datasets.Value("string"),
144
+ "text": datasets.Sequence(datasets.Value("string")),
145
+ "offsets": datasets.Sequence([datasets.Value("int32")]),
146
+ }
147
+ ],
148
+ "entities": [
149
+ {
150
+ "id": datasets.Value("string"),
151
+ "type": datasets.Value("string"),
152
+ "text": datasets.Sequence(datasets.Value("string")),
153
+ "offsets": datasets.Sequence([datasets.Value("int32")]),
154
+ "normalized": [
155
+ {
156
+ "db_name": datasets.Value("string"),
157
+ "db_id": datasets.Value("string"),
158
+ }
159
+ ],
160
+ }
161
+ ],
162
+ "events": [
163
+ {
164
+ "id": datasets.Value("string"),
165
+ "type": datasets.Value("string"),
166
+ # refers to the text_bound_annotation of the trigger
167
+ "trigger": {
168
+ "text": datasets.Sequence(datasets.Value("string")),
169
+ "offsets": datasets.Sequence([datasets.Value("int32")]),
170
+ },
171
+ "arguments": [
172
+ {
173
+ "role": datasets.Value("string"),
174
+ "ref_id": datasets.Value("string"),
175
+ }
176
+ ],
177
+ }
178
+ ],
179
+ "coreferences": [
180
+ {
181
+ "id": datasets.Value("string"),
182
+ "entity_ids": datasets.Sequence(datasets.Value("string")),
183
+ }
184
+ ],
185
+ "relations": [
186
+ {
187
+ "id": datasets.Value("string"),
188
+ "type": datasets.Value("string"),
189
+ "arg1_id": datasets.Value("string"),
190
+ "arg2_id": datasets.Value("string"),
191
+ "normalized": [
192
+ {
193
+ "db_name": datasets.Value("string"),
194
+ "db_id": datasets.Value("string"),
195
+ }
196
+ ],
197
+ }
198
+ ],
199
+ }
200
+ )
201
+
202
+ SCHEMA_TO_FEATURES = {
203
+ "KB": kb_features,
204
+ "QA": qa_features,
205
+ "TE": entailment_features,
206
+ "T2T": text2text_features,
207
+ "TEXT": text_features,
208
+ "PAIRS": pairs_features,
209
+ }