Upload regulatory_comments_api.py
Browse files- regulatory_comments_api.py +21 -3
regulatory_comments_api.py
CHANGED
@@ -15,6 +15,7 @@
|
|
15 |
|
16 |
import requests
|
17 |
import datasets
|
|
|
18 |
|
19 |
_DESCRIPTION = """\
|
20 |
United States governmental agencies often make proposed regulations open to the public for comment.
|
@@ -118,10 +119,23 @@ class RegulationsDataFetcher:
|
|
118 |
break
|
119 |
|
120 |
return nested_data
|
|
|
|
|
|
|
|
|
|
|
121 |
|
122 |
-
class
|
123 |
VERSION = datasets.Version("1.1.0")
|
124 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
# Method to define the structure of the dataset
|
126 |
def _info(self):
|
127 |
# Defining the structure of the dataset
|
@@ -151,17 +165,21 @@ class RegComments(datasets.GeneratorBasedBuilder):
|
|
151 |
)
|
152 |
|
153 |
def _split_generators(self, dl_manager):
|
154 |
-
#
|
|
|
|
|
|
|
155 |
return [
|
156 |
datasets.SplitGenerator(
|
157 |
name=datasets.Split.TRAIN,
|
158 |
gen_kwargs={
|
159 |
"search_terms": opioid_related_terms,
|
160 |
-
"api_key":
|
161 |
},
|
162 |
),
|
163 |
]
|
164 |
|
|
|
165 |
def _generate_examples(self, search_terms, api_key):
|
166 |
# Iterate over each search term to fetch relevant dockets
|
167 |
for term in search_terms:
|
|
|
15 |
|
16 |
import requests
|
17 |
import datasets
|
18 |
+
from datasets import BuilderConfig
|
19 |
|
20 |
_DESCRIPTION = """\
|
21 |
United States governmental agencies often make proposed regulations open to the public for comment.
|
|
|
119 |
break
|
120 |
|
121 |
return nested_data
|
122 |
+
|
123 |
+
class RegCommentsAPIConfig(BuilderConfig):
|
124 |
+
def __init__(self, api_key=None, **kwargs):
|
125 |
+
super(RegCommentsAPIConfig, self).__init__(**kwargs)
|
126 |
+
self.api_key = api_key
|
127 |
|
128 |
+
class RegCommentsAPI(datasets.GeneratorBasedBuilder):
|
129 |
VERSION = datasets.Version("1.1.0")
|
130 |
|
131 |
+
BUILDER_CONFIGS = [
|
132 |
+
RegCommentsAPIConfig(
|
133 |
+
name="default",
|
134 |
+
version=datasets.Version("1.0.0"),
|
135 |
+
description="Dataset of regulatory comments",
|
136 |
+
)
|
137 |
+
]
|
138 |
+
|
139 |
# Method to define the structure of the dataset
|
140 |
def _info(self):
|
141 |
# Defining the structure of the dataset
|
|
|
165 |
)
|
166 |
|
167 |
def _split_generators(self, dl_manager):
|
168 |
+
# Retrieve the API key from the builder's config
|
169 |
+
api_key = self.config.api_key
|
170 |
+
|
171 |
+
# Define your dataset's splits. In this case, only a training split.
|
172 |
return [
|
173 |
datasets.SplitGenerator(
|
174 |
name=datasets.Split.TRAIN,
|
175 |
gen_kwargs={
|
176 |
"search_terms": opioid_related_terms,
|
177 |
+
"api_key": api_key, # Pass the API key to the generator function
|
178 |
},
|
179 |
),
|
180 |
]
|
181 |
|
182 |
+
|
183 |
def _generate_examples(self, search_terms, api_key):
|
184 |
# Iterate over each search term to fetch relevant dockets
|
185 |
for term in search_terms:
|