{
"cells": [
{
"cell_type": "code",
"execution_count": 10,
"id": "3c6f4757-0572-48ec-8159-206bbf2e08fd",
"metadata": {},
"outputs": [],
"source": [
"from datasets import load_dataset"
]
},
{
"cell_type": "markdown",
"id": "27e4d6d8-b201-482b-9b0a-688e1a21c9c0",
"metadata": {},
"source": [
"# Load `questions`"
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "2cb75e7c-b7eb-4601-85f3-cc27c1f5ff94",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Downloading builder script: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 3.67k/3.67k [00:00<00:00, 11.9MB/s]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"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"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"Downloading data: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 987k/987k [00:00<00:00, 7.34MB/s]\n",
" \r"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"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"
]
},
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" idx | \n",
" state | \n",
" question | \n",
" answer | \n",
" question_group | \n",
" statutes | \n",
" original_question | \n",
" caveats | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 0 | \n",
" Alabama | \n",
" Is there a state/territory law regulating resi... | \n",
" Yes | \n",
" 69 | \n",
" {'statute_idx': [431263], 'citation': ['ALA. C... | \n",
" Is there a state/territory law regulating resi... | \n",
" [] | \n",
"
\n",
" \n",
" 1 | \n",
" 163 | \n",
" Alabama | \n",
" Does the law specify a minimum number of days ... | \n",
" Yes | \n",
" 23 | \n",
" {'statute_idx': [431277], 'citation': ['ALA. C... | \n",
" Does the law specify a minimum number of days ... | \n",
" [] | \n",
"
\n",
" \n",
" 2 | \n",
" 237 | \n",
" Alabama | \n",
" Does the law specify rebuttals available to te... | \n",
" Yes | \n",
" 116 | \n",
" {'statute_idx': [417060, 431274, 431280, 43127... | \n",
" Does the law specify rebuttals available to a ... | \n",
" [] | \n",
"
\n",
" \n",
" 3 | \n",
" 286 | \n",
" Alabama | \n",
" In eviction proceedings, does the filing of an... | \n",
" Yes | \n",
" 4 | \n",
" {'statute_idx': [431286], 'citation': ['ALA. C... | \n",
" Does the filing of an appeal stay the executio... | \n",
" [] | \n",
"
\n",
" \n",
" 4 | \n",
" 353 | \n",
" Alabama | \n",
" Is it specified whether a landlord waives thei... | \n",
" Yes | \n",
" 201 | \n",
" {'statute_idx': [431280], 'citation': ['ALA. C... | \n",
" Does a landlord waive their right to evict for... | \n",
" [A landlord waives their right to evict by acc... | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" idx state question answer \\\n",
"0 0 Alabama Is there a state/territory law regulating resi... Yes \n",
"1 163 Alabama Does the law specify a minimum number of days ... Yes \n",
"2 237 Alabama Does the law specify rebuttals available to te... Yes \n",
"3 286 Alabama In eviction proceedings, does the filing of an... Yes \n",
"4 353 Alabama Is it specified whether a landlord waives thei... Yes \n",
"\n",
" question_group statutes \\\n",
"0 69 {'statute_idx': [431263], 'citation': ['ALA. C... \n",
"1 23 {'statute_idx': [431277], 'citation': ['ALA. C... \n",
"2 116 {'statute_idx': [417060, 431274, 431280, 43127... \n",
"3 4 {'statute_idx': [431286], 'citation': ['ALA. C... \n",
"4 201 {'statute_idx': [431280], 'citation': ['ALA. C... \n",
"\n",
" original_question \\\n",
"0 Is there a state/territory law regulating resi... \n",
"1 Does the law specify a minimum number of days ... \n",
"2 Does the law specify rebuttals available to a ... \n",
"3 Does the filing of an appeal stay the executio... \n",
"4 Does a landlord waive their right to evict for... \n",
"\n",
" caveats \n",
"0 [] \n",
"1 [] \n",
"2 [] \n",
"3 [] \n",
"4 [A landlord waives their right to evict by acc... "
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"questions = load_dataset(\"reglab/housing_qa\", \"questions\", split=\"test\", download_mode=\"force_redownload\")\n",
"questions.to_pandas().head(5)"
]
},
{
"cell_type": "code",
"execution_count": 30,
"id": "3931e731-006f-4731-8350-a7f83ea3f298",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'idx': 237,\n",
" 'state': 'Alabama',\n",
" 'question': 'Does the law specify rebuttals available to tenants subject to eviction proceedings?',\n",
" 'answer': 'Yes',\n",
" 'question_group': 116,\n",
" 'statutes': {'statute_idx': [417060, 431274, 431280, 431273, 431271],\n",
" 'citation': ['ALA. CODE § 35-9A-501(B)',\n",
" 'ALA. CODE § 35-9A-405(A)',\n",
" 'ALA. CODE § 35-9A-424',\n",
" 'ALA. CODE § 35-9A-404(B)',\n",
" 'ALA. CODE § 35-9A-401(A)'],\n",
" '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",
" \"(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",
" \"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",
" '(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",
" '(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",
" 'original_question': 'Does the law specify rebuttals available to a tenant?',\n",
" 'caveats': ['']}"
]
},
"execution_count": 30,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"for q in questions:\n",
" if len(q[\"statutes\"][\"citation\"]) > 1:\n",
" break \n",
"q"
]
},
{
"cell_type": "markdown",
"id": "c30a72f9-0ebe-4d33-abbd-e53883d04be5",
"metadata": {},
"source": [
"# RC Questions"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "92c9606a-09a5-44c6-94f2-4c9773c1a754",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Downloading data: 100%|████████████████████████████████████████████████████| 987k/987k [00:00<00:00, 10.7MB/s]\n",
"Generating test split: 6853 examples [00:00, 25871.49 examples/s]\n"
]
},
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" idx | \n",
" state | \n",
" question | \n",
" answer | \n",
" question_group | \n",
" statutes | \n",
" original_question | \n",
" caveats | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 0 | \n",
" Alabama | \n",
" Is there a state/territory law regulating resi... | \n",
" Yes | \n",
" 69 | \n",
" {'statute_idx': [431263], 'citation': ['ALA. C... | \n",
" Is there a state/territory law regulating resi... | \n",
" [[]] | \n",
"
\n",
" \n",
" 1 | \n",
" 163 | \n",
" Alabama | \n",
" Does the law specify a minimum number of days ... | \n",
" Yes | \n",
" 23 | \n",
" {'statute_idx': [431277], 'citation': ['ALA. C... | \n",
" Does the law specify a minimum number of days ... | \n",
" [[]] | \n",
"
\n",
" \n",
" 2 | \n",
" 237 | \n",
" Alabama | \n",
" Does the law specify rebuttals available to te... | \n",
" Yes | \n",
" 116 | \n",
" {'statute_idx': [417060, 431274, 431280, 43127... | \n",
" Does the law specify rebuttals available to a ... | \n",
" [[]] | \n",
"
\n",
" \n",
" 3 | \n",
" 286 | \n",
" Alabama | \n",
" In eviction proceedings, does the filing of an... | \n",
" Yes | \n",
" 4 | \n",
" {'statute_idx': [431286], 'citation': ['ALA. C... | \n",
" Does the filing of an appeal stay the executio... | \n",
" [[]] | \n",
"
\n",
" \n",
" 4 | \n",
" 353 | \n",
" Alabama | \n",
" Is it specified whether a landlord waives thei... | \n",
" Yes | \n",
" 201 | \n",
" {'statute_idx': [431280], 'citation': ['ALA. C... | \n",
" Does a landlord waive their right to evict for... | \n",
" [[A, , l, a, n, d, l, o, r, d, , w, a, i, v,... | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" idx state question answer \\\n",
"0 0 Alabama Is there a state/territory law regulating resi... Yes \n",
"1 163 Alabama Does the law specify a minimum number of days ... Yes \n",
"2 237 Alabama Does the law specify rebuttals available to te... Yes \n",
"3 286 Alabama In eviction proceedings, does the filing of an... Yes \n",
"4 353 Alabama Is it specified whether a landlord waives thei... Yes \n",
"\n",
" question_group statutes \\\n",
"0 69 {'statute_idx': [431263], 'citation': ['ALA. C... \n",
"1 23 {'statute_idx': [431277], 'citation': ['ALA. C... \n",
"2 116 {'statute_idx': [417060, 431274, 431280, 43127... \n",
"3 4 {'statute_idx': [431286], 'citation': ['ALA. C... \n",
"4 201 {'statute_idx': [431280], 'citation': ['ALA. C... \n",
"\n",
" original_question \\\n",
"0 Is there a state/territory law regulating resi... \n",
"1 Does the law specify a minimum number of days ... \n",
"2 Does the law specify rebuttals available to a ... \n",
"3 Does the filing of an appeal stay the executio... \n",
"4 Does a landlord waive their right to evict for... \n",
"\n",
" caveats \n",
"0 [[]] \n",
"1 [[]] \n",
"2 [[]] \n",
"3 [[]] \n",
"4 [[A, , l, a, n, d, l, o, r, d, , w, a, i, v,... "
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"questions = load_dataset(\"reglab/housing_qa\", \"rc_questions\")\n",
"questions[\"test\"].to_pandas().head(5)"
]
},
{
"cell_type": "markdown",
"id": "692490c0-eaa3-4f88-9b25-630f6ce736a3",
"metadata": {},
"source": [
"# Statutes"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "b4ce7ae9-618f-4594-be69-b53a58e580e4",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" citation | \n",
" path | \n",
" state | \n",
" text | \n",
" idx | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" MO Rev Stat § 1.010 (2021) | \n",
" 2021 Missouri Revised Statutes|Title I - Laws ... | \n",
" missouri | \n",
" Effective - 28 Aug 2015 1.010. Common law in... | \n",
" 0 | \n",
"
\n",
" \n",
" 1 | \n",
" MO Rev Stat § 1.020 (2021) | \n",
" 2021 Missouri Revised Statutes|Title I - Laws ... | \n",
" missouri | \n",
" Effective - 28 Aug 2009 1.020. Definitions. ... | \n",
" 1 | \n",
"
\n",
" \n",
" 2 | \n",
" MO Rev Stat § 1.025 (2021) | \n",
" 2021 Missouri Revised Statutes|Title I - Laws ... | \n",
" missouri | \n",
" Effective - 28 Aug 1958 1.025. Registered ma... | \n",
" 2 | \n",
"
\n",
" \n",
" 3 | \n",
" MO Rev Stat § 1.028 (2021) | \n",
" 2021 Missouri Revised Statutes|Title I - Laws ... | \n",
" missouri | \n",
" Effective - 28 Aug 1999 1.028. English is th... | \n",
" 3 | \n",
"
\n",
" \n",
" 4 | \n",
" MO Rev Stat § 1.030 (2021) | \n",
" 2021 Missouri Revised Statutes|Title I - Laws ... | \n",
" missouri | \n",
" Effective - 28 Aug 1957 1.030. Plural includ... | \n",
" 4 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" citation \\\n",
"0 MO Rev Stat § 1.010 (2021) \n",
"1 MO Rev Stat § 1.020 (2021) \n",
"2 MO Rev Stat § 1.025 (2021) \n",
"3 MO Rev Stat § 1.028 (2021) \n",
"4 MO Rev Stat § 1.030 (2021) \n",
"\n",
" path state \\\n",
"0 2021 Missouri Revised Statutes|Title I - Laws ... missouri \n",
"1 2021 Missouri Revised Statutes|Title I - Laws ... missouri \n",
"2 2021 Missouri Revised Statutes|Title I - Laws ... missouri \n",
"3 2021 Missouri Revised Statutes|Title I - Laws ... missouri \n",
"4 2021 Missouri Revised Statutes|Title I - Laws ... missouri \n",
"\n",
" text idx \n",
"0 Effective - 28 Aug 2015 1.010. Common law in... 0 \n",
"1 Effective - 28 Aug 2009 1.020. Definitions. ... 1 \n",
"2 Effective - 28 Aug 1958 1.025. Registered ma... 2 \n",
"3 Effective - 28 Aug 1999 1.028. English is th... 3 \n",
"4 Effective - 28 Aug 1957 1.030. Plural includ... 4 "
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"statutes = load_dataset(\"reglab/housing_qa\", \"statutes\")\n",
"statutes[\"corpus\"].to_pandas().head(5)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.18"
}
},
"nbformat": 4,
"nbformat_minor": 5
}