Jason Alan Fries
commited on
Commit
·
62390ae
1
Parent(s):
9408b89
use sequence tagging formulation of dataset
Browse files
blurb.py
CHANGED
@@ -44,7 +44,6 @@ import re
|
|
44 |
import pandas
|
45 |
import datasets
|
46 |
|
47 |
-
#from .bigbiohub import kb_features
|
48 |
from .bigbiohub import BigBioConfig
|
49 |
from .bigbiohub import Tasks
|
50 |
|
@@ -165,7 +164,7 @@ _DESCRIPTION = {
|
|
165 |
|
166 |
_HOMEPAGE = "https://microsoft.github.io/BLURB/tasks.html"
|
167 |
|
168 |
-
_LICENSE = "MIXED"
|
169 |
|
170 |
|
171 |
_URLs = {
|
@@ -202,8 +201,7 @@ _BIGBIO_VERSION = "1.0.0"
|
|
202 |
|
203 |
|
204 |
class BlurbDataset(datasets.GeneratorBasedBuilder):
|
205 |
-
"""Source splits for BLURB data (train/val/test) for easy access.
|
206 |
-
"""
|
207 |
|
208 |
DEFAULT_CONFIG_NAME = "bc5chem"
|
209 |
SOURCE_VERSION = datasets.Version(_SOURCE_VERSION)
|
@@ -253,12 +251,12 @@ class BlurbDataset(datasets.GeneratorBasedBuilder):
|
|
253 |
{
|
254 |
"id": datasets.Value("string"),
|
255 |
"tokens": datasets.Sequence(datasets.Value("string")),
|
256 |
-
"word_idx": datasets.Value("int32"),
|
257 |
"type": datasets.Value("string"),
|
258 |
-
"
|
259 |
datasets.features.ClassLabel(
|
260 |
names=[
|
261 |
"O",
|
|
|
262 |
"I",
|
263 |
]
|
264 |
)
|
@@ -314,7 +312,7 @@ class BlurbDataset(datasets.GeneratorBasedBuilder):
|
|
314 |
if line.strip() == "":
|
315 |
toks, tags = zip(*tagged)
|
316 |
# transform tags
|
317 |
-
tags =
|
318 |
yield (toks, tags)
|
319 |
tagged = []
|
320 |
continue
|
@@ -341,16 +339,11 @@ class BlurbDataset(datasets.GeneratorBasedBuilder):
|
|
341 |
|
342 |
uid = 0
|
343 |
for item in self._load_iob(filepath):
|
344 |
-
if len(item) != 2:
|
345 |
-
print("ERROR", len(item), item, split)
|
346 |
-
continue
|
347 |
toks, tags = item
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
}
|
356 |
-
uid += 1
|
|
|
44 |
import pandas
|
45 |
import datasets
|
46 |
|
|
|
47 |
from .bigbiohub import BigBioConfig
|
48 |
from .bigbiohub import Tasks
|
49 |
|
|
|
164 |
|
165 |
_HOMEPAGE = "https://microsoft.github.io/BLURB/tasks.html"
|
166 |
|
167 |
+
_LICENSE = "MIXED"
|
168 |
|
169 |
|
170 |
_URLs = {
|
|
|
201 |
|
202 |
|
203 |
class BlurbDataset(datasets.GeneratorBasedBuilder):
|
204 |
+
"""Source splits for BLURB data (train/val/test) for easy access."""
|
|
|
205 |
|
206 |
DEFAULT_CONFIG_NAME = "bc5chem"
|
207 |
SOURCE_VERSION = datasets.Version(_SOURCE_VERSION)
|
|
|
251 |
{
|
252 |
"id": datasets.Value("string"),
|
253 |
"tokens": datasets.Sequence(datasets.Value("string")),
|
|
|
254 |
"type": datasets.Value("string"),
|
255 |
+
"ner_tags": datasets.Sequence(
|
256 |
datasets.features.ClassLabel(
|
257 |
names=[
|
258 |
"O",
|
259 |
+
"B",
|
260 |
"I",
|
261 |
]
|
262 |
)
|
|
|
312 |
if line.strip() == "":
|
313 |
toks, tags = zip(*tagged)
|
314 |
# transform tags
|
315 |
+
tags = tags = [t[0] for t in tags]
|
316 |
yield (toks, tags)
|
317 |
tagged = []
|
318 |
continue
|
|
|
339 |
|
340 |
uid = 0
|
341 |
for item in self._load_iob(filepath):
|
|
|
|
|
|
|
342 |
toks, tags = item
|
343 |
+
yield uid, {
|
344 |
+
"id": uid,
|
345 |
+
"tokens": toks,
|
346 |
+
"type": ner_types[self.config.name],
|
347 |
+
"ner_tags": tags,
|
348 |
+
}
|
349 |
+
uid += 1
|
|
|
|