Datasets:

nguha commited on
Commit
bd2366b
Β·
1 Parent(s): c8460c9

Updating statutes split name

Browse files
Files changed (2) hide show
  1. demo.ipynb +371 -0
  2. housing_qa.py +1 -1
demo.ipynb ADDED
@@ -0,0 +1,371 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "id": "3c6f4757-0572-48ec-8159-206bbf2e08fd",
7
+ "metadata": {},
8
+ "outputs": [
9
+ {
10
+ "name": "stderr",
11
+ "output_type": "stream",
12
+ "text": [
13
+ "/Users/neelguha/miniconda3/lib/python3.11/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
14
+ " from .autonotebook import tqdm as notebook_tqdm\n"
15
+ ]
16
+ }
17
+ ],
18
+ "source": [
19
+ "from datasets import load_dataset"
20
+ ]
21
+ },
22
+ {
23
+ "cell_type": "markdown",
24
+ "id": "27e4d6d8-b201-482b-9b0a-688e1a21c9c0",
25
+ "metadata": {},
26
+ "source": [
27
+ "# Knowledge questions"
28
+ ]
29
+ },
30
+ {
31
+ "cell_type": "code",
32
+ "execution_count": 7,
33
+ "id": "2cb75e7c-b7eb-4601-85f3-cc27c1f5ff94",
34
+ "metadata": {},
35
+ "outputs": [
36
+ {
37
+ "data": {
38
+ "text/html": [
39
+ "<div>\n",
40
+ "<style scoped>\n",
41
+ " .dataframe tbody tr th:only-of-type {\n",
42
+ " vertical-align: middle;\n",
43
+ " }\n",
44
+ "\n",
45
+ " .dataframe tbody tr th {\n",
46
+ " vertical-align: top;\n",
47
+ " }\n",
48
+ "\n",
49
+ " .dataframe thead th {\n",
50
+ " text-align: right;\n",
51
+ " }\n",
52
+ "</style>\n",
53
+ "<table border=\"1\" class=\"dataframe\">\n",
54
+ " <thead>\n",
55
+ " <tr style=\"text-align: right;\">\n",
56
+ " <th></th>\n",
57
+ " <th>idx</th>\n",
58
+ " <th>state</th>\n",
59
+ " <th>question</th>\n",
60
+ " <th>answer</th>\n",
61
+ " <th>question_group</th>\n",
62
+ " <th>statutes</th>\n",
63
+ " <th>original_question</th>\n",
64
+ " <th>caveats</th>\n",
65
+ " </tr>\n",
66
+ " </thead>\n",
67
+ " <tbody>\n",
68
+ " <tr>\n",
69
+ " <th>0</th>\n",
70
+ " <td>0</td>\n",
71
+ " <td>Alabama</td>\n",
72
+ " <td>Is there a state/territory law regulating resi...</td>\n",
73
+ " <td>Yes</td>\n",
74
+ " <td>69</td>\n",
75
+ " <td>{'citation': ['ALA. CODE Β§ 35-9A-141(11)'], 'e...</td>\n",
76
+ " <td>Is there a state/territory law regulating resi...</td>\n",
77
+ " <td>[[]]</td>\n",
78
+ " </tr>\n",
79
+ " <tr>\n",
80
+ " <th>1</th>\n",
81
+ " <td>1</td>\n",
82
+ " <td>Alaska</td>\n",
83
+ " <td>Is there a state/territory law regulating resi...</td>\n",
84
+ " <td>Yes</td>\n",
85
+ " <td>69</td>\n",
86
+ " <td>{'citation': ['ALASKA STAT. Β§ 09.45.100(A)'], ...</td>\n",
87
+ " <td>Is there a state/territory law regulating resi...</td>\n",
88
+ " <td>[[]]</td>\n",
89
+ " </tr>\n",
90
+ " <tr>\n",
91
+ " <th>2</th>\n",
92
+ " <td>2</td>\n",
93
+ " <td>American Samoa</td>\n",
94
+ " <td>Is there a state/territory law regulating resi...</td>\n",
95
+ " <td>Yes</td>\n",
96
+ " <td>69</td>\n",
97
+ " <td>{'citation': ['AM. SAM. CODE ANN. Β§ 43.1405'],...</td>\n",
98
+ " <td>Is there a state/territory law regulating resi...</td>\n",
99
+ " <td>[[]]</td>\n",
100
+ " </tr>\n",
101
+ " <tr>\n",
102
+ " <th>3</th>\n",
103
+ " <td>3</td>\n",
104
+ " <td>Arizona</td>\n",
105
+ " <td>Is there a state/territory law regulating resi...</td>\n",
106
+ " <td>Yes</td>\n",
107
+ " <td>69</td>\n",
108
+ " <td>{'citation': ['ARIZONA STAT. Β§ 33-1307'], 'exc...</td>\n",
109
+ " <td>Is there a state/territory law regulating resi...</td>\n",
110
+ " <td>[[]]</td>\n",
111
+ " </tr>\n",
112
+ " <tr>\n",
113
+ " <th>4</th>\n",
114
+ " <td>4</td>\n",
115
+ " <td>Arkansas</td>\n",
116
+ " <td>Is there a state/territory law regulating resi...</td>\n",
117
+ " <td>Yes</td>\n",
118
+ " <td>69</td>\n",
119
+ " <td>{'citation': ['ARK. CODE Β§ 18-17-201'], 'excer...</td>\n",
120
+ " <td>Is there a state/territory law regulating resi...</td>\n",
121
+ " <td>[[]]</td>\n",
122
+ " </tr>\n",
123
+ " </tbody>\n",
124
+ "</table>\n",
125
+ "</div>"
126
+ ],
127
+ "text/plain": [
128
+ " idx state question \\\n",
129
+ "0 0 Alabama Is there a state/territory law regulating resi... \n",
130
+ "1 1 Alaska Is there a state/territory law regulating resi... \n",
131
+ "2 2 American Samoa Is there a state/territory law regulating resi... \n",
132
+ "3 3 Arizona Is there a state/territory law regulating resi... \n",
133
+ "4 4 Arkansas Is there a state/territory law regulating resi... \n",
134
+ "\n",
135
+ " answer question_group statutes \\\n",
136
+ "0 Yes 69 {'citation': ['ALA. CODE Β§ 35-9A-141(11)'], 'e... \n",
137
+ "1 Yes 69 {'citation': ['ALASKA STAT. Β§ 09.45.100(A)'], ... \n",
138
+ "2 Yes 69 {'citation': ['AM. SAM. CODE ANN. Β§ 43.1405'],... \n",
139
+ "3 Yes 69 {'citation': ['ARIZONA STAT. Β§ 33-1307'], 'exc... \n",
140
+ "4 Yes 69 {'citation': ['ARK. CODE Β§ 18-17-201'], 'excer... \n",
141
+ "\n",
142
+ " original_question caveats \n",
143
+ "0 Is there a state/territory law regulating resi... [[]] \n",
144
+ "1 Is there a state/territory law regulating resi... [[]] \n",
145
+ "2 Is there a state/territory law regulating resi... [[]] \n",
146
+ "3 Is there a state/territory law regulating resi... [[]] \n",
147
+ "4 Is there a state/territory law regulating resi... [[]] "
148
+ ]
149
+ },
150
+ "execution_count": 7,
151
+ "metadata": {},
152
+ "output_type": "execute_result"
153
+ }
154
+ ],
155
+ "source": [
156
+ "questions = load_dataset(\"reglab/housing_qa\", \"knowledge_questions\")\n",
157
+ "questions[\"test\"].to_pandas().head(5)"
158
+ ]
159
+ },
160
+ {
161
+ "cell_type": "markdown",
162
+ "id": "c30a72f9-0ebe-4d33-abbd-e53883d04be5",
163
+ "metadata": {},
164
+ "source": [
165
+ "# RC Questions"
166
+ ]
167
+ },
168
+ {
169
+ "cell_type": "code",
170
+ "execution_count": 8,
171
+ "id": "92c9606a-09a5-44c6-94f2-4c9773c1a754",
172
+ "metadata": {},
173
+ "outputs": [
174
+ {
175
+ "name": "stderr",
176
+ "output_type": "stream",
177
+ "text": [
178
+ "Downloading data: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 987k/987k [00:00<00:00, 10.7MB/s]\n",
179
+ "Generating test split: 6853 examples [00:00, 25871.49 examples/s]\n"
180
+ ]
181
+ },
182
+ {
183
+ "data": {
184
+ "text/html": [
185
+ "<div>\n",
186
+ "<style scoped>\n",
187
+ " .dataframe tbody tr th:only-of-type {\n",
188
+ " vertical-align: middle;\n",
189
+ " }\n",
190
+ "\n",
191
+ " .dataframe tbody tr th {\n",
192
+ " vertical-align: top;\n",
193
+ " }\n",
194
+ "\n",
195
+ " .dataframe thead th {\n",
196
+ " text-align: right;\n",
197
+ " }\n",
198
+ "</style>\n",
199
+ "<table border=\"1\" class=\"dataframe\">\n",
200
+ " <thead>\n",
201
+ " <tr style=\"text-align: right;\">\n",
202
+ " <th></th>\n",
203
+ " <th>idx</th>\n",
204
+ " <th>state</th>\n",
205
+ " <th>question</th>\n",
206
+ " <th>answer</th>\n",
207
+ " <th>question_group</th>\n",
208
+ " <th>statutes</th>\n",
209
+ " <th>original_question</th>\n",
210
+ " <th>caveats</th>\n",
211
+ " </tr>\n",
212
+ " </thead>\n",
213
+ " <tbody>\n",
214
+ " <tr>\n",
215
+ " <th>0</th>\n",
216
+ " <td>0</td>\n",
217
+ " <td>Alabama</td>\n",
218
+ " <td>Is there a state/territory law regulating resi...</td>\n",
219
+ " <td>Yes</td>\n",
220
+ " <td>69</td>\n",
221
+ " <td>{'statute_idx': [431263], 'citation': ['ALA. C...</td>\n",
222
+ " <td>Is there a state/territory law regulating resi...</td>\n",
223
+ " <td>[[]]</td>\n",
224
+ " </tr>\n",
225
+ " <tr>\n",
226
+ " <th>1</th>\n",
227
+ " <td>163</td>\n",
228
+ " <td>Alabama</td>\n",
229
+ " <td>Does the law specify a minimum number of days ...</td>\n",
230
+ " <td>Yes</td>\n",
231
+ " <td>23</td>\n",
232
+ " <td>{'statute_idx': [431277], 'citation': ['ALA. C...</td>\n",
233
+ " <td>Does the law specify a minimum number of days ...</td>\n",
234
+ " <td>[[]]</td>\n",
235
+ " </tr>\n",
236
+ " <tr>\n",
237
+ " <th>2</th>\n",
238
+ " <td>237</td>\n",
239
+ " <td>Alabama</td>\n",
240
+ " <td>Does the law specify rebuttals available to te...</td>\n",
241
+ " <td>Yes</td>\n",
242
+ " <td>116</td>\n",
243
+ " <td>{'statute_idx': [417060, 431274, 431280, 43127...</td>\n",
244
+ " <td>Does the law specify rebuttals available to a ...</td>\n",
245
+ " <td>[[]]</td>\n",
246
+ " </tr>\n",
247
+ " <tr>\n",
248
+ " <th>3</th>\n",
249
+ " <td>286</td>\n",
250
+ " <td>Alabama</td>\n",
251
+ " <td>In eviction proceedings, does the filing of an...</td>\n",
252
+ " <td>Yes</td>\n",
253
+ " <td>4</td>\n",
254
+ " <td>{'statute_idx': [431286], 'citation': ['ALA. C...</td>\n",
255
+ " <td>Does the filing of an appeal stay the executio...</td>\n",
256
+ " <td>[[]]</td>\n",
257
+ " </tr>\n",
258
+ " <tr>\n",
259
+ " <th>4</th>\n",
260
+ " <td>353</td>\n",
261
+ " <td>Alabama</td>\n",
262
+ " <td>Is it specified whether a landlord waives thei...</td>\n",
263
+ " <td>Yes</td>\n",
264
+ " <td>201</td>\n",
265
+ " <td>{'statute_idx': [431280], 'citation': ['ALA. C...</td>\n",
266
+ " <td>Does a landlord waive their right to evict for...</td>\n",
267
+ " <td>[[A, , l, a, n, d, l, o, r, d, , w, a, i, v,...</td>\n",
268
+ " </tr>\n",
269
+ " </tbody>\n",
270
+ "</table>\n",
271
+ "</div>"
272
+ ],
273
+ "text/plain": [
274
+ " idx state question answer \\\n",
275
+ "0 0 Alabama Is there a state/territory law regulating resi... Yes \n",
276
+ "1 163 Alabama Does the law specify a minimum number of days ... Yes \n",
277
+ "2 237 Alabama Does the law specify rebuttals available to te... Yes \n",
278
+ "3 286 Alabama In eviction proceedings, does the filing of an... Yes \n",
279
+ "4 353 Alabama Is it specified whether a landlord waives thei... Yes \n",
280
+ "\n",
281
+ " question_group statutes \\\n",
282
+ "0 69 {'statute_idx': [431263], 'citation': ['ALA. C... \n",
283
+ "1 23 {'statute_idx': [431277], 'citation': ['ALA. C... \n",
284
+ "2 116 {'statute_idx': [417060, 431274, 431280, 43127... \n",
285
+ "3 4 {'statute_idx': [431286], 'citation': ['ALA. C... \n",
286
+ "4 201 {'statute_idx': [431280], 'citation': ['ALA. C... \n",
287
+ "\n",
288
+ " original_question \\\n",
289
+ "0 Is there a state/territory law regulating resi... \n",
290
+ "1 Does the law specify a minimum number of days ... \n",
291
+ "2 Does the law specify rebuttals available to a ... \n",
292
+ "3 Does the filing of an appeal stay the executio... \n",
293
+ "4 Does a landlord waive their right to evict for... \n",
294
+ "\n",
295
+ " caveats \n",
296
+ "0 [[]] \n",
297
+ "1 [[]] \n",
298
+ "2 [[]] \n",
299
+ "3 [[]] \n",
300
+ "4 [[A, , l, a, n, d, l, o, r, d, , w, a, i, v,... "
301
+ ]
302
+ },
303
+ "execution_count": 8,
304
+ "metadata": {},
305
+ "output_type": "execute_result"
306
+ }
307
+ ],
308
+ "source": [
309
+ "questions = load_dataset(\"reglab/housing_qa\", \"rc_questions\")\n",
310
+ "questions[\"test\"].to_pandas().head(5)"
311
+ ]
312
+ },
313
+ {
314
+ "cell_type": "markdown",
315
+ "id": "692490c0-eaa3-4f88-9b25-630f6ce736a3",
316
+ "metadata": {},
317
+ "source": [
318
+ "# Statutes"
319
+ ]
320
+ },
321
+ {
322
+ "cell_type": "code",
323
+ "execution_count": null,
324
+ "id": "b4ce7ae9-618f-4594-be69-b53a58e580e4",
325
+ "metadata": {},
326
+ "outputs": [
327
+ {
328
+ "name": "stderr",
329
+ "output_type": "stream",
330
+ "text": [
331
+ "Downloading data: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 732M/732M [00:27<00:00, 26.4MB/s]\n",
332
+ "Generating test split: 0 examples [00:00, ? examples/s]"
333
+ ]
334
+ }
335
+ ],
336
+ "source": [
337
+ "statutes = load_dataset(\"reglab/housing_qa\", \"statutes\")\n",
338
+ "statutes[\"test\"].to_pandas().head(5)"
339
+ ]
340
+ },
341
+ {
342
+ "cell_type": "code",
343
+ "execution_count": null,
344
+ "id": "c6958462-4f76-4a2d-8a6b-f379fc70095a",
345
+ "metadata": {},
346
+ "outputs": [],
347
+ "source": []
348
+ }
349
+ ],
350
+ "metadata": {
351
+ "kernelspec": {
352
+ "display_name": "Python 3 (ipykernel)",
353
+ "language": "python",
354
+ "name": "python3"
355
+ },
356
+ "language_info": {
357
+ "codemirror_mode": {
358
+ "name": "ipython",
359
+ "version": 3
360
+ },
361
+ "file_extension": ".py",
362
+ "mimetype": "text/x-python",
363
+ "name": "python",
364
+ "nbconvert_exporter": "python",
365
+ "pygments_lexer": "ipython3",
366
+ "version": "3.11.4"
367
+ }
368
+ },
369
+ "nbformat": 4,
370
+ "nbformat_minor": 5
371
+ }
housing_qa.py CHANGED
@@ -98,7 +98,7 @@ class HousingQA(datasets.GeneratorBasedBuilder):
98
  downloaded_file_dir = Path(dl_manager.download_and_extract(_URLS[self.config.name]))
99
  return [
100
  datasets.SplitGenerator(
101
- name=datasets.Split.TEST,
102
  gen_kwargs={
103
  "downloaded_file_dir": downloaded_file_dir,
104
  "name": self.config.name,
 
98
  downloaded_file_dir = Path(dl_manager.download_and_extract(_URLS[self.config.name]))
99
  return [
100
  datasets.SplitGenerator(
101
+ name="corpus",
102
  gen_kwargs={
103
  "downloaded_file_dir": downloaded_file_dir,
104
  "name": self.config.name,