Datasets:
Changed data
Browse files- .DS_Store +0 -0
- .gitattributes +8 -0
- .ipynb_checkpoints/demo-checkpoint.ipynb +455 -0
- .ipynb_checkpoints/statistics-checkpoint.ipynb +332 -0
- README.md +75 -51
- copy_data.py +22 -0
- data/.DS_Store +0 -0
- data/knowledge_questions.json +0 -3
- data/{rc_questions.json.zip → questions.json.zip} +2 -2
- data/{knowledge_questions.json.zip → questions_aux.json.zip} +2 -2
- data/rc_questions.json +0 -3
- demo.ipynb +39 -6
- housing_qa.py +19 -31
- statistics.ipynb +332 -0
.DS_Store
ADDED
Binary file (8.2 kB). View file
|
|
.gitattributes
CHANGED
@@ -53,3 +53,11 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
53 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
54 |
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
55 |
*.webp filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
54 |
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
55 |
*.webp filter=lfs diff=lfs merge=lfs -text
|
56 |
+
data/rc_questions.json.zip filter=lfs diff=lfs merge=lfs -text
|
57 |
+
data/statutes.tsv.zip filter=lfs diff=lfs merge=lfs -text
|
58 |
+
data/knowledge_questions.json.zip filter=lfs diff=lfs merge=lfs -text
|
59 |
+
data/knowledge_questions.json filter=lfs diff=lfs merge=lfs -text
|
60 |
+
data/rc_questions.json filter=lfs diff=lfs merge=lfs -text
|
61 |
+
data/statutes.tsv filter=lfs diff=lfs merge=lfs -text
|
62 |
+
data/questions.json.zip filter=lfs diff=lfs merge=lfs -text
|
63 |
+
data/questions_aux.json.zip filter=lfs diff=lfs merge=lfs -text
|
.ipynb_checkpoints/demo-checkpoint.ipynb
ADDED
@@ -0,0 +1,455 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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": 12,
|
324 |
+
"id": "b4ce7ae9-618f-4594-be69-b53a58e580e4",
|
325 |
+
"metadata": {},
|
326 |
+
"outputs": [
|
327 |
+
{
|
328 |
+
"data": {
|
329 |
+
"text/html": [
|
330 |
+
"<div>\n",
|
331 |
+
"<style scoped>\n",
|
332 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
333 |
+
" vertical-align: middle;\n",
|
334 |
+
" }\n",
|
335 |
+
"\n",
|
336 |
+
" .dataframe tbody tr th {\n",
|
337 |
+
" vertical-align: top;\n",
|
338 |
+
" }\n",
|
339 |
+
"\n",
|
340 |
+
" .dataframe thead th {\n",
|
341 |
+
" text-align: right;\n",
|
342 |
+
" }\n",
|
343 |
+
"</style>\n",
|
344 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
345 |
+
" <thead>\n",
|
346 |
+
" <tr style=\"text-align: right;\">\n",
|
347 |
+
" <th></th>\n",
|
348 |
+
" <th>citation</th>\n",
|
349 |
+
" <th>path</th>\n",
|
350 |
+
" <th>state</th>\n",
|
351 |
+
" <th>text</th>\n",
|
352 |
+
" <th>idx</th>\n",
|
353 |
+
" </tr>\n",
|
354 |
+
" </thead>\n",
|
355 |
+
" <tbody>\n",
|
356 |
+
" <tr>\n",
|
357 |
+
" <th>0</th>\n",
|
358 |
+
" <td>MO Rev Stat § 1.010 (2021)</td>\n",
|
359 |
+
" <td>2021 Missouri Revised Statutes|Title I - Laws ...</td>\n",
|
360 |
+
" <td>missouri</td>\n",
|
361 |
+
" <td>Effective - 28 Aug 2015 1.010. Common law in...</td>\n",
|
362 |
+
" <td>0</td>\n",
|
363 |
+
" </tr>\n",
|
364 |
+
" <tr>\n",
|
365 |
+
" <th>1</th>\n",
|
366 |
+
" <td>MO Rev Stat § 1.020 (2021)</td>\n",
|
367 |
+
" <td>2021 Missouri Revised Statutes|Title I - Laws ...</td>\n",
|
368 |
+
" <td>missouri</td>\n",
|
369 |
+
" <td>Effective - 28 Aug 2009 1.020. Definitions. ...</td>\n",
|
370 |
+
" <td>1</td>\n",
|
371 |
+
" </tr>\n",
|
372 |
+
" <tr>\n",
|
373 |
+
" <th>2</th>\n",
|
374 |
+
" <td>MO Rev Stat § 1.025 (2021)</td>\n",
|
375 |
+
" <td>2021 Missouri Revised Statutes|Title I - Laws ...</td>\n",
|
376 |
+
" <td>missouri</td>\n",
|
377 |
+
" <td>Effective - 28 Aug 1958 1.025. Registered ma...</td>\n",
|
378 |
+
" <td>2</td>\n",
|
379 |
+
" </tr>\n",
|
380 |
+
" <tr>\n",
|
381 |
+
" <th>3</th>\n",
|
382 |
+
" <td>MO Rev Stat § 1.028 (2021)</td>\n",
|
383 |
+
" <td>2021 Missouri Revised Statutes|Title I - Laws ...</td>\n",
|
384 |
+
" <td>missouri</td>\n",
|
385 |
+
" <td>Effective - 28 Aug 1999 1.028. English is th...</td>\n",
|
386 |
+
" <td>3</td>\n",
|
387 |
+
" </tr>\n",
|
388 |
+
" <tr>\n",
|
389 |
+
" <th>4</th>\n",
|
390 |
+
" <td>MO Rev Stat § 1.030 (2021)</td>\n",
|
391 |
+
" <td>2021 Missouri Revised Statutes|Title I - Laws ...</td>\n",
|
392 |
+
" <td>missouri</td>\n",
|
393 |
+
" <td>Effective - 28 Aug 1957 1.030. Plural includ...</td>\n",
|
394 |
+
" <td>4</td>\n",
|
395 |
+
" </tr>\n",
|
396 |
+
" </tbody>\n",
|
397 |
+
"</table>\n",
|
398 |
+
"</div>"
|
399 |
+
],
|
400 |
+
"text/plain": [
|
401 |
+
" citation \\\n",
|
402 |
+
"0 MO Rev Stat § 1.010 (2021) \n",
|
403 |
+
"1 MO Rev Stat § 1.020 (2021) \n",
|
404 |
+
"2 MO Rev Stat § 1.025 (2021) \n",
|
405 |
+
"3 MO Rev Stat § 1.028 (2021) \n",
|
406 |
+
"4 MO Rev Stat § 1.030 (2021) \n",
|
407 |
+
"\n",
|
408 |
+
" path state \\\n",
|
409 |
+
"0 2021 Missouri Revised Statutes|Title I - Laws ... missouri \n",
|
410 |
+
"1 2021 Missouri Revised Statutes|Title I - Laws ... missouri \n",
|
411 |
+
"2 2021 Missouri Revised Statutes|Title I - Laws ... missouri \n",
|
412 |
+
"3 2021 Missouri Revised Statutes|Title I - Laws ... missouri \n",
|
413 |
+
"4 2021 Missouri Revised Statutes|Title I - Laws ... missouri \n",
|
414 |
+
"\n",
|
415 |
+
" text idx \n",
|
416 |
+
"0 Effective - 28 Aug 2015 1.010. Common law in... 0 \n",
|
417 |
+
"1 Effective - 28 Aug 2009 1.020. Definitions. ... 1 \n",
|
418 |
+
"2 Effective - 28 Aug 1958 1.025. Registered ma... 2 \n",
|
419 |
+
"3 Effective - 28 Aug 1999 1.028. English is th... 3 \n",
|
420 |
+
"4 Effective - 28 Aug 1957 1.030. Plural includ... 4 "
|
421 |
+
]
|
422 |
+
},
|
423 |
+
"execution_count": 12,
|
424 |
+
"metadata": {},
|
425 |
+
"output_type": "execute_result"
|
426 |
+
}
|
427 |
+
],
|
428 |
+
"source": [
|
429 |
+
"statutes = load_dataset(\"reglab/housing_qa\", \"statutes\")\n",
|
430 |
+
"statutes[\"corpus\"].to_pandas().head(5)"
|
431 |
+
]
|
432 |
+
}
|
433 |
+
],
|
434 |
+
"metadata": {
|
435 |
+
"kernelspec": {
|
436 |
+
"display_name": "Python 3 (ipykernel)",
|
437 |
+
"language": "python",
|
438 |
+
"name": "python3"
|
439 |
+
},
|
440 |
+
"language_info": {
|
441 |
+
"codemirror_mode": {
|
442 |
+
"name": "ipython",
|
443 |
+
"version": 3
|
444 |
+
},
|
445 |
+
"file_extension": ".py",
|
446 |
+
"mimetype": "text/x-python",
|
447 |
+
"name": "python",
|
448 |
+
"nbconvert_exporter": "python",
|
449 |
+
"pygments_lexer": "ipython3",
|
450 |
+
"version": "3.11.4"
|
451 |
+
}
|
452 |
+
},
|
453 |
+
"nbformat": 4,
|
454 |
+
"nbformat_minor": 5
|
455 |
+
}
|
.ipynb_checkpoints/statistics-checkpoint.ipynb
ADDED
@@ -0,0 +1,332 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 15,
|
6 |
+
"id": "fce498ac-4ea7-4e10-a15a-60ac41e3adce",
|
7 |
+
"metadata": {},
|
8 |
+
"outputs": [],
|
9 |
+
"source": [
|
10 |
+
"from datasets import load_dataset\n",
|
11 |
+
"from collections import Counter"
|
12 |
+
]
|
13 |
+
},
|
14 |
+
{
|
15 |
+
"cell_type": "code",
|
16 |
+
"execution_count": 7,
|
17 |
+
"id": "73aaafd1-3ebb-42f7-b162-2e6bc630d195",
|
18 |
+
"metadata": {},
|
19 |
+
"outputs": [
|
20 |
+
{
|
21 |
+
"name": "stdout",
|
22 |
+
"output_type": "stream",
|
23 |
+
"text": [
|
24 |
+
"Downloading and preparing dataset housing_qa/rc_questions to /Users/neelguha/.cache/huggingface/datasets/reglab___housing_qa/rc_questions/1.0.0/cc9b072f76a495a77b95dea87f9dce53c85bad450eb9ac41c80026e7d4b0f08e...\n"
|
25 |
+
]
|
26 |
+
},
|
27 |
+
{
|
28 |
+
"name": "stderr",
|
29 |
+
"output_type": "stream",
|
30 |
+
"text": [
|
31 |
+
" \r"
|
32 |
+
]
|
33 |
+
},
|
34 |
+
{
|
35 |
+
"name": "stdout",
|
36 |
+
"output_type": "stream",
|
37 |
+
"text": [
|
38 |
+
"Dataset housing_qa downloaded and prepared to /Users/neelguha/.cache/huggingface/datasets/reglab___housing_qa/rc_questions/1.0.0/cc9b072f76a495a77b95dea87f9dce53c85bad450eb9ac41c80026e7d4b0f08e. Subsequent calls will reuse this data.\n"
|
39 |
+
]
|
40 |
+
},
|
41 |
+
{
|
42 |
+
"data": {
|
43 |
+
"text/plain": [
|
44 |
+
"{'idx': 0,\n",
|
45 |
+
" 'state': 'Alabama',\n",
|
46 |
+
" 'question': 'Is there a state/territory law regulating residential evictions?',\n",
|
47 |
+
" 'answer': 'Yes',\n",
|
48 |
+
" 'question_group': 69,\n",
|
49 |
+
" 'statutes': {'statute_idx': [431263],\n",
|
50 |
+
" 'citation': ['ALA. CODE § 35-9A-141(11)'],\n",
|
51 |
+
" 'excerpt': ['(11) “premises” means a dwelling unit and the structure of which it is a part and facilities and appurtenances therein and grounds, areas, and facilities held out for the use of tenants generally or whose use is promised by the rental agreement to the tenant;']},\n",
|
52 |
+
" 'original_question': 'Is there a state/territory law regulating residential evictions?',\n",
|
53 |
+
" 'caveats': [[]]}"
|
54 |
+
]
|
55 |
+
},
|
56 |
+
"execution_count": 7,
|
57 |
+
"metadata": {},
|
58 |
+
"output_type": "execute_result"
|
59 |
+
}
|
60 |
+
],
|
61 |
+
"source": [
|
62 |
+
"questions = load_dataset(\"reglab/housing_qa\", \"rc_questions\", split=\"corpus\")\n",
|
63 |
+
"questions[0]"
|
64 |
+
]
|
65 |
+
},
|
66 |
+
{
|
67 |
+
"cell_type": "code",
|
68 |
+
"execution_count": 18,
|
69 |
+
"id": "c28a88fe-933f-424c-9b81-fc43eea34dee",
|
70 |
+
"metadata": {},
|
71 |
+
"outputs": [],
|
72 |
+
"source": [
|
73 |
+
"counts = []\n",
|
74 |
+
"for sample in questions: \n",
|
75 |
+
" if len(sample[\"caveats\"][0]) > 0:\n",
|
76 |
+
" break "
|
77 |
+
]
|
78 |
+
},
|
79 |
+
{
|
80 |
+
"cell_type": "code",
|
81 |
+
"execution_count": 19,
|
82 |
+
"id": "2c24819e-0019-4c60-9284-77bfa565ecc5",
|
83 |
+
"metadata": {},
|
84 |
+
"outputs": [
|
85 |
+
{
|
86 |
+
"data": {
|
87 |
+
"text/plain": [
|
88 |
+
"{'idx': 353,\n",
|
89 |
+
" 'state': 'Alabama',\n",
|
90 |
+
" 'question': 'Is it specified whether a landlord waives their right to evict for nonpayment of rent by accepting partial payment of rent?',\n",
|
91 |
+
" 'answer': 'Yes',\n",
|
92 |
+
" 'question_group': 201,\n",
|
93 |
+
" 'statutes': {'statute_idx': [431280],\n",
|
94 |
+
" 'citation': ['ALA. CODE § 35-9A-424'],\n",
|
95 |
+
" 'excerpt': [\"Acceptance of rent with knowledge of a default by the tenant or acceptance of performance by the tenant that varies from the terms of the rental agreement constitutes a waiver of the landlord's right to terminate the rental agreement for that breach, unless otherwise agreed after the breach has occurred.\"]},\n",
|
96 |
+
" 'original_question': 'Does a landlord waive their right to evict for nonpayment of rent by accepting partial payment of rent?',\n",
|
97 |
+
" 'caveats': [['A',\n",
|
98 |
+
" ' ',\n",
|
99 |
+
" 'l',\n",
|
100 |
+
" 'a',\n",
|
101 |
+
" 'n',\n",
|
102 |
+
" 'd',\n",
|
103 |
+
" 'l',\n",
|
104 |
+
" 'o',\n",
|
105 |
+
" 'r',\n",
|
106 |
+
" 'd',\n",
|
107 |
+
" ' ',\n",
|
108 |
+
" 'w',\n",
|
109 |
+
" 'a',\n",
|
110 |
+
" 'i',\n",
|
111 |
+
" 'v',\n",
|
112 |
+
" 'e',\n",
|
113 |
+
" 's',\n",
|
114 |
+
" ' ',\n",
|
115 |
+
" 't',\n",
|
116 |
+
" 'h',\n",
|
117 |
+
" 'e',\n",
|
118 |
+
" 'i',\n",
|
119 |
+
" 'r',\n",
|
120 |
+
" ' ',\n",
|
121 |
+
" 'r',\n",
|
122 |
+
" 'i',\n",
|
123 |
+
" 'g',\n",
|
124 |
+
" 'h',\n",
|
125 |
+
" 't',\n",
|
126 |
+
" ' ',\n",
|
127 |
+
" 't',\n",
|
128 |
+
" 'o',\n",
|
129 |
+
" ' ',\n",
|
130 |
+
" 'e',\n",
|
131 |
+
" 'v',\n",
|
132 |
+
" 'i',\n",
|
133 |
+
" 'c',\n",
|
134 |
+
" 't',\n",
|
135 |
+
" ' ',\n",
|
136 |
+
" 'b',\n",
|
137 |
+
" 'y',\n",
|
138 |
+
" ' ',\n",
|
139 |
+
" 'a',\n",
|
140 |
+
" 'c',\n",
|
141 |
+
" 'c',\n",
|
142 |
+
" 'e',\n",
|
143 |
+
" 'p',\n",
|
144 |
+
" 't',\n",
|
145 |
+
" 'i',\n",
|
146 |
+
" 'n',\n",
|
147 |
+
" 'g',\n",
|
148 |
+
" ' ',\n",
|
149 |
+
" 'p',\n",
|
150 |
+
" 'a',\n",
|
151 |
+
" 'y',\n",
|
152 |
+
" 'm',\n",
|
153 |
+
" 'e',\n",
|
154 |
+
" 'n',\n",
|
155 |
+
" 't',\n",
|
156 |
+
" ' ',\n",
|
157 |
+
" 'o',\n",
|
158 |
+
" 'f',\n",
|
159 |
+
" ' ',\n",
|
160 |
+
" 'r',\n",
|
161 |
+
" 'e',\n",
|
162 |
+
" 'n',\n",
|
163 |
+
" 't',\n",
|
164 |
+
" ',',\n",
|
165 |
+
" ' ',\n",
|
166 |
+
" 'A',\n",
|
167 |
+
" 'l',\n",
|
168 |
+
" 'a',\n",
|
169 |
+
" '.',\n",
|
170 |
+
" ' ',\n",
|
171 |
+
" 'C',\n",
|
172 |
+
" 'o',\n",
|
173 |
+
" 'd',\n",
|
174 |
+
" 'e',\n",
|
175 |
+
" ' ',\n",
|
176 |
+
" '§',\n",
|
177 |
+
" ' ',\n",
|
178 |
+
" '3',\n",
|
179 |
+
" '5',\n",
|
180 |
+
" '-',\n",
|
181 |
+
" '9',\n",
|
182 |
+
" 'A',\n",
|
183 |
+
" '-',\n",
|
184 |
+
" '4',\n",
|
185 |
+
" '2',\n",
|
186 |
+
" '4',\n",
|
187 |
+
" ',',\n",
|
188 |
+
" ' ',\n",
|
189 |
+
" 'b',\n",
|
190 |
+
" 'u',\n",
|
191 |
+
" 't',\n",
|
192 |
+
" ' ',\n",
|
193 |
+
" 't',\n",
|
194 |
+
" 'h',\n",
|
195 |
+
" 'e',\n",
|
196 |
+
" ' ',\n",
|
197 |
+
" 'l',\n",
|
198 |
+
" 'a',\n",
|
199 |
+
" 'w',\n",
|
200 |
+
" ' ',\n",
|
201 |
+
" 'd',\n",
|
202 |
+
" 'o',\n",
|
203 |
+
" 'e',\n",
|
204 |
+
" 's',\n",
|
205 |
+
" ' ',\n",
|
206 |
+
" 'n',\n",
|
207 |
+
" 'o',\n",
|
208 |
+
" 't',\n",
|
209 |
+
" ' ',\n",
|
210 |
+
" 's',\n",
|
211 |
+
" 'p',\n",
|
212 |
+
" 'e',\n",
|
213 |
+
" 'c',\n",
|
214 |
+
" 'i',\n",
|
215 |
+
" 'f',\n",
|
216 |
+
" 'y',\n",
|
217 |
+
" ' ',\n",
|
218 |
+
" 'w',\n",
|
219 |
+
" 'h',\n",
|
220 |
+
" 'e',\n",
|
221 |
+
" 't',\n",
|
222 |
+
" 'h',\n",
|
223 |
+
" 'e',\n",
|
224 |
+
" 'r',\n",
|
225 |
+
" ' ',\n",
|
226 |
+
" 'a',\n",
|
227 |
+
" 'c',\n",
|
228 |
+
" 'c',\n",
|
229 |
+
" 'e',\n",
|
230 |
+
" 'p',\n",
|
231 |
+
" 't',\n",
|
232 |
+
" 'a',\n",
|
233 |
+
" 'n',\n",
|
234 |
+
" 'c',\n",
|
235 |
+
" 'e',\n",
|
236 |
+
" ' ',\n",
|
237 |
+
" 'o',\n",
|
238 |
+
" 'f',\n",
|
239 |
+
" ' ',\n",
|
240 |
+
" 'f',\n",
|
241 |
+
" 'u',\n",
|
242 |
+
" 'l',\n",
|
243 |
+
" 'l',\n",
|
244 |
+
" ' ',\n",
|
245 |
+
" 'o',\n",
|
246 |
+
" 'r',\n",
|
247 |
+
" ' ',\n",
|
248 |
+
" 'p',\n",
|
249 |
+
" 'a',\n",
|
250 |
+
" 'r',\n",
|
251 |
+
" 't',\n",
|
252 |
+
" 'i',\n",
|
253 |
+
" 'a',\n",
|
254 |
+
" 'l',\n",
|
255 |
+
" ' ',\n",
|
256 |
+
" 'p',\n",
|
257 |
+
" 'a',\n",
|
258 |
+
" 'y',\n",
|
259 |
+
" 'm',\n",
|
260 |
+
" 'e',\n",
|
261 |
+
" 'n',\n",
|
262 |
+
" 't',\n",
|
263 |
+
" ' ',\n",
|
264 |
+
" 'i',\n",
|
265 |
+
" 's',\n",
|
266 |
+
" ' ',\n",
|
267 |
+
" 'r',\n",
|
268 |
+
" 'e',\n",
|
269 |
+
" 'q',\n",
|
270 |
+
" 'u',\n",
|
271 |
+
" 'i',\n",
|
272 |
+
" 'r',\n",
|
273 |
+
" 'e',\n",
|
274 |
+
" 'd',\n",
|
275 |
+
" ' ',\n",
|
276 |
+
" 'f',\n",
|
277 |
+
" 'o',\n",
|
278 |
+
" 'r',\n",
|
279 |
+
" ' ',\n",
|
280 |
+
" 't',\n",
|
281 |
+
" 'h',\n",
|
282 |
+
" 'e',\n",
|
283 |
+
" ' ',\n",
|
284 |
+
" 'w',\n",
|
285 |
+
" 'a',\n",
|
286 |
+
" 'i',\n",
|
287 |
+
" 'v',\n",
|
288 |
+
" 'e',\n",
|
289 |
+
" 'r',\n",
|
290 |
+
" '.']]}"
|
291 |
+
]
|
292 |
+
},
|
293 |
+
"execution_count": 19,
|
294 |
+
"metadata": {},
|
295 |
+
"output_type": "execute_result"
|
296 |
+
}
|
297 |
+
],
|
298 |
+
"source": [
|
299 |
+
"sample"
|
300 |
+
]
|
301 |
+
},
|
302 |
+
{
|
303 |
+
"cell_type": "code",
|
304 |
+
"execution_count": null,
|
305 |
+
"id": "893dbd5a-e351-43a9-b939-ed022a78b78a",
|
306 |
+
"metadata": {},
|
307 |
+
"outputs": [],
|
308 |
+
"source": []
|
309 |
+
}
|
310 |
+
],
|
311 |
+
"metadata": {
|
312 |
+
"kernelspec": {
|
313 |
+
"display_name": "Python 3 (ipykernel)",
|
314 |
+
"language": "python",
|
315 |
+
"name": "python3"
|
316 |
+
},
|
317 |
+
"language_info": {
|
318 |
+
"codemirror_mode": {
|
319 |
+
"name": "ipython",
|
320 |
+
"version": 3
|
321 |
+
},
|
322 |
+
"file_extension": ".py",
|
323 |
+
"mimetype": "text/x-python",
|
324 |
+
"name": "python",
|
325 |
+
"nbconvert_exporter": "python",
|
326 |
+
"pygments_lexer": "ipython3",
|
327 |
+
"version": "3.8.18"
|
328 |
+
}
|
329 |
+
},
|
330 |
+
"nbformat": 4,
|
331 |
+
"nbformat_minor": 5
|
332 |
+
}
|
README.md
CHANGED
@@ -15,68 +15,79 @@ size_categories:
|
|
15 |
- 1K<n<10K
|
16 |
---
|
17 |
|
18 |
-
`HousingQA` is a benchmark evaluating LLMs' abilities to answer questions about housing law in different states.
|
19 |
|
|
|
|
|
|
|
20 |
|
21 |
-
`
|
22 |
|
|
|
23 |
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
```json
|
28 |
{
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
|
|
45 |
```
|
46 |
where:
|
47 |
- `idx`: unique sample idx
|
48 |
- `state`: the state to which the question pertains.
|
49 |
- `question`: the question
|
50 |
- `answer`: the answer to the question
|
51 |
-
- `question_group`: the question
|
52 |
-
- `statutes`:
|
|
|
53 |
- `citation`: the statute citation
|
54 |
- `excerpt`: an excerpt from the statute
|
55 |
- `original_question`: the original question from the LSC database. This is sometimes identical to `question`. In other cases `question` corresponds to a rephrased version of this designed to have a yes/no answer.
|
56 |
- `caveats`: any caveats to the answer, from the LSC annotations.
|
57 |
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
Consider statutory law for {state} in the year 2021. {question}
|
63 |
-
|
64 |
-
Answer "Yes" or "No".
|
65 |
-
Answer:
|
66 |
-
```
|
67 |
|
68 |
-
## rc_questions
|
69 |
-
`rc_questions` consists of 6853 yes/no questions. Each question and answer are specific to a jurisdiction.
|
70 |
|
71 |
-
`rc_questions` is a subset of `knowledge_questions`. Each question in this subset has been annotated with a list of relevant statutes, all of which are contained in the `statutes` split.
|
72 |
|
73 |
-
`rc_questions` can be used in several ways:
|
74 |
|
75 |
-
|
76 |
-
|
77 |
-
- To evaluate **RAG**, by using an embedding-based retriever to identify the relevant statutes for a question (from the `statutes` split) and then asking a LLM to answer the question based on the statutes provided.
|
78 |
-
|
79 |
-
Each row has the following structure:
|
80 |
|
81 |
```json
|
82 |
{
|
@@ -87,7 +98,6 @@ Each row has the following structure:
|
|
87 |
"question_group": 69,
|
88 |
"statutes": [
|
89 |
{
|
90 |
-
"statute_idx": 431263,
|
91 |
"citation": "ALA. CODE \u00a7 35-9A-141(11)",
|
92 |
"excerpt": "(11) \u201cpremises\u201d means a dwelling unit and the structure of which it is a part and facilities and appurtenances therein and grounds, areas, and facilities held out for the use of tenants generally or whose use is promised by the rental agreement to the tenant;"
|
93 |
}
|
@@ -104,8 +114,7 @@ where:
|
|
104 |
- `question`: the question
|
105 |
- `answer`: the answer to the question
|
106 |
- `question_group`: the question group. Questions repeated in different jurisdictions have the same `question_group` value.
|
107 |
-
- `statutes`: the statutes that support the answer
|
108 |
-
- `statute_idx`: a foreign key corresponding to the `idx` column in the `statutes` split.
|
109 |
- `citation`: the statute citation
|
110 |
- `excerpt`: an excerpt from the statute
|
111 |
- `original_question`: the original question from the LSC database. This is sometimes identical to `question`. In other cases `question` corresponds to a rephrased version of this designed to have a yes/no answer.
|
@@ -114,19 +123,15 @@ where:
|
|
114 |
If you want to prompt a LLM to answer the question, we recommend explicitly providing the state and specifying that the question should be answered with respect the law in 2021.
|
115 |
|
116 |
```text
|
117 |
-
Consider statutory law for {state} in the year 2021. Read the following statute excerpts which govern housing law in this state, and answer the question below.
|
118 |
-
|
119 |
-
Statutes ##################
|
120 |
-
|
121 |
-
{statute_list}
|
122 |
|
123 |
-
|
124 |
|
125 |
-
{question}
|
126 |
Answer "Yes" or "No".
|
127 |
Answer:
|
128 |
```
|
129 |
|
|
|
|
|
130 |
## statutes
|
131 |
The `statutes` contains approximately 1.7 million statutes collected Justia. Note:
|
132 |
|
@@ -138,4 +143,23 @@ Data has the following columns:
|
|
138 |
- `path`: a string containing the headers for the statute
|
139 |
- `state`: the state for which the statute belongs
|
140 |
- `text`: the text of the statute
|
141 |
-
- `idx`: a unique idx for the statute. This maps to the `statute_idx` column in the `rc_questions` split.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
- 1K<n<10K
|
16 |
---
|
17 |
|
18 |
+
`HousingQA` is a benchmark evaluating LLMs' abilities to answer questions about housing law in different states. `HousingQA` supports the following research questions:
|
19 |
|
20 |
+
- **Knowledge**: Whether LLMs can answer questions about state housing law in the year 2021 using only the knowledge encoded in their weights.
|
21 |
+
- **Comprehension**: Whether LLMs can answer questions about state housing law, given an excerpt of the relevant statutes.
|
22 |
+
- **RAG**: Whether retrieval systems can identify the relevant housing statutes for a question about a state, and an LLM provided with these statutes can answer the question correctly.
|
23 |
|
24 |
+
`HousingQA` consists of three subsets: `questions`, `questions_aux`, and `statutes`. `questions_aux` is a larger set of questions (containing all samples in `questions` and more) but **does** not contain statute annotations. Thus, it cannot be used for evaluating RAG. `statutes` contains a database of statutes that can be used for evaluating full RAG pipelines.
|
25 |
|
26 |
+
`HousingQA` was constructed by collecting questions from the [Legal Services Corporation Eviction Laws Database](https://www.lsc.gov/initiatives/effect-state-local-laws-evictions/lsc-eviction-laws-database), and scraping statutes from [Justia](https://law.justia.com/codes/).
|
27 |
|
28 |
+
**Please note that because all questions and statutes are only accurate as of 2021, nothing in this dataset should be construed as legal advice or used to provide legal advice**.
|
29 |
+
|
30 |
+
## Loading data
|
31 |
+
|
32 |
+
|
33 |
+
```python
|
34 |
+
from datasets import load_dataset
|
35 |
+
|
36 |
+
# Load questions
|
37 |
+
questions = load_dataset("reglab/housing_qa", "questions", split="test")
|
38 |
+
|
39 |
+
# Load questions_aux
|
40 |
+
questions_aux = load_dataset("reglab/housing_qa", "questions_aux", split="test")
|
41 |
+
|
42 |
+
# Load statutes
|
43 |
+
statutes = load_dataset("reglab/housing_qa", "statutes", split="corpus")
|
44 |
+
```
|
45 |
+
|
46 |
+
## questions
|
47 |
+
`questions` consists of 6853 yes/no questions. The original LSC Database answered a common set of questions about housing law for each US state/territory ("jurisdiction"), according to the law in 2021. Each sample in this dataset corresponds to a different (question, jurisdiction) pair and has the following structure:
|
48 |
|
49 |
```json
|
50 |
{
|
51 |
+
"idx": 0,
|
52 |
+
"state": "Alabama",
|
53 |
+
"question": "Is there a state/territory law regulating residential evictions?",
|
54 |
+
"answer": "Yes",
|
55 |
+
"question_group": 69,
|
56 |
+
"statutes": [
|
57 |
+
{
|
58 |
+
"statute_idx": 431263,
|
59 |
+
"citation": "ALA. CODE \u00a7 35-9A-141(11)",
|
60 |
+
"excerpt": "(11) \u201cpremises\u201d means a dwelling unit and the structure of which it is a part and facilities and appurtenances therein and grounds, areas, and facilities held out for the use of tenants generally or whose use is promised by the rental agreement to the tenant;"
|
61 |
+
}
|
62 |
+
],
|
63 |
+
"original_question": "Is there a state/territory law regulating residential evictions?",
|
64 |
+
"caveats": [
|
65 |
+
""
|
66 |
+
]
|
67 |
+
}
|
68 |
```
|
69 |
where:
|
70 |
- `idx`: unique sample idx
|
71 |
- `state`: the state to which the question pertains.
|
72 |
- `question`: the question
|
73 |
- `answer`: the answer to the question
|
74 |
+
- `question_group`: the question type.
|
75 |
+
- `statutes`: the statutes that support the answer
|
76 |
+
- `statute_idx`: a foreign key corresponding to the `idx` column in the `statutes` split.
|
77 |
- `citation`: the statute citation
|
78 |
- `excerpt`: an excerpt from the statute
|
79 |
- `original_question`: the original question from the LSC database. This is sometimes identical to `question`. In other cases `question` corresponds to a rephrased version of this designed to have a yes/no answer.
|
80 |
- `caveats`: any caveats to the answer, from the LSC annotations.
|
81 |
|
82 |
+
Please see the paper for a full description of how scraping and question formatting occured. We note several significant limitations below:
|
83 |
+
- Not all states are represented, and certain states are missing for certain questions.
|
84 |
+
- Not all statutes included in the `statutes` field are necessary for answering the question.
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
|
|
|
|
|
86 |
|
|
|
87 |
|
|
|
88 |
|
89 |
+
## knowledge_qa
|
90 |
+
`knowledge_qa` consists of 9297 yes/no questions. Each question and answer are specific to a jurisdiction. Each row has the following structure:
|
|
|
|
|
|
|
91 |
|
92 |
```json
|
93 |
{
|
|
|
98 |
"question_group": 69,
|
99 |
"statutes": [
|
100 |
{
|
|
|
101 |
"citation": "ALA. CODE \u00a7 35-9A-141(11)",
|
102 |
"excerpt": "(11) \u201cpremises\u201d means a dwelling unit and the structure of which it is a part and facilities and appurtenances therein and grounds, areas, and facilities held out for the use of tenants generally or whose use is promised by the rental agreement to the tenant;"
|
103 |
}
|
|
|
114 |
- `question`: the question
|
115 |
- `answer`: the answer to the question
|
116 |
- `question_group`: the question group. Questions repeated in different jurisdictions have the same `question_group` value.
|
117 |
+
- `statutes`: a list of the statutes that support the answer
|
|
|
118 |
- `citation`: the statute citation
|
119 |
- `excerpt`: an excerpt from the statute
|
120 |
- `original_question`: the original question from the LSC database. This is sometimes identical to `question`. In other cases `question` corresponds to a rephrased version of this designed to have a yes/no answer.
|
|
|
123 |
If you want to prompt a LLM to answer the question, we recommend explicitly providing the state and specifying that the question should be answered with respect the law in 2021.
|
124 |
|
125 |
```text
|
|
|
|
|
|
|
|
|
|
|
126 |
|
127 |
+
Consider statutory law for {state} in the year 2021. {question}
|
128 |
|
|
|
129 |
Answer "Yes" or "No".
|
130 |
Answer:
|
131 |
```
|
132 |
|
133 |
+
|
134 |
+
|
135 |
## statutes
|
136 |
The `statutes` contains approximately 1.7 million statutes collected Justia. Note:
|
137 |
|
|
|
143 |
- `path`: a string containing the headers for the statute
|
144 |
- `state`: the state for which the statute belongs
|
145 |
- `text`: the text of the statute
|
146 |
+
- `idx`: a unique idx for the statute. This maps to the `statute_idx` column in the `rc_questions` split.
|
147 |
+
|
148 |
+
|
149 |
+
## Prompting
|
150 |
+
|
151 |
+
If you want to prompt a LLM to answer the question, we recommend explicitly providing the state and specifying that the question should be answered with respect the law in 2021.
|
152 |
+
|
153 |
+
```text
|
154 |
+
Consider statutory law for {state} in the year 2021. Read the following statute excerpts which govern housing law in this state, and answer the question below.
|
155 |
+
|
156 |
+
Statutes ##################
|
157 |
+
|
158 |
+
{statute_list}
|
159 |
+
|
160 |
+
Question ##################
|
161 |
+
|
162 |
+
{question}
|
163 |
+
Answer "Yes" or "No".
|
164 |
+
Answer:
|
165 |
+
```
|
copy_data.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import shutil
|
3 |
+
import zipfile
|
4 |
+
|
5 |
+
# Ensure the data directory exists
|
6 |
+
os.makedirs('data', exist_ok=True)
|
7 |
+
|
8 |
+
# List of files to copy and compress
|
9 |
+
files = ['questions.json', 'questions_aux.json']
|
10 |
+
|
11 |
+
for file in files:
|
12 |
+
# Source and destination paths
|
13 |
+
src_path = os.path.join('old_data', file)
|
14 |
+
dst_path = os.path.join('data', file + '.zip')
|
15 |
+
|
16 |
+
# Copy and compress the file
|
17 |
+
with zipfile.ZipFile(dst_path, 'w', zipfile.ZIP_DEFLATED) as zipf:
|
18 |
+
zipf.write(src_path, arcname=file)
|
19 |
+
|
20 |
+
print(f"Copied and compressed {file} to {dst_path}")
|
21 |
+
|
22 |
+
print("All files have been copied and compressed successfully.")
|
data/.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
data/knowledge_questions.json
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:30f2312e1681f964b4e850962ef48c7cb80e79c1e9e2889d80710eb9ca7462e8
|
3 |
-
size 30186420
|
|
|
|
|
|
|
|
data/{rc_questions.json.zip → questions.json.zip}
RENAMED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7e7722c267d44ecc1f9f52d69109116d8a0a352b89f002438585872f67de9985
|
3 |
+
size 986847
|
data/{knowledge_questions.json.zip → questions_aux.json.zip}
RENAMED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:fa4361b1802cbece95210561a8bb97bcbada497a919075ae666a04ac642156dd
|
3 |
+
size 1297687
|
data/rc_questions.json
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:4f6eb35e1b865a6c5cfd0cf73a0b514a86bd1d8306bf6719f2b4fb94793c7e4b
|
3 |
-
size 22753840
|
|
|
|
|
|
|
|
demo.ipynb
CHANGED
@@ -10,7 +10,7 @@
|
|
10 |
"name": "stderr",
|
11 |
"output_type": "stream",
|
12 |
"text": [
|
13 |
-
"/Users/neelguha/miniconda3/lib/python3.
|
14 |
" from .autonotebook import tqdm as notebook_tqdm\n"
|
15 |
]
|
16 |
}
|
@@ -29,10 +29,17 @@
|
|
29 |
},
|
30 |
{
|
31 |
"cell_type": "code",
|
32 |
-
"execution_count":
|
33 |
"id": "2cb75e7c-b7eb-4601-85f3-cc27c1f5ff94",
|
34 |
"metadata": {},
|
35 |
"outputs": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
{
|
37 |
"data": {
|
38 |
"text/html": [
|
@@ -147,14 +154,40 @@
|
|
147 |
"4 Is there a state/territory law regulating resi... [[]] "
|
148 |
]
|
149 |
},
|
150 |
-
"execution_count":
|
151 |
"metadata": {},
|
152 |
"output_type": "execute_result"
|
153 |
}
|
154 |
],
|
155 |
"source": [
|
156 |
-
"questions = load_dataset(\"reglab/housing_qa\", \"knowledge_questions\")\n",
|
157 |
-
"questions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
]
|
159 |
},
|
160 |
{
|
@@ -447,7 +480,7 @@
|
|
447 |
"name": "python",
|
448 |
"nbconvert_exporter": "python",
|
449 |
"pygments_lexer": "ipython3",
|
450 |
-
"version": "3.
|
451 |
}
|
452 |
},
|
453 |
"nbformat": 4,
|
|
|
10 |
"name": "stderr",
|
11 |
"output_type": "stream",
|
12 |
"text": [
|
13 |
+
"/Users/neelguha/miniconda3/envs/judicial-behavior/lib/python3.8/site-packages/tqdm/auto.py:22: 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 |
}
|
|
|
29 |
},
|
30 |
{
|
31 |
"cell_type": "code",
|
32 |
+
"execution_count": 9,
|
33 |
"id": "2cb75e7c-b7eb-4601-85f3-cc27c1f5ff94",
|
34 |
"metadata": {},
|
35 |
"outputs": [
|
36 |
+
{
|
37 |
+
"name": "stderr",
|
38 |
+
"output_type": "stream",
|
39 |
+
"text": [
|
40 |
+
"Found cached dataset housing_qa (/Users/neelguha/.cache/huggingface/datasets/reglab___housing_qa/knowledge_questions/1.0.0/cc9b072f76a495a77b95dea87f9dce53c85bad450eb9ac41c80026e7d4b0f08e)\n"
|
41 |
+
]
|
42 |
+
},
|
43 |
{
|
44 |
"data": {
|
45 |
"text/html": [
|
|
|
154 |
"4 Is there a state/territory law regulating resi... [[]] "
|
155 |
]
|
156 |
},
|
157 |
+
"execution_count": 9,
|
158 |
"metadata": {},
|
159 |
"output_type": "execute_result"
|
160 |
}
|
161 |
],
|
162 |
"source": [
|
163 |
+
"questions = load_dataset(\"reglab/housing_qa\", \"knowledge_questions\", split=\"corpus\")\n",
|
164 |
+
"questions.to_pandas().head(5)"
|
165 |
+
]
|
166 |
+
},
|
167 |
+
{
|
168 |
+
"cell_type": "code",
|
169 |
+
"execution_count": 5,
|
170 |
+
"id": "3931e731-006f-4731-8350-a7f83ea3f298",
|
171 |
+
"metadata": {},
|
172 |
+
"outputs": [
|
173 |
+
{
|
174 |
+
"data": {
|
175 |
+
"text/plain": [
|
176 |
+
"DatasetDict({\n",
|
177 |
+
" corpus: Dataset({\n",
|
178 |
+
" features: ['idx', 'state', 'question', 'answer', 'question_group', 'statutes', 'original_question', 'caveats'],\n",
|
179 |
+
" num_rows: 9297\n",
|
180 |
+
" })\n",
|
181 |
+
"})"
|
182 |
+
]
|
183 |
+
},
|
184 |
+
"execution_count": 5,
|
185 |
+
"metadata": {},
|
186 |
+
"output_type": "execute_result"
|
187 |
+
}
|
188 |
+
],
|
189 |
+
"source": [
|
190 |
+
"questions"
|
191 |
]
|
192 |
},
|
193 |
{
|
|
|
480 |
"name": "python",
|
481 |
"nbconvert_exporter": "python",
|
482 |
"pygments_lexer": "ipython3",
|
483 |
+
"version": "3.8.18"
|
484 |
}
|
485 |
},
|
486 |
"nbformat": 4,
|
housing_qa.py
CHANGED
@@ -10,52 +10,46 @@ _CITATION = """"""
|
|
10 |
_DESCRIPTION = """"""
|
11 |
_HOMEPAGE = ""
|
12 |
_URLS = {
|
13 |
-
"
|
14 |
-
"
|
15 |
"statutes": "data/statutes.tsv.zip",
|
16 |
}
|
17 |
|
18 |
-
|
19 |
-
|
20 |
_CONFIGS = {}
|
21 |
|
22 |
-
_CONFIGS["
|
23 |
-
"description": "
|
24 |
"features": {
|
25 |
"idx": datasets.Value("int32"),
|
26 |
"state": datasets.Value("string"),
|
27 |
"question": datasets.Value("string"),
|
28 |
"answer": datasets.Value("string"),
|
29 |
"question_group": datasets.Value("int32"),
|
30 |
-
"statutes":
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
),
|
36 |
"original_question": datasets.Value("string"),
|
37 |
-
"caveats": datasets.Sequence(
|
38 |
},
|
39 |
"license": None,
|
40 |
}
|
41 |
|
42 |
-
_CONFIGS["
|
43 |
-
"description": "
|
44 |
"features": {
|
45 |
"idx": datasets.Value("int32"),
|
46 |
"state": datasets.Value("string"),
|
47 |
"question": datasets.Value("string"),
|
48 |
"answer": datasets.Value("string"),
|
49 |
"question_group": datasets.Value("int32"),
|
50 |
-
"statutes":
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
"excerpt": datasets.Value("string"),
|
55 |
-
}
|
56 |
-
),
|
57 |
"original_question": datasets.Value("string"),
|
58 |
-
"caveats": datasets.Sequence(
|
59 |
},
|
60 |
"license": None,
|
61 |
}
|
@@ -98,7 +92,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="corpus",
|
102 |
gen_kwargs={
|
103 |
"downloaded_file_dir": downloaded_file_dir,
|
104 |
"name": self.config.name,
|
@@ -109,13 +103,7 @@ class HousingQA(datasets.GeneratorBasedBuilder):
|
|
109 |
def _generate_examples(self, downloaded_file_dir, name):
|
110 |
"""Yields examples as (key, example) tuples."""
|
111 |
|
112 |
-
if name in ["
|
113 |
-
fpath = downloaded_file_dir / f"{name}.json"
|
114 |
-
data = json.loads(fpath.read_text())
|
115 |
-
for id_line, data in enumerate(data):
|
116 |
-
yield id_line, data
|
117 |
-
|
118 |
-
if name in ["rc_questions"]:
|
119 |
fpath = downloaded_file_dir / f"{name}.json"
|
120 |
data = json.loads(fpath.read_text())
|
121 |
for id_line, data in enumerate(data):
|
|
|
10 |
_DESCRIPTION = """"""
|
11 |
_HOMEPAGE = ""
|
12 |
_URLS = {
|
13 |
+
"questions": "data/questions.json.zip",
|
14 |
+
"questions_aux": "data/questions_aux.json.zip",
|
15 |
"statutes": "data/statutes.tsv.zip",
|
16 |
}
|
17 |
|
|
|
|
|
18 |
_CONFIGS = {}
|
19 |
|
20 |
+
_CONFIGS["questions"] = {
|
21 |
+
"description": "Questions about housing law.",
|
22 |
"features": {
|
23 |
"idx": datasets.Value("int32"),
|
24 |
"state": datasets.Value("string"),
|
25 |
"question": datasets.Value("string"),
|
26 |
"answer": datasets.Value("string"),
|
27 |
"question_group": datasets.Value("int32"),
|
28 |
+
"statutes": {
|
29 |
+
"statute_idx": datasets.Sequence(datasets.Value("int32")),
|
30 |
+
"citation": datasets.Sequence(datasets.Value("string")),
|
31 |
+
"excerpt": datasets.Sequence(datasets.Value("string")),
|
32 |
+
},
|
|
|
33 |
"original_question": datasets.Value("string"),
|
34 |
+
"caveats": datasets.Sequence(datasets.Value("string")),
|
35 |
},
|
36 |
"license": None,
|
37 |
}
|
38 |
|
39 |
+
_CONFIGS["questions_aux"] = {
|
40 |
+
"description": "An auxilliary set of larger questions about housing law, without statutory annotations.",
|
41 |
"features": {
|
42 |
"idx": datasets.Value("int32"),
|
43 |
"state": datasets.Value("string"),
|
44 |
"question": datasets.Value("string"),
|
45 |
"answer": datasets.Value("string"),
|
46 |
"question_group": datasets.Value("int32"),
|
47 |
+
"statutes": {
|
48 |
+
"citation": datasets.Sequence(datasets.Value("string")),
|
49 |
+
"excerpt": datasets.Sequence(datasets.Value("string")),
|
50 |
+
},
|
|
|
|
|
|
|
51 |
"original_question": datasets.Value("string"),
|
52 |
+
"caveats": datasets.Sequence(datasets.Value("string")),
|
53 |
},
|
54 |
"license": None,
|
55 |
}
|
|
|
92 |
downloaded_file_dir = Path(dl_manager.download_and_extract(_URLS[self.config.name]))
|
93 |
return [
|
94 |
datasets.SplitGenerator(
|
95 |
+
name="corpus" if self.config.name == "statutes" else "test",
|
96 |
gen_kwargs={
|
97 |
"downloaded_file_dir": downloaded_file_dir,
|
98 |
"name": self.config.name,
|
|
|
103 |
def _generate_examples(self, downloaded_file_dir, name):
|
104 |
"""Yields examples as (key, example) tuples."""
|
105 |
|
106 |
+
if name in ["questions", "questions_aux"]:
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
fpath = downloaded_file_dir / f"{name}.json"
|
108 |
data = json.loads(fpath.read_text())
|
109 |
for id_line, data in enumerate(data):
|
statistics.ipynb
ADDED
@@ -0,0 +1,332 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 15,
|
6 |
+
"id": "fce498ac-4ea7-4e10-a15a-60ac41e3adce",
|
7 |
+
"metadata": {},
|
8 |
+
"outputs": [],
|
9 |
+
"source": [
|
10 |
+
"from datasets import load_dataset\n",
|
11 |
+
"from collections import Counter"
|
12 |
+
]
|
13 |
+
},
|
14 |
+
{
|
15 |
+
"cell_type": "code",
|
16 |
+
"execution_count": 7,
|
17 |
+
"id": "73aaafd1-3ebb-42f7-b162-2e6bc630d195",
|
18 |
+
"metadata": {},
|
19 |
+
"outputs": [
|
20 |
+
{
|
21 |
+
"name": "stdout",
|
22 |
+
"output_type": "stream",
|
23 |
+
"text": [
|
24 |
+
"Downloading and preparing dataset housing_qa/rc_questions to /Users/neelguha/.cache/huggingface/datasets/reglab___housing_qa/rc_questions/1.0.0/cc9b072f76a495a77b95dea87f9dce53c85bad450eb9ac41c80026e7d4b0f08e...\n"
|
25 |
+
]
|
26 |
+
},
|
27 |
+
{
|
28 |
+
"name": "stderr",
|
29 |
+
"output_type": "stream",
|
30 |
+
"text": [
|
31 |
+
" \r"
|
32 |
+
]
|
33 |
+
},
|
34 |
+
{
|
35 |
+
"name": "stdout",
|
36 |
+
"output_type": "stream",
|
37 |
+
"text": [
|
38 |
+
"Dataset housing_qa downloaded and prepared to /Users/neelguha/.cache/huggingface/datasets/reglab___housing_qa/rc_questions/1.0.0/cc9b072f76a495a77b95dea87f9dce53c85bad450eb9ac41c80026e7d4b0f08e. Subsequent calls will reuse this data.\n"
|
39 |
+
]
|
40 |
+
},
|
41 |
+
{
|
42 |
+
"data": {
|
43 |
+
"text/plain": [
|
44 |
+
"{'idx': 0,\n",
|
45 |
+
" 'state': 'Alabama',\n",
|
46 |
+
" 'question': 'Is there a state/territory law regulating residential evictions?',\n",
|
47 |
+
" 'answer': 'Yes',\n",
|
48 |
+
" 'question_group': 69,\n",
|
49 |
+
" 'statutes': {'statute_idx': [431263],\n",
|
50 |
+
" 'citation': ['ALA. CODE § 35-9A-141(11)'],\n",
|
51 |
+
" 'excerpt': ['(11) “premises” means a dwelling unit and the structure of which it is a part and facilities and appurtenances therein and grounds, areas, and facilities held out for the use of tenants generally or whose use is promised by the rental agreement to the tenant;']},\n",
|
52 |
+
" 'original_question': 'Is there a state/territory law regulating residential evictions?',\n",
|
53 |
+
" 'caveats': [[]]}"
|
54 |
+
]
|
55 |
+
},
|
56 |
+
"execution_count": 7,
|
57 |
+
"metadata": {},
|
58 |
+
"output_type": "execute_result"
|
59 |
+
}
|
60 |
+
],
|
61 |
+
"source": [
|
62 |
+
"questions = load_dataset(\"reglab/housing_qa\", \"rc_questions\", split=\"corpus\")\n",
|
63 |
+
"questions[0]"
|
64 |
+
]
|
65 |
+
},
|
66 |
+
{
|
67 |
+
"cell_type": "code",
|
68 |
+
"execution_count": 18,
|
69 |
+
"id": "c28a88fe-933f-424c-9b81-fc43eea34dee",
|
70 |
+
"metadata": {},
|
71 |
+
"outputs": [],
|
72 |
+
"source": [
|
73 |
+
"counts = []\n",
|
74 |
+
"for sample in questions: \n",
|
75 |
+
" if len(sample[\"caveats\"][0]) > 0:\n",
|
76 |
+
" break "
|
77 |
+
]
|
78 |
+
},
|
79 |
+
{
|
80 |
+
"cell_type": "code",
|
81 |
+
"execution_count": 19,
|
82 |
+
"id": "2c24819e-0019-4c60-9284-77bfa565ecc5",
|
83 |
+
"metadata": {},
|
84 |
+
"outputs": [
|
85 |
+
{
|
86 |
+
"data": {
|
87 |
+
"text/plain": [
|
88 |
+
"{'idx': 353,\n",
|
89 |
+
" 'state': 'Alabama',\n",
|
90 |
+
" 'question': 'Is it specified whether a landlord waives their right to evict for nonpayment of rent by accepting partial payment of rent?',\n",
|
91 |
+
" 'answer': 'Yes',\n",
|
92 |
+
" 'question_group': 201,\n",
|
93 |
+
" 'statutes': {'statute_idx': [431280],\n",
|
94 |
+
" 'citation': ['ALA. CODE § 35-9A-424'],\n",
|
95 |
+
" 'excerpt': [\"Acceptance of rent with knowledge of a default by the tenant or acceptance of performance by the tenant that varies from the terms of the rental agreement constitutes a waiver of the landlord's right to terminate the rental agreement for that breach, unless otherwise agreed after the breach has occurred.\"]},\n",
|
96 |
+
" 'original_question': 'Does a landlord waive their right to evict for nonpayment of rent by accepting partial payment of rent?',\n",
|
97 |
+
" 'caveats': [['A',\n",
|
98 |
+
" ' ',\n",
|
99 |
+
" 'l',\n",
|
100 |
+
" 'a',\n",
|
101 |
+
" 'n',\n",
|
102 |
+
" 'd',\n",
|
103 |
+
" 'l',\n",
|
104 |
+
" 'o',\n",
|
105 |
+
" 'r',\n",
|
106 |
+
" 'd',\n",
|
107 |
+
" ' ',\n",
|
108 |
+
" 'w',\n",
|
109 |
+
" 'a',\n",
|
110 |
+
" 'i',\n",
|
111 |
+
" 'v',\n",
|
112 |
+
" 'e',\n",
|
113 |
+
" 's',\n",
|
114 |
+
" ' ',\n",
|
115 |
+
" 't',\n",
|
116 |
+
" 'h',\n",
|
117 |
+
" 'e',\n",
|
118 |
+
" 'i',\n",
|
119 |
+
" 'r',\n",
|
120 |
+
" ' ',\n",
|
121 |
+
" 'r',\n",
|
122 |
+
" 'i',\n",
|
123 |
+
" 'g',\n",
|
124 |
+
" 'h',\n",
|
125 |
+
" 't',\n",
|
126 |
+
" ' ',\n",
|
127 |
+
" 't',\n",
|
128 |
+
" 'o',\n",
|
129 |
+
" ' ',\n",
|
130 |
+
" 'e',\n",
|
131 |
+
" 'v',\n",
|
132 |
+
" 'i',\n",
|
133 |
+
" 'c',\n",
|
134 |
+
" 't',\n",
|
135 |
+
" ' ',\n",
|
136 |
+
" 'b',\n",
|
137 |
+
" 'y',\n",
|
138 |
+
" ' ',\n",
|
139 |
+
" 'a',\n",
|
140 |
+
" 'c',\n",
|
141 |
+
" 'c',\n",
|
142 |
+
" 'e',\n",
|
143 |
+
" 'p',\n",
|
144 |
+
" 't',\n",
|
145 |
+
" 'i',\n",
|
146 |
+
" 'n',\n",
|
147 |
+
" 'g',\n",
|
148 |
+
" ' ',\n",
|
149 |
+
" 'p',\n",
|
150 |
+
" 'a',\n",
|
151 |
+
" 'y',\n",
|
152 |
+
" 'm',\n",
|
153 |
+
" 'e',\n",
|
154 |
+
" 'n',\n",
|
155 |
+
" 't',\n",
|
156 |
+
" ' ',\n",
|
157 |
+
" 'o',\n",
|
158 |
+
" 'f',\n",
|
159 |
+
" ' ',\n",
|
160 |
+
" 'r',\n",
|
161 |
+
" 'e',\n",
|
162 |
+
" 'n',\n",
|
163 |
+
" 't',\n",
|
164 |
+
" ',',\n",
|
165 |
+
" ' ',\n",
|
166 |
+
" 'A',\n",
|
167 |
+
" 'l',\n",
|
168 |
+
" 'a',\n",
|
169 |
+
" '.',\n",
|
170 |
+
" ' ',\n",
|
171 |
+
" 'C',\n",
|
172 |
+
" 'o',\n",
|
173 |
+
" 'd',\n",
|
174 |
+
" 'e',\n",
|
175 |
+
" ' ',\n",
|
176 |
+
" '§',\n",
|
177 |
+
" ' ',\n",
|
178 |
+
" '3',\n",
|
179 |
+
" '5',\n",
|
180 |
+
" '-',\n",
|
181 |
+
" '9',\n",
|
182 |
+
" 'A',\n",
|
183 |
+
" '-',\n",
|
184 |
+
" '4',\n",
|
185 |
+
" '2',\n",
|
186 |
+
" '4',\n",
|
187 |
+
" ',',\n",
|
188 |
+
" ' ',\n",
|
189 |
+
" 'b',\n",
|
190 |
+
" 'u',\n",
|
191 |
+
" 't',\n",
|
192 |
+
" ' ',\n",
|
193 |
+
" 't',\n",
|
194 |
+
" 'h',\n",
|
195 |
+
" 'e',\n",
|
196 |
+
" ' ',\n",
|
197 |
+
" 'l',\n",
|
198 |
+
" 'a',\n",
|
199 |
+
" 'w',\n",
|
200 |
+
" ' ',\n",
|
201 |
+
" 'd',\n",
|
202 |
+
" 'o',\n",
|
203 |
+
" 'e',\n",
|
204 |
+
" 's',\n",
|
205 |
+
" ' ',\n",
|
206 |
+
" 'n',\n",
|
207 |
+
" 'o',\n",
|
208 |
+
" 't',\n",
|
209 |
+
" ' ',\n",
|
210 |
+
" 's',\n",
|
211 |
+
" 'p',\n",
|
212 |
+
" 'e',\n",
|
213 |
+
" 'c',\n",
|
214 |
+
" 'i',\n",
|
215 |
+
" 'f',\n",
|
216 |
+
" 'y',\n",
|
217 |
+
" ' ',\n",
|
218 |
+
" 'w',\n",
|
219 |
+
" 'h',\n",
|
220 |
+
" 'e',\n",
|
221 |
+
" 't',\n",
|
222 |
+
" 'h',\n",
|
223 |
+
" 'e',\n",
|
224 |
+
" 'r',\n",
|
225 |
+
" ' ',\n",
|
226 |
+
" 'a',\n",
|
227 |
+
" 'c',\n",
|
228 |
+
" 'c',\n",
|
229 |
+
" 'e',\n",
|
230 |
+
" 'p',\n",
|
231 |
+
" 't',\n",
|
232 |
+
" 'a',\n",
|
233 |
+
" 'n',\n",
|
234 |
+
" 'c',\n",
|
235 |
+
" 'e',\n",
|
236 |
+
" ' ',\n",
|
237 |
+
" 'o',\n",
|
238 |
+
" 'f',\n",
|
239 |
+
" ' ',\n",
|
240 |
+
" 'f',\n",
|
241 |
+
" 'u',\n",
|
242 |
+
" 'l',\n",
|
243 |
+
" 'l',\n",
|
244 |
+
" ' ',\n",
|
245 |
+
" 'o',\n",
|
246 |
+
" 'r',\n",
|
247 |
+
" ' ',\n",
|
248 |
+
" 'p',\n",
|
249 |
+
" 'a',\n",
|
250 |
+
" 'r',\n",
|
251 |
+
" 't',\n",
|
252 |
+
" 'i',\n",
|
253 |
+
" 'a',\n",
|
254 |
+
" 'l',\n",
|
255 |
+
" ' ',\n",
|
256 |
+
" 'p',\n",
|
257 |
+
" 'a',\n",
|
258 |
+
" 'y',\n",
|
259 |
+
" 'm',\n",
|
260 |
+
" 'e',\n",
|
261 |
+
" 'n',\n",
|
262 |
+
" 't',\n",
|
263 |
+
" ' ',\n",
|
264 |
+
" 'i',\n",
|
265 |
+
" 's',\n",
|
266 |
+
" ' ',\n",
|
267 |
+
" 'r',\n",
|
268 |
+
" 'e',\n",
|
269 |
+
" 'q',\n",
|
270 |
+
" 'u',\n",
|
271 |
+
" 'i',\n",
|
272 |
+
" 'r',\n",
|
273 |
+
" 'e',\n",
|
274 |
+
" 'd',\n",
|
275 |
+
" ' ',\n",
|
276 |
+
" 'f',\n",
|
277 |
+
" 'o',\n",
|
278 |
+
" 'r',\n",
|
279 |
+
" ' ',\n",
|
280 |
+
" 't',\n",
|
281 |
+
" 'h',\n",
|
282 |
+
" 'e',\n",
|
283 |
+
" ' ',\n",
|
284 |
+
" 'w',\n",
|
285 |
+
" 'a',\n",
|
286 |
+
" 'i',\n",
|
287 |
+
" 'v',\n",
|
288 |
+
" 'e',\n",
|
289 |
+
" 'r',\n",
|
290 |
+
" '.']]}"
|
291 |
+
]
|
292 |
+
},
|
293 |
+
"execution_count": 19,
|
294 |
+
"metadata": {},
|
295 |
+
"output_type": "execute_result"
|
296 |
+
}
|
297 |
+
],
|
298 |
+
"source": [
|
299 |
+
"sample"
|
300 |
+
]
|
301 |
+
},
|
302 |
+
{
|
303 |
+
"cell_type": "code",
|
304 |
+
"execution_count": null,
|
305 |
+
"id": "893dbd5a-e351-43a9-b939-ed022a78b78a",
|
306 |
+
"metadata": {},
|
307 |
+
"outputs": [],
|
308 |
+
"source": []
|
309 |
+
}
|
310 |
+
],
|
311 |
+
"metadata": {
|
312 |
+
"kernelspec": {
|
313 |
+
"display_name": "Python 3 (ipykernel)",
|
314 |
+
"language": "python",
|
315 |
+
"name": "python3"
|
316 |
+
},
|
317 |
+
"language_info": {
|
318 |
+
"codemirror_mode": {
|
319 |
+
"name": "ipython",
|
320 |
+
"version": 3
|
321 |
+
},
|
322 |
+
"file_extension": ".py",
|
323 |
+
"mimetype": "text/x-python",
|
324 |
+
"name": "python",
|
325 |
+
"nbconvert_exporter": "python",
|
326 |
+
"pygments_lexer": "ipython3",
|
327 |
+
"version": "3.8.18"
|
328 |
+
}
|
329 |
+
},
|
330 |
+
"nbformat": 4,
|
331 |
+
"nbformat_minor": 5
|
332 |
+
}
|