Datasets:
Changed data
Browse files- demo.ipynb +27 -16
- housing_qa.py +24 -25
- statistics.ipynb +55 -63
demo.ipynb
CHANGED
@@ -20,7 +20,7 @@
|
|
20 |
},
|
21 |
{
|
22 |
"cell_type": "code",
|
23 |
-
"execution_count":
|
24 |
"id": "2cb75e7c-b7eb-4601-85f3-cc27c1f5ff94",
|
25 |
"metadata": {},
|
26 |
"outputs": [
|
@@ -28,21 +28,21 @@
|
|
28 |
"name": "stderr",
|
29 |
"output_type": "stream",
|
30 |
"text": [
|
31 |
-
"Downloading builder script: 100%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 3.
|
32 |
]
|
33 |
},
|
34 |
{
|
35 |
"name": "stdout",
|
36 |
"output_type": "stream",
|
37 |
"text": [
|
38 |
-
"Downloading and preparing dataset housing_qa/questions (download: 963.72 KiB, generated: 18.27 MiB, post-processed: Unknown size, total: 19.21 MiB) to /Users/neelguha/.cache/huggingface/datasets/reglab___housing_qa/questions/1.0.0/
|
39 |
]
|
40 |
},
|
41 |
{
|
42 |
"name": "stderr",
|
43 |
"output_type": "stream",
|
44 |
"text": [
|
45 |
-
"Downloading data: 100%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 987k/987k [00:00<00:00,
|
46 |
" \r"
|
47 |
]
|
48 |
},
|
@@ -50,7 +50,7 @@
|
|
50 |
"name": "stdout",
|
51 |
"output_type": "stream",
|
52 |
"text": [
|
53 |
-
"Dataset housing_qa downloaded and prepared to /Users/neelguha/.cache/huggingface/datasets/reglab___housing_qa/questions/1.0.0/
|
54 |
]
|
55 |
},
|
56 |
{
|
@@ -174,7 +174,7 @@
|
|
174 |
"4 [A landlord waives their right to evict by acc... "
|
175 |
]
|
176 |
},
|
177 |
-
"execution_count":
|
178 |
"metadata": {},
|
179 |
"output_type": "execute_result"
|
180 |
}
|
@@ -186,32 +186,43 @@
|
|
186 |
},
|
187 |
{
|
188 |
"cell_type": "code",
|
189 |
-
"execution_count":
|
190 |
"id": "3931e731-006f-4731-8350-a7f83ea3f298",
|
191 |
"metadata": {},
|
192 |
"outputs": [
|
193 |
{
|
194 |
"data": {
|
195 |
"text/plain": [
|
196 |
-
"{'idx':
|
197 |
" 'state': 'Alabama',\n",
|
198 |
-
" 'question': '
|
199 |
" 'answer': 'Yes',\n",
|
200 |
-
" 'question_group':
|
201 |
-
" 'statutes': {'statute_idx': [
|
202 |
-
" 'citation': ['ALA. CODE Β§ 35-9A-
|
203 |
-
"
|
204 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
" 'caveats': ['']}"
|
206 |
]
|
207 |
},
|
208 |
-
"execution_count":
|
209 |
"metadata": {},
|
210 |
"output_type": "execute_result"
|
211 |
}
|
212 |
],
|
213 |
"source": [
|
214 |
-
"questions
|
|
|
|
|
|
|
215 |
]
|
216 |
},
|
217 |
{
|
|
|
20 |
},
|
21 |
{
|
22 |
"cell_type": "code",
|
23 |
+
"execution_count": 28,
|
24 |
"id": "2cb75e7c-b7eb-4601-85f3-cc27c1f5ff94",
|
25 |
"metadata": {},
|
26 |
"outputs": [
|
|
|
28 |
"name": "stderr",
|
29 |
"output_type": "stream",
|
30 |
"text": [
|
31 |
+
"Downloading builder script: 100%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 3.67k/3.67k [00:00<00:00, 11.9MB/s]\n"
|
32 |
]
|
33 |
},
|
34 |
{
|
35 |
"name": "stdout",
|
36 |
"output_type": "stream",
|
37 |
"text": [
|
38 |
+
"Downloading and preparing dataset housing_qa/questions (download: 963.72 KiB, generated: 18.27 MiB, post-processed: Unknown size, total: 19.21 MiB) to /Users/neelguha/.cache/huggingface/datasets/reglab___housing_qa/questions/1.0.0/72d4d5c21c6043dceebcc4cb378b5258ba6b3c0db013d32c0627b85a4c6f50bc...\n"
|
39 |
]
|
40 |
},
|
41 |
{
|
42 |
"name": "stderr",
|
43 |
"output_type": "stream",
|
44 |
"text": [
|
45 |
+
"Downloading data: 100%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 987k/987k [00:00<00:00, 7.34MB/s]\n",
|
46 |
" \r"
|
47 |
]
|
48 |
},
|
|
|
50 |
"name": "stdout",
|
51 |
"output_type": "stream",
|
52 |
"text": [
|
53 |
+
"Dataset housing_qa downloaded and prepared to /Users/neelguha/.cache/huggingface/datasets/reglab___housing_qa/questions/1.0.0/72d4d5c21c6043dceebcc4cb378b5258ba6b3c0db013d32c0627b85a4c6f50bc. Subsequent calls will reuse this data.\n"
|
54 |
]
|
55 |
},
|
56 |
{
|
|
|
174 |
"4 [A landlord waives their right to evict by acc... "
|
175 |
]
|
176 |
},
|
177 |
+
"execution_count": 28,
|
178 |
"metadata": {},
|
179 |
"output_type": "execute_result"
|
180 |
}
|
|
|
186 |
},
|
187 |
{
|
188 |
"cell_type": "code",
|
189 |
+
"execution_count": 30,
|
190 |
"id": "3931e731-006f-4731-8350-a7f83ea3f298",
|
191 |
"metadata": {},
|
192 |
"outputs": [
|
193 |
{
|
194 |
"data": {
|
195 |
"text/plain": [
|
196 |
+
"{'idx': 237,\n",
|
197 |
" 'state': 'Alabama',\n",
|
198 |
+
" 'question': 'Does the law specify rebuttals available to tenants subject to eviction proceedings?',\n",
|
199 |
" 'answer': 'Yes',\n",
|
200 |
+
" 'question_group': 116,\n",
|
201 |
+
" 'statutes': {'statute_idx': [417060, 431274, 431280, 431273, 431271],\n",
|
202 |
+
" 'citation': ['ALA. CODE Β§ 35-9A-501(B)',\n",
|
203 |
+
" 'ALA. CODE Β§ 35-9A-405(A)',\n",
|
204 |
+
" 'ALA. CODE Β§ 35-9A-424',\n",
|
205 |
+
" 'ALA. CODE Β§ 35-9A-404(B)',\n",
|
206 |
+
" 'ALA. CODE Β§ 35-9A-401(A)'],\n",
|
207 |
+
" 'excerpt': ['(b) If a landlord acts in violation of subsection (a), the tenant is entitled to the remedies provided in Section 35-9A-407 and has a defense in any retaliatory action against the tenant for possession.',\n",
|
208 |
+
" \"(a) In an action for possession or in an action for rent when the tenant is in possession, the tenant may counterclaim for any amount the tenant may recover under the rental agreement or this chapter. It is in the court's discretion whether the tenant is to remain in possession. The tenant shall pay into court rent accrued and thereafter accruing as it comes due. The court shall determine the amount due to each party. The party to whom a net amount is owed shall be paid first from the money paid into court, and the balance by the other party. If no rent remains due after application of this section, judgment shall be entered for the tenant in the action for possession. If the defense or counterclaim by the tenant is without merit and is not raised in good faith, the landlord may recover reasonable attorney's fees.\",\n",
|
209 |
+
" \"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",
|
210 |
+
" '(b) If contrary to the rental agreement or Section 35-9A-204, after receiving notice of the breach from the tenant, the landlord willfully or negligently fails to promptly make available heat, running water, hot water, electric, gas, or other essential service, the tenant may:(1) send a written notice specifying the date of termination not less than 14 days after receipt of notice and upon vacation of the premises, the rental agreement shall be rightfully terminated without further obligation or penalty. If the rental agreement is terminated pursuant to this section, the landlord shall return all security recoverable by the tenant under Section 35-9A-201 and all unearned prepaid rent; or(2) recover damages based upon the diminution in the fair rental value of the dwelling unit.',\n",
|
211 |
+
" '(a) Except as provided in this chapter, if there is a material noncompliance by the landlord with the rental agreement or a noncompliance with Section 35-9A-204 materially affecting health and safety, the tenant may deliver a written notice to the landlord specifying the acts and omissions constituting the breach and that the rental agreement will terminate upon a date not less than 14 days after receipt of the notice if the breach is not remedied within that period, and the rental agreement shall terminate as provided in the notice subject to the following:']},\n",
|
212 |
+
" 'original_question': 'Does the law specify rebuttals available to a tenant?',\n",
|
213 |
" 'caveats': ['']}"
|
214 |
]
|
215 |
},
|
216 |
+
"execution_count": 30,
|
217 |
"metadata": {},
|
218 |
"output_type": "execute_result"
|
219 |
}
|
220 |
],
|
221 |
"source": [
|
222 |
+
"for q in questions:\n",
|
223 |
+
" if len(q[\"statutes\"][\"citation\"]) > 1:\n",
|
224 |
+
" break \n",
|
225 |
+
"q"
|
226 |
]
|
227 |
},
|
228 |
{
|
housing_qa.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import csv
|
2 |
|
3 |
import datasets
|
4 |
-
from datasets import Features, Value, Sequence,
|
5 |
import json
|
6 |
from io import StringIO
|
7 |
from pathlib import Path
|
@@ -20,38 +20,37 @@ _CONFIGS = {}
|
|
20 |
|
21 |
_CONFIGS["questions"] = {
|
22 |
"description": "Questions about housing law.",
|
23 |
-
"features": Features({
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
}),
|
34 |
-
|
35 |
-
|
36 |
}),
|
37 |
"license": None,
|
38 |
-
"license": None,
|
39 |
}
|
40 |
|
41 |
_CONFIGS["questions_aux"] = {
|
42 |
"description": "An auxilliary set of larger questions about housing law, without statutory annotations.",
|
43 |
-
"features": Features({
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
}),
|
53 |
-
|
54 |
-
|
55 |
}),
|
56 |
"license": None,
|
57 |
}
|
|
|
1 |
import csv
|
2 |
|
3 |
import datasets
|
4 |
+
from datasets import Dataset, DatasetInfo, Features, ClassLabel, Value, Sequence, DatasetDict
|
5 |
import json
|
6 |
from io import StringIO
|
7 |
from pathlib import Path
|
|
|
20 |
|
21 |
_CONFIGS["questions"] = {
|
22 |
"description": "Questions about housing law.",
|
23 |
+
"features" : Features({
|
24 |
+
'idx': Value('int32'),
|
25 |
+
'state': Value('string'),
|
26 |
+
'question': Value('string'),
|
27 |
+
'answer': Value('string'),
|
28 |
+
'question_group': Value('int32'),
|
29 |
+
'statutes': Sequence({
|
30 |
+
'statute_idx': Value('int32'),
|
31 |
+
'citation': Value('string'),
|
32 |
+
'excerpt': Value('string'),
|
33 |
}),
|
34 |
+
'original_question': Value('string'),
|
35 |
+
'caveats': Sequence(Value('string')),
|
36 |
}),
|
37 |
"license": None,
|
|
|
38 |
}
|
39 |
|
40 |
_CONFIGS["questions_aux"] = {
|
41 |
"description": "An auxilliary set of larger questions about housing law, without statutory annotations.",
|
42 |
+
"features" : Features({
|
43 |
+
'idx': Value('int32'),
|
44 |
+
'state': Value('string'),
|
45 |
+
'question': Value('string'),
|
46 |
+
'answer': Value('string'),
|
47 |
+
'question_group': Value('int32'),
|
48 |
+
'statutes': Sequence({
|
49 |
+
'citation': Value('string'),
|
50 |
+
'excerpt': Value('string'),
|
51 |
}),
|
52 |
+
'original_question': Value('string'),
|
53 |
+
'caveats': Sequence(Value('string')),
|
54 |
}),
|
55 |
"license": None,
|
56 |
}
|
statistics.ipynb
CHANGED
@@ -2,28 +2,64 @@
|
|
2 |
"cells": [
|
3 |
{
|
4 |
"cell_type": "code",
|
5 |
-
"execution_count":
|
6 |
-
"id": "
|
7 |
"metadata": {},
|
8 |
"outputs": [],
|
9 |
"source": [
|
10 |
-
"from datasets import
|
11 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
]
|
13 |
},
|
14 |
{
|
15 |
"cell_type": "code",
|
16 |
-
"execution_count":
|
17 |
-
"id": "
|
18 |
"metadata": {},
|
19 |
"outputs": [
|
20 |
-
{
|
21 |
-
"name": "stderr",
|
22 |
-
"output_type": "stream",
|
23 |
-
"text": [
|
24 |
-
"Found cached dataset housing_qa (/Users/neelguha/.cache/huggingface/datasets/reglab___housing_qa/questions/1.0.0/c3f397c8b54111729d49ff66d6145d407a535b137643491f86e3dc7b858cf34a)\n"
|
25 |
-
]
|
26 |
-
},
|
27 |
{
|
28 |
"data": {
|
29 |
"text/plain": [
|
@@ -32,70 +68,26 @@
|
|
32 |
" 'question': 'Is there a state/territory law regulating residential evictions?',\n",
|
33 |
" 'answer': 'Yes',\n",
|
34 |
" 'question_group': 69,\n",
|
35 |
-
" 'statutes': {'
|
36 |
-
"
|
37 |
-
"
|
38 |
" 'original_question': 'Is there a state/territory law regulating residential evictions?',\n",
|
39 |
" 'caveats': ['']}"
|
40 |
]
|
41 |
},
|
42 |
-
"execution_count":
|
43 |
-
"metadata": {},
|
44 |
-
"output_type": "execute_result"
|
45 |
-
}
|
46 |
-
],
|
47 |
-
"source": [
|
48 |
-
"questions = load_dataset(\"reglab/housing_qa\", \"questions\", split=\"test\")\n",
|
49 |
-
"questions[0]"
|
50 |
-
]
|
51 |
-
},
|
52 |
-
{
|
53 |
-
"cell_type": "code",
|
54 |
-
"execution_count": 24,
|
55 |
-
"id": "c28a88fe-933f-424c-9b81-fc43eea34dee",
|
56 |
-
"metadata": {},
|
57 |
-
"outputs": [],
|
58 |
-
"source": [
|
59 |
-
"counts = []\n",
|
60 |
-
"for sample in questions: \n",
|
61 |
-
" if len(sample[\"caveats\"][0]) > 0:\n",
|
62 |
-
" break "
|
63 |
-
]
|
64 |
-
},
|
65 |
-
{
|
66 |
-
"cell_type": "code",
|
67 |
-
"execution_count": 25,
|
68 |
-
"id": "2c24819e-0019-4c60-9284-77bfa565ecc5",
|
69 |
-
"metadata": {},
|
70 |
-
"outputs": [
|
71 |
-
{
|
72 |
-
"data": {
|
73 |
-
"text/plain": [
|
74 |
-
"{'idx': 353,\n",
|
75 |
-
" 'state': 'Alabama',\n",
|
76 |
-
" 'question': 'Is it specified whether a landlord waives their right to evict for nonpayment of rent by accepting partial payment of rent?',\n",
|
77 |
-
" 'answer': 'Yes',\n",
|
78 |
-
" 'question_group': 201,\n",
|
79 |
-
" 'statutes': {'statute_idx': [431280],\n",
|
80 |
-
" 'citation': ['ALA. CODE Β§ 35-9A-424'],\n",
|
81 |
-
" '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",
|
82 |
-
" 'original_question': 'Does a landlord waive their right to evict for nonpayment of rent by accepting partial payment of rent?',\n",
|
83 |
-
" 'caveats': ['A landlord waives their right to evict by accepting payment of rent, Ala. Code Β§ 35-9A-424, but the law does not specify whether acceptance of full or partial payment is required for the waiver.']}"
|
84 |
-
]
|
85 |
-
},
|
86 |
-
"execution_count": 25,
|
87 |
"metadata": {},
|
88 |
"output_type": "execute_result"
|
89 |
}
|
90 |
],
|
91 |
"source": [
|
92 |
-
"
|
93 |
]
|
94 |
},
|
95 |
{
|
96 |
"cell_type": "code",
|
97 |
"execution_count": null,
|
98 |
-
"id": "
|
99 |
"metadata": {},
|
100 |
"outputs": [],
|
101 |
"source": []
|
|
|
2 |
"cells": [
|
3 |
{
|
4 |
"cell_type": "code",
|
5 |
+
"execution_count": 26,
|
6 |
+
"id": "2c24819e-0019-4c60-9284-77bfa565ecc5",
|
7 |
"metadata": {},
|
8 |
"outputs": [],
|
9 |
"source": [
|
10 |
+
"from datasets import Dataset, DatasetInfo, Features, ClassLabel, Value, Sequence, DatasetDict\n",
|
11 |
+
"\n",
|
12 |
+
"# Define the dataset's schema\n",
|
13 |
+
"features = Features({\n",
|
14 |
+
" 'idx': Value('int32'),\n",
|
15 |
+
" 'state': Value('string'),\n",
|
16 |
+
" 'question': Value('string'),\n",
|
17 |
+
" 'answer': Value('string'),\n",
|
18 |
+
" 'question_group': Value('int32'),\n",
|
19 |
+
" 'statutes': Sequence({\n",
|
20 |
+
" 'statute_idx': Value('int32'),\n",
|
21 |
+
" 'citation': Value('string'),\n",
|
22 |
+
" 'excerpt': Value('string'),\n",
|
23 |
+
" }),\n",
|
24 |
+
" 'original_question': Value('string'),\n",
|
25 |
+
" 'caveats': Sequence(Value('string')),\n",
|
26 |
+
"})\n",
|
27 |
+
"\n",
|
28 |
+
"# Create a DatasetInfo object for additional metadata\n",
|
29 |
+
"dataset_info = DatasetInfo(\n",
|
30 |
+
" description=\"A dataset containing information on state/territory laws regulating residential evictions, including relevant legal statutes.\",\n",
|
31 |
+
" features=features,\n",
|
32 |
+
" supervised_keys=None, # No supervised keys as this dataset doesn't include labels for training models\n",
|
33 |
+
" homepage=\"http://example.com\", # Add a real homepage if applicable\n",
|
34 |
+
" citation=\"Citation information for the dataset\",\n",
|
35 |
+
")\n",
|
36 |
+
"\n",
|
37 |
+
"# Load dataset from your data source\n",
|
38 |
+
"# Assuming your data is in JSON or other format, use appropriate loading function\n",
|
39 |
+
"dataset = DatasetDict({\n",
|
40 |
+
" 'train': Dataset.from_dict({\n",
|
41 |
+
" 'idx': [0],\n",
|
42 |
+
" 'state': ['Alabama'],\n",
|
43 |
+
" 'question': ['Is there a state/territory law regulating residential evictions?'],\n",
|
44 |
+
" 'answer': ['Yes'],\n",
|
45 |
+
" 'question_group': [69],\n",
|
46 |
+
" 'statutes': [[{\n",
|
47 |
+
" 'statute_idx': 431263,\n",
|
48 |
+
" 'citation': 'ALA. CODE \\u00a7 35-9A-141(11)',\n",
|
49 |
+
" '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",
|
50 |
+
" }]],\n",
|
51 |
+
" 'original_question': ['Is there a state/territory law regulating residential evictions?'],\n",
|
52 |
+
" 'caveats': [['']],\n",
|
53 |
+
" })\n",
|
54 |
+
"})"
|
55 |
]
|
56 |
},
|
57 |
{
|
58 |
"cell_type": "code",
|
59 |
+
"execution_count": 29,
|
60 |
+
"id": "893dbd5a-e351-43a9-b939-ed022a78b78a",
|
61 |
"metadata": {},
|
62 |
"outputs": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
{
|
64 |
"data": {
|
65 |
"text/plain": [
|
|
|
68 |
" 'question': 'Is there a state/territory law regulating residential evictions?',\n",
|
69 |
" 'answer': 'Yes',\n",
|
70 |
" 'question_group': 69,\n",
|
71 |
+
" 'statutes': [{'citation': 'ALA. CODE Β§ 35-9A-141(11)',\n",
|
72 |
+
" '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",
|
73 |
+
" 'statute_idx': 431263}],\n",
|
74 |
" 'original_question': 'Is there a state/territory law regulating residential evictions?',\n",
|
75 |
" 'caveats': ['']}"
|
76 |
]
|
77 |
},
|
78 |
+
"execution_count": 29,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
"metadata": {},
|
80 |
"output_type": "execute_result"
|
81 |
}
|
82 |
],
|
83 |
"source": [
|
84 |
+
"dataset[\"train\"][0]"
|
85 |
]
|
86 |
},
|
87 |
{
|
88 |
"cell_type": "code",
|
89 |
"execution_count": null,
|
90 |
+
"id": "98fc7ef8-24e8-4e02-ba9f-215330fca3c6",
|
91 |
"metadata": {},
|
92 |
"outputs": [],
|
93 |
"source": []
|