{ "cells": [ { "cell_type": "code", "execution_count": 26, "id": "2c24819e-0019-4c60-9284-77bfa565ecc5", "metadata": {}, "outputs": [], "source": [ "from datasets import Dataset, DatasetInfo, Features, ClassLabel, Value, Sequence, DatasetDict\n", "\n", "# Define the dataset's schema\n", "features = Features({\n", " 'idx': Value('int32'),\n", " 'state': Value('string'),\n", " 'question': Value('string'),\n", " 'answer': Value('string'),\n", " 'question_group': Value('int32'),\n", " 'statutes': Sequence({\n", " 'statute_idx': Value('int32'),\n", " 'citation': Value('string'),\n", " 'excerpt': Value('string'),\n", " }),\n", " 'original_question': Value('string'),\n", " 'caveats': Sequence(Value('string')),\n", "})\n", "\n", "# Create a DatasetInfo object for additional metadata\n", "dataset_info = DatasetInfo(\n", " description=\"A dataset containing information on state/territory laws regulating residential evictions, including relevant legal statutes.\",\n", " features=features,\n", " supervised_keys=None, # No supervised keys as this dataset doesn't include labels for training models\n", " homepage=\"http://example.com\", # Add a real homepage if applicable\n", " citation=\"Citation information for the dataset\",\n", ")\n", "\n", "# Load dataset from your data source\n", "# Assuming your data is in JSON or other format, use appropriate loading function\n", "dataset = DatasetDict({\n", " 'train': Dataset.from_dict({\n", " 'idx': [0],\n", " 'state': ['Alabama'],\n", " 'question': ['Is there a state/territory law regulating residential evictions?'],\n", " 'answer': ['Yes'],\n", " 'question_group': [69],\n", " 'statutes': [[{\n", " 'statute_idx': 431263,\n", " 'citation': 'ALA. CODE \\u00a7 35-9A-141(11)',\n", " '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", " }]],\n", " 'original_question': ['Is there a state/territory law regulating residential evictions?'],\n", " 'caveats': [['']],\n", " })\n", "})" ] }, { "cell_type": "code", "execution_count": 29, "id": "893dbd5a-e351-43a9-b939-ed022a78b78a", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'idx': 0,\n", " 'state': 'Alabama',\n", " 'question': 'Is there a state/territory law regulating residential evictions?',\n", " 'answer': 'Yes',\n", " 'question_group': 69,\n", " 'statutes': [{'citation': 'ALA. CODE § 35-9A-141(11)',\n", " '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", " 'statute_idx': 431263}],\n", " 'original_question': 'Is there a state/territory law regulating residential evictions?',\n", " 'caveats': ['']}" ] }, "execution_count": 29, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dataset[\"train\"][0]" ] }, { "cell_type": "code", "execution_count": null, "id": "98fc7ef8-24e8-4e02-ba9f-215330fca3c6", "metadata": {}, "outputs": [], "source": [] } ], "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 }