gabrielaltay
commited on
Commit
•
cfc0d0a
1
Parent(s):
5c09981
Upload bigbiohub.py
Browse files- bigbiohub.py +67 -0
bigbiohub.py
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
from collections import defaultdict
|
3 |
+
from enum import Enum
|
4 |
+
from types import SimpleNamespace
|
5 |
+
|
6 |
+
from dataclasses import dataclass
|
7 |
+
import datasets
|
8 |
+
|
9 |
+
from licenses import License
|
10 |
+
from licenses import Licenses
|
11 |
+
|
12 |
+
|
13 |
+
BigBioValues = SimpleNamespace(NULL="<BB_NULL_STR>")
|
14 |
+
|
15 |
+
|
16 |
+
@dataclass
|
17 |
+
class BigBioConfig(datasets.BuilderConfig):
|
18 |
+
"""BuilderConfig for BigBio."""
|
19 |
+
|
20 |
+
name: str = None
|
21 |
+
version: datasets.Version = None
|
22 |
+
description: str = None
|
23 |
+
schema: str = None
|
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"))
|
32 |
+
langs_dict = {k.replace("-", "_").upper(): v for k, v in langs_json.items()}
|
33 |
+
Lang = Enum("Lang", langs_dict)
|
34 |
+
|
35 |
+
|
36 |
+
METADATA: dict = {
|
37 |
+
"_LOCAL": bool,
|
38 |
+
"_LANGUAGES": Lang,
|
39 |
+
"_PUBMED": bool,
|
40 |
+
"_LICENSE": License,
|
41 |
+
"_DISPLAYNAME": str,
|
42 |
+
}
|
43 |
+
|
44 |
+
|
45 |
+
class Tasks(Enum):
|
46 |
+
NAMED_ENTITY_RECOGNITION = "NER"
|
47 |
+
NAMED_ENTITY_DISAMBIGUATION = "NED"
|
48 |
+
EVENT_EXTRACTION = "EE"
|
49 |
+
RELATION_EXTRACTION = "RE"
|
50 |
+
COREFERENCE_RESOLUTION = "COREF"
|
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"),
|
63 |
+
"premise": datasets.Value("string"),
|
64 |
+
"hypothesis": datasets.Value("string"),
|
65 |
+
"label": datasets.Value("string"),
|
66 |
+
}
|
67 |
+
)
|