Dataset Preview
Duplicate
The full dataset viewer is not available (click to read why). Only showing a preview of the rows.
The dataset generation failed
Error code:   DatasetGenerationError
Exception:    ArrowNotImplementedError
Message:      Cannot write struct type '_format_kwargs' with no child field to Parquet. Consider adding a dummy child field.
Traceback:    Traceback (most recent call last):
                File "/usr/local/lib/python3.12/site-packages/datasets/builder.py", line 1831, in _prepare_split_single
                  writer.write_table(table)
                File "/usr/local/lib/python3.12/site-packages/datasets/arrow_writer.py", line 712, in write_table
                  self._build_writer(inferred_schema=pa_table.schema)
                File "/usr/local/lib/python3.12/site-packages/datasets/arrow_writer.py", line 757, in _build_writer
                  self.pa_writer = pq.ParquetWriter(
                                   ^^^^^^^^^^^^^^^^^
                File "/usr/local/lib/python3.12/site-packages/pyarrow/parquet/core.py", line 1070, in __init__
                  self.writer = _parquet.ParquetWriter(
                                ^^^^^^^^^^^^^^^^^^^^^^^
                File "pyarrow/_parquet.pyx", line 2363, in pyarrow._parquet.ParquetWriter.__cinit__
                File "pyarrow/error.pxi", line 155, in pyarrow.lib.pyarrow_internal_check_status
                File "pyarrow/error.pxi", line 92, in pyarrow.lib.check_status
              pyarrow.lib.ArrowNotImplementedError: Cannot write struct type '_format_kwargs' with no child field to Parquet. Consider adding a dummy child field.
              
              During handling of the above exception, another exception occurred:
              
              Traceback (most recent call last):
                File "/usr/local/lib/python3.12/site-packages/datasets/builder.py", line 1847, in _prepare_split_single
                  num_examples, num_bytes = writer.finalize()
                                            ^^^^^^^^^^^^^^^^^
                File "/usr/local/lib/python3.12/site-packages/datasets/arrow_writer.py", line 731, in finalize
                  self._build_writer(self.schema)
                File "/usr/local/lib/python3.12/site-packages/datasets/arrow_writer.py", line 757, in _build_writer
                  self.pa_writer = pq.ParquetWriter(
                                   ^^^^^^^^^^^^^^^^^
                File "/usr/local/lib/python3.12/site-packages/pyarrow/parquet/core.py", line 1070, in __init__
                  self.writer = _parquet.ParquetWriter(
                                ^^^^^^^^^^^^^^^^^^^^^^^
                File "pyarrow/_parquet.pyx", line 2363, in pyarrow._parquet.ParquetWriter.__cinit__
                File "pyarrow/error.pxi", line 155, in pyarrow.lib.pyarrow_internal_check_status
                File "pyarrow/error.pxi", line 92, in pyarrow.lib.check_status
              pyarrow.lib.ArrowNotImplementedError: Cannot write struct type '_format_kwargs' with no child field to Parquet. Consider adding a dummy child field.
              
              The above exception was the direct cause of the following exception:
              
              Traceback (most recent call last):
                File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 1455, in compute_config_parquet_and_info_response
                  parquet_operations = convert_to_parquet(builder)
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
                File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 1054, in convert_to_parquet
                  builder.download_and_prepare(
                File "/usr/local/lib/python3.12/site-packages/datasets/builder.py", line 894, in download_and_prepare
                  self._download_and_prepare(
                File "/usr/local/lib/python3.12/site-packages/datasets/builder.py", line 970, in _download_and_prepare
                  self._prepare_split(split_generator, **prepare_split_kwargs)
                File "/usr/local/lib/python3.12/site-packages/datasets/builder.py", line 1702, in _prepare_split
                  for job_id, done, content in self._prepare_split_single(
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
                File "/usr/local/lib/python3.12/site-packages/datasets/builder.py", line 1858, in _prepare_split_single
                  raise DatasetGenerationError("An error occurred while generating the dataset") from e
              datasets.exceptions.DatasetGenerationError: An error occurred while generating the dataset

Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.

_data_files
list
_fingerprint
string
_format_columns
null
_format_kwargs
dict
_format_type
null
_output_all_columns
bool
_split
null
[ { "filename": "data-00000-of-00001.arrow" } ]
489d7ac5343c2ad5
null
{}
null
false
null
[ { "filename": "data-00000-of-00001.arrow" } ]
a75d8cbbb931d470
null
{}
null
false
null
[ { "filename": "data-00000-of-00001.arrow" } ]
66af2d5df3ca1b01
null
{}
null
false
null
[ { "filename": "data-00000-of-00001.arrow" } ]
c1f06fafde30f9d5
null
{}
null
false
null

YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

Legal Case Dataset Loader

This project provides a Python-based pipeline to load and access pre-processed legal case datasets stored in the Hugging Face datasets format. The datasets are intended for Natural Language Processing (NLP) tasks such as token classification, masked language modeling, and span extraction.


Dataset Overview

The datasets are stored in Arrow format using Hugging Face's datasets library. There are four main datasets:

  1. masked

    • Contains masked versions of legal case texts.
    • Useful for masked language modeling (MLM) tasks.
    • Each example may contain fields like case_id, masked_text, and tokenized input_ids.
  2. extracted

    • Contains raw extracted text from legal case PDFs.
    • Useful for text analysis, summarization, and feature extraction.
    • Typical fields: case_id, text.
  3. spans

    • Contains span information indicating important sections or phrases in the legal text.
    • Useful for tasks such as named entity recognition (NER) or section classification.
    • Typical fields: case_id, spans (list of start/end positions).
  4. token_labels

    • Contains token-level labels for NLP tasks.
    • Useful for token classification tasks like NER or legal argument labeling.
    • Typical fields: case_id, tokens, labels.

Prerequisites

Ensure you have Python installed (>=3.8) and the required packages.

Install the datasets library from Hugging Face:

pip install datasets

Optional but recommended for NLP pipelines:

pip install transformers torch

Project Structure

arrow_dataset/
├── masked/
├── extracted/
├── spans/
└── token_labels/

Each folder contains a dataset saved in Hugging Face Arrow format.


Loading the Datasets

Use the datasets library to load the datasets from disk:

from datasets import load_from_disk

# Load each dataset folder
masked_dataset = load_from_disk("arrow_dataset/masked")
extracted_dataset = load_from_disk("arrow_dataset/extracted")
spans_dataset = load_from_disk("arrow_dataset/spans")
token_labels_dataset = load_from_disk("arrow_dataset/token_labels")

# Example access
print("Masked Example:", masked_dataset[0])
print("Token Labels Example:", token_labels_dataset[0])

Example Data

Masked Dataset Example

{
  "case_id": "Sat_Paul_And_Others_vs_State_Of_Punjab_And_Another_on_9_March_2010",
  "masked_text": "The accused ___ entered the premises...",
  "input_ids": [101, 2003, 1037, 7099, 6251, 102]
}

Token Labels Example

{
  "case_id": "Sat_Paul_And_Others_vs_State_Of_Punjab_And_Another_on_9_March_2010",
  "tokens": ["The", "accused", "___", "entered", "the", "premises", "..."],
  "labels": [0, 1, 2, 0, 0, 1, 0]
}

Iterating Through Dataset

You can iterate through all examples for preprocessing or exporting:

for example in masked_dataset:
    case_id = example['case_id']
    masked_text = example['masked_text']
    print(f"Case ID: {case_id}\nMasked Text: {masked_text}\n")

You can also convert the dataset to pandas DataFrame for easier analysis:

import pandas as pd

df_masked = masked_dataset.to_pandas()
print(df_masked.head())

Use Cases

  • Legal NLP Modeling

    • Token classification (e.g., labeling legal entities)
    • Masked language modeling (MLM)
    • Span extraction or section identification
    • Summarization and legal text analysis
  • Data Analysis

    • Exploratory Data Analysis (EDA) on legal cases
    • Frequency analysis of legal phrases or tokens

Notes

  • Ensure that the dataset directories exist under arrow_dataset/.
  • The Hugging Face Arrow format is efficient for large datasets and can handle memory-mapped loading.
  • For tokenization and model training, you can use Hugging Face transformers with datasets directly.

References


Downloads last month
3