Update inspec.py
Browse files
inspec.py
CHANGED
@@ -1,20 +1,14 @@
|
|
1 |
-
import csv
|
2 |
import json
|
3 |
-
import os
|
4 |
|
5 |
import datasets
|
6 |
-
from typing import List, Any
|
7 |
|
8 |
# _SPLIT = ['train', 'test', 'valid']
|
9 |
_CITATION = """\
|
10 |
-
author: amardeep
|
11 |
"""
|
12 |
|
13 |
-
|
14 |
_DESCRIPTION = """\
|
15 |
-
This new dataset is designed to solve kp NLP task and is crafted with a lot of care.
|
16 |
-
"""
|
17 |
|
|
|
18 |
|
19 |
_HOMEPAGE = ""
|
20 |
|
@@ -34,37 +28,36 @@ _URLS = {
|
|
34 |
class TestLDKP(datasets.GeneratorBasedBuilder):
|
35 |
"""TODO: Short description of my dataset."""
|
36 |
|
37 |
-
VERSION = datasets.Version("
|
38 |
|
39 |
BUILDER_CONFIGS = [
|
40 |
-
datasets.BuilderConfig(name="extraction", version=VERSION,
|
41 |
-
|
42 |
-
datasets.BuilderConfig(name="
|
43 |
-
|
44 |
-
datasets.BuilderConfig(name="
|
45 |
-
|
46 |
]
|
47 |
|
48 |
-
DEFAULT_CONFIG_NAME = "extraction"
|
49 |
|
50 |
def _info(self):
|
51 |
-
if self.config.name == "extraction"
|
52 |
features = datasets.Features(
|
53 |
{
|
54 |
"id": datasets.Value("int64"),
|
55 |
"document": datasets.features.Sequence(datasets.Value("string")),
|
56 |
"doc_bio_tags": datasets.features.Sequence(datasets.Value("string"))
|
57 |
-
|
58 |
}
|
59 |
)
|
60 |
-
elif self.config.name == "generation"
|
61 |
features = datasets.Features(
|
62 |
{
|
63 |
"id": datasets.Value("int64"),
|
64 |
"document": datasets.features.Sequence(datasets.Value("string")),
|
65 |
"extractive_keyphrases": datasets.features.Sequence(datasets.Value("string")),
|
66 |
"abstractive_keyphrases": datasets.features.Sequence(datasets.Value("string"))
|
67 |
-
|
68 |
}
|
69 |
)
|
70 |
else:
|
@@ -78,18 +71,17 @@ class TestLDKP(datasets.GeneratorBasedBuilder):
|
|
78 |
"other_metadata": datasets.features.Sequence(
|
79 |
{
|
80 |
"text": datasets.features.Sequence(datasets.Value("string")),
|
81 |
-
"bio_tags":datasets.features.Sequence(datasets.Value("string"))
|
82 |
}
|
83 |
)
|
84 |
|
85 |
-
|
86 |
}
|
87 |
)
|
88 |
return datasets.DatasetInfo(
|
89 |
# This is the description that will appear on the datasets page.
|
90 |
description=_DESCRIPTION,
|
91 |
# This defines the different columns of the dataset and their types
|
92 |
-
features=features,
|
93 |
homepage=_HOMEPAGE,
|
94 |
# License for the dataset if available
|
95 |
license=_LICENSE,
|
@@ -98,7 +90,7 @@ class TestLDKP(datasets.GeneratorBasedBuilder):
|
|
98 |
)
|
99 |
|
100 |
def _split_generators(self, dl_manager):
|
101 |
-
|
102 |
data_dir = dl_manager.download_and_extract(_URLS)
|
103 |
return [
|
104 |
datasets.SplitGenerator(
|
@@ -139,20 +131,7 @@ class TestLDKP(datasets.GeneratorBasedBuilder):
|
|
139 |
"document": data["document"],
|
140 |
"doc_bio_tags": data["doc_bio_tags"]
|
141 |
}
|
142 |
-
elif self.config.name == "
|
143 |
-
yield key, {
|
144 |
-
"id": data['paper_id'],
|
145 |
-
"document": data["document"]+data["other_metadata"]['text'],
|
146 |
-
"doc_bio_tags": data["document_tags"] + data["other_metadata"]['bio_tags']
|
147 |
-
}
|
148 |
-
elif self.config.name == "ldkp_generation":
|
149 |
-
yield key, {
|
150 |
-
"id": data['paper_id'],
|
151 |
-
"document": data["document"]+data["other_metadata"]['text'],
|
152 |
-
"extractive_keyphrases": data["extractive_keyphrases"],
|
153 |
-
"abstractive_keyphrases": data["abstractive_keyphrases"]
|
154 |
-
}
|
155 |
-
elif self.config.name == "generation":
|
156 |
yield key, {
|
157 |
"id": data['paper_id'],
|
158 |
"document": data["document"],
|
|
|
|
|
1 |
import json
|
|
|
2 |
|
3 |
import datasets
|
|
|
4 |
|
5 |
# _SPLIT = ['train', 'test', 'valid']
|
6 |
_CITATION = """\
|
|
|
7 |
"""
|
8 |
|
|
|
9 |
_DESCRIPTION = """\
|
|
|
|
|
10 |
|
11 |
+
"""
|
12 |
|
13 |
_HOMEPAGE = ""
|
14 |
|
|
|
28 |
class TestLDKP(datasets.GeneratorBasedBuilder):
|
29 |
"""TODO: Short description of my dataset."""
|
30 |
|
31 |
+
VERSION = datasets.Version("0.1")
|
32 |
|
33 |
BUILDER_CONFIGS = [
|
34 |
+
datasets.BuilderConfig(name="extraction", version=VERSION,
|
35 |
+
description="This part of my dataset covers extraction"),
|
36 |
+
datasets.BuilderConfig(name="generation", version=VERSION,
|
37 |
+
description="This part of my dataset covers generation"),
|
38 |
+
datasets.BuilderConfig(name="raw", version=VERSION, description="This part of my dataset covers the raw data"),
|
|
|
39 |
]
|
40 |
|
41 |
+
DEFAULT_CONFIG_NAME = "extraction"
|
42 |
|
43 |
def _info(self):
|
44 |
+
if self.config.name == "extraction": # This is the name of the configuration selected in BUILDER_CONFIGS above
|
45 |
features = datasets.Features(
|
46 |
{
|
47 |
"id": datasets.Value("int64"),
|
48 |
"document": datasets.features.Sequence(datasets.Value("string")),
|
49 |
"doc_bio_tags": datasets.features.Sequence(datasets.Value("string"))
|
50 |
+
|
51 |
}
|
52 |
)
|
53 |
+
elif self.config.name == "generation":
|
54 |
features = datasets.Features(
|
55 |
{
|
56 |
"id": datasets.Value("int64"),
|
57 |
"document": datasets.features.Sequence(datasets.Value("string")),
|
58 |
"extractive_keyphrases": datasets.features.Sequence(datasets.Value("string")),
|
59 |
"abstractive_keyphrases": datasets.features.Sequence(datasets.Value("string"))
|
60 |
+
|
61 |
}
|
62 |
)
|
63 |
else:
|
|
|
71 |
"other_metadata": datasets.features.Sequence(
|
72 |
{
|
73 |
"text": datasets.features.Sequence(datasets.Value("string")),
|
74 |
+
"bio_tags": datasets.features.Sequence(datasets.Value("string"))
|
75 |
}
|
76 |
)
|
77 |
|
|
|
78 |
}
|
79 |
)
|
80 |
return datasets.DatasetInfo(
|
81 |
# This is the description that will appear on the datasets page.
|
82 |
description=_DESCRIPTION,
|
83 |
# This defines the different columns of the dataset and their types
|
84 |
+
features=features,
|
85 |
homepage=_HOMEPAGE,
|
86 |
# License for the dataset if available
|
87 |
license=_LICENSE,
|
|
|
90 |
)
|
91 |
|
92 |
def _split_generators(self, dl_manager):
|
93 |
+
|
94 |
data_dir = dl_manager.download_and_extract(_URLS)
|
95 |
return [
|
96 |
datasets.SplitGenerator(
|
|
|
131 |
"document": data["document"],
|
132 |
"doc_bio_tags": data["doc_bio_tags"]
|
133 |
}
|
134 |
+
elif self.config.name == "generation":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
yield key, {
|
136 |
"id": data['paper_id'],
|
137 |
"document": data["document"],
|