yes-man-today
commited on
Commit
•
db36a72
1
Parent(s):
cf669b7
test
Browse files- regulatory_comments_api.py +80 -47
regulatory_comments_api.py
CHANGED
@@ -176,62 +176,95 @@ class RegCommentsAPI(datasets.GeneratorBasedBuilder):
|
|
176 |
datasets.SplitGenerator(
|
177 |
name=datasets.Split.TRAIN,
|
178 |
gen_kwargs={
|
179 |
-
"search_terms": opioid_related_terms,
|
180 |
"api_key": api_key, # Pass the API key to the generator function
|
181 |
},
|
182 |
),
|
183 |
]
|
184 |
|
185 |
-
|
186 |
-
def _generate_examples(self, search_terms, api_key):
|
187 |
# Iterate over each search term to fetch relevant dockets
|
188 |
-
|
189 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
190 |
|
191 |
-
for docket_id in
|
192 |
fetcher = RegulationsDataFetcher(docket_id, api_key) # Initialize with the API key
|
193 |
docket_data = fetcher.collect_data()
|
194 |
if len(docket_data["comments"]) != 0:
|
195 |
yield docket_id, docket_data
|
196 |
-
|
197 |
-
# Modify the get_docket_ids function to accept an API key
|
198 |
-
def get_docket_ids(search_term, api_key):
|
199 |
-
url = f"https://api.regulations.gov/v4/dockets"
|
200 |
-
params = {
|
201 |
-
'filter[searchTerm]': search_term,
|
202 |
-
'api_key': api_key
|
203 |
-
}
|
204 |
-
response = requests.get(url, params=params)
|
205 |
-
if response.status_code == 200:
|
206 |
-
data = response.json()
|
207 |
-
dockets = data['data']
|
208 |
-
docket_ids = [docket['id'] for docket in dockets]
|
209 |
-
return docket_ids
|
210 |
-
else:
|
211 |
-
return f"Error: {response.status_code}"
|
212 |
|
213 |
-
|
214 |
-
# Types of Opioids
|
215 |
-
"opioids",
|
216 |
-
"heroin",
|
217 |
-
"morphine",
|
218 |
-
"fentanyl",
|
219 |
-
"methadone",
|
220 |
-
"oxycodone",
|
221 |
-
"hydrocodone",
|
222 |
-
"codeine",
|
223 |
-
"tramadol",
|
224 |
-
"prescription opioids",
|
225 |
-
# Withdrawal Support
|
226 |
-
"lofexidine",
|
227 |
-
"buprenorphine",
|
228 |
-
"naloxone",
|
229 |
-
# Related Phrases
|
230 |
-
"opioid epidemic",
|
231 |
-
"opioid abuse",
|
232 |
-
"opioid crisis",
|
233 |
-
"opioid overdose"
|
234 |
-
"opioid tolerance",
|
235 |
-
"opioid treatment program",
|
236 |
-
"medication assisted treatment",
|
237 |
-
]
|
|
|
176 |
datasets.SplitGenerator(
|
177 |
name=datasets.Split.TRAIN,
|
178 |
gen_kwargs={
|
|
|
179 |
"api_key": api_key, # Pass the API key to the generator function
|
180 |
},
|
181 |
),
|
182 |
]
|
183 |
|
184 |
+
def _generate_examples(self, api_key):
|
|
|
185 |
# Iterate over each search term to fetch relevant dockets
|
186 |
+
dockets = ['FDA-2000-P-0565', 'FDA-1995-P-0018', 'FDA-2010-P-0338',
|
187 |
+
'FDA-2017-N-2903', 'FDA-1976-N-0517', 'CDC-2008-0002',
|
188 |
+
'DEA-2017-0006', 'DEA-2017-0004', 'DEA-2023-0028',
|
189 |
+
'DEA-2007-0060', 'FDA-2005-P-0191', 'CDC-2017-0057',
|
190 |
+
'FDA-2003-P-0115', 'FDA-2012-P-1028', 'FDA-1989-P-0003',
|
191 |
+
'FDA-2009-P-0415', 'FDA-2007-P-0352', 'FDA-2007-P-0124',
|
192 |
+
'FDA-2009-P-0459', 'FDA-2014-P-2168', 'FDA-2014-N-0233',
|
193 |
+
'FDA-2002-P-0291', 'DOD-2012-HA-0117', 'FDA-2015-P-1004',
|
194 |
+
'DEA-2016-0005', 'FDA-2002-P-0049', 'FDA-2008-P-0327',
|
195 |
+
'FDA-2022-D-1847', 'FDA-2015-P-2344', 'FDA-2009-P-0429',
|
196 |
+
'FDA-2012-P-0053', 'FDA-2009-P-0289', 'DEA-2023-0106',
|
197 |
+
'FDA-1986-P-0002', 'CMS-2019-0090', 'FDA-2018-D-1334',
|
198 |
+
'FDA-1975-N-0003', 'FDA-2019-N-5973', 'FDA-2004-P-0101',
|
199 |
+
'FDA-2023-N-0148', 'FDA-2000-P-0580', 'FDA-2007-P-0128',
|
200 |
+
'FDA-2017-N-5608', 'FDA-1994-P-0014', 'DEA-2016-0018',
|
201 |
+
'FDA-2017-P-6918', 'DOD-2013-HA-0085', 'FDA-2003-P-0270',
|
202 |
+
'FDA-2011-P-0869', 'FDA-2010-P-0593', 'FDA-2012-P-1251',
|
203 |
+
'DEA-2014-0005', 'FDA-1994-P-0003', 'FDA-2021-P-0514',
|
204 |
+
'FDA-1987-P-0026', 'FDA-2013-N-1485', 'FDA-1993-N-0363',
|
205 |
+
'FDA-2017-P-0428', 'SAMHSA-2023-0001', 'FDA-2012-P-1180',
|
206 |
+
'FDA-2019-P-5268', 'DEA-2017-0011', 'FDA-2016-P-3912',
|
207 |
+
'DOD-2015-HA-0109', 'FDA-2022-P-1863', 'FDA-2011-N-0802',
|
208 |
+
'FDA-1996-P-0154', 'FDA-2021-N-0951', 'DEA-2015-0009',
|
209 |
+
'FDA-2022-N-2393', 'FDA-2019-P-1783', 'FDA-2017-N-1094',
|
210 |
+
'CDC-2018-0085', 'FDA-2005-P-0327', 'FDA-2014-P-2058',
|
211 |
+
'DEA-2020-0031', 'FDA-2018-P-3355', 'FDA-2003-P-0183',
|
212 |
+
'FDA-2002-P-0167', 'DOD-2015-OS-0118', 'FDA-2008-P-0401',
|
213 |
+
'FDA-2013-P-1606', 'ONDCP_FRDOC_0001', 'FDA-1998-P-0018',
|
214 |
+
'FDA-2008-P-0366', 'FDA-2013-D-0045', 'FDA-2013-P-1055',
|
215 |
+
'FDA-2017-N-4515', 'FDA-1982-N-0046', 'FDA-2018-P-0673',
|
216 |
+
'FDA-2012-P-0818', 'FDA-2019-P-1643', 'FDA-2004-P-0098',
|
217 |
+
'FDA-2008-P-0127', 'FDA-2004-P-0096', 'DEA-2019-0014',
|
218 |
+
'FDA-2019-N-0299', 'FDA-1994-P-0021', 'FDA-2021-N-0275',
|
219 |
+
'CDC-2017-0043', 'SAMHSA-2016-0001', 'VA-2020-VHA-0023',
|
220 |
+
'CNCS-2021-0018', 'FDA-2005-P-0054', 'DEA-2017-0005',
|
221 |
+
'FDA-2019-P-5593', 'FDA-1997-P-0036', 'FDA-2002-P-0051',
|
222 |
+
'SAMHSA-2016-0004', 'FDA-2016-D-0785', 'FDA-2020-N-1561',
|
223 |
+
'SAMHSA-2022-0001', 'DEA-2018-0015', 'FDA-2010-P-0082',
|
224 |
+
'FDA-2023-P-2656', 'FDA-2004-P-0085', 'FDA-2007-P-0415',
|
225 |
+
'DEA-2017-0013', 'DEA-2018-0004', 'FDA-2005-P-0058',
|
226 |
+
'FDA-2002-N-0320', 'FDA-2014-P-0752', 'FDA-2002-P-0219',
|
227 |
+
'DEA-2013-0010', 'FDA-2003-N-0396', 'FDA-2005-P-0425',
|
228 |
+
'CMS-2020-0060', 'FRA-2019-0071', 'FDA-2013-N-0883',
|
229 |
+
'FDA-2009-P-0154', 'HHS-OS-2009-0007', 'CDC-2020-0001',
|
230 |
+
'FDA-2012-P-0189', 'DEA-2023-0058', 'FDA-2017-P-1911',
|
231 |
+
'DOD-2011-HA-0085', 'FDA-2017-P-6307', 'FDA-2004-P-0162',
|
232 |
+
'FDA-2001-P-0056', 'FDA-2013-P-0675', 'FDA-1993-P-0018',
|
233 |
+
'FDA-2017-P-5370', 'FDA-2012-N-0548', 'FDA-2012-N-0563',
|
234 |
+
'FDA-2009-P-0388', 'FDA-2001-P-0416', 'FDA-2005-N-0093',
|
235 |
+
'FDA-2002-P-0003', 'FDA-2016-P-1875', 'FDA-1987-P-0012',
|
236 |
+
'FDA-2004-P-0216', 'FDA-2007-P-0065', 'FDA-2015-P-0516',
|
237 |
+
'FDA-2023-N-3159', 'FDA-2008-P-0156', 'FDA-2021-P-0036',
|
238 |
+
'FDA-1995-P-0100', 'FDA-2012-P-1034', 'DEA-2018-0002',
|
239 |
+
'FDA-2015-P-1153', 'FDA-1995-P-0004', 'FDA-1985-P-0014',
|
240 |
+
'FDA-2016-P-1090', 'FDA-1977-N-0411', 'FDA-2009-P-0325',
|
241 |
+
'FDA-2005-P-0440', 'FDA-2019-P-1679', 'FDA-2011-P-0045',
|
242 |
+
'DEA-2020-0034', 'DOD-2015-HA-0062', 'FDA-2018-P-1448',
|
243 |
+
'FDA-2009-P-0446', 'FDA-2006-P-0279', 'FDA-2013-P-0995',
|
244 |
+
'CMS-2022-0191', 'FDA-2009-P-0227', 'FDA-2005-P-0009',
|
245 |
+
'USCBP-2013-0002', 'HHS-ASPE-2016-0011', 'FDA-2011-P-0302',
|
246 |
+
'FDA-2003-P-0185', 'FDA-2012-E-0152', 'FDA-1994-P-0016',
|
247 |
+
'FDA-2016-N-2648', 'CMS-2019-0111', 'FDA-2022-N-2673',
|
248 |
+
'FDA-1988-P-0026', 'FDA-1999-P-3513', 'DOT-OST-2016-0189',
|
249 |
+
'FDA-2017-P-0663', 'FDA-2003-P-0276', 'FDA-2006-P-0329',
|
250 |
+
'FDA-2016-P-4094', 'FDA-1993-P-0041', 'FDA-2005-P-0325',
|
251 |
+
'DEA-2020-0002', 'FDA-2007-E-0400', 'FDA-2002-P-0050',
|
252 |
+
'VA-2017-VHA-0004', 'FDA-2000-P-0024', 'FDA-2002-P-0528',
|
253 |
+
'FDA-2009-P-0252', 'FDA-2017-D-2497', 'CNCS-2021-0011',
|
254 |
+
'FDA-2006-P-0148', 'DEA-2008-0012', 'FDA-2018-N-3685',
|
255 |
+
'FDA-2023-P-4223', 'FDA-2014-P-1383', 'ONDCP-2020-0001',
|
256 |
+
'FDA-2008-P-0134', 'FDA-2007-P-0245', 'FDA-2013-P-1711',
|
257 |
+
'FDA-2016-P-1650', 'FDA-2019-P-1364', 'FDA-2015-P-1003',
|
258 |
+
'FDA-2007-N-0438', 'FDA-1985-P-0002', 'FDA-2007-P-0062',
|
259 |
+
'SAMHSA-2022-0002', 'FDA-2006-P-0016', 'FDA-2010-P-0012',
|
260 |
+
'FDA-2006-P-0278', 'FDA-1981-N-0248', 'CMS-2021-0167',
|
261 |
+
'FDA-2015-P-1752', 'FDA-2005-P-0055', 'FDA-2004-P-0473',
|
262 |
+
'FDA-2001-P-0191', 'FDA-1986-P-0034']
|
263 |
|
264 |
+
for docket_id in dockets:
|
265 |
fetcher = RegulationsDataFetcher(docket_id, api_key) # Initialize with the API key
|
266 |
docket_data = fetcher.collect_data()
|
267 |
if len(docket_data["comments"]) != 0:
|
268 |
yield docket_id, docket_data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
269 |
|
270 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|