The Dataset Viewer has been disabled on this dataset.

Polish Court Judgments Graph

Dataset description

We introduce a graph dataset of Polish Court Judgments. This dataset is primarily based on the JuDDGES/pl-court-raw. The dataset consists of nodes representing either judgments or legal bases, and edges connecting judgments to the legal bases they refer to. Also, the graph was cleaned from small disconnected components, leaving single giant component. Consequently, the resulting graph is bipartite. We provide the dataset in both JSON and PyG formats, each has different purpose. While structurally graphs in these formats are the same, their attributes differ.

The JSON format is intended for analysis and contains most of the attributes available in JuDDGES/pl-court-raw. We excluded some less-useful attributes and text content, which can be easily retrieved from the raw dataset and added to the graph as needed.

The PyG format is designed for machine learning applications, such as link prediction on graphs, and is fully compatible with the Pytorch Geometric framework.

In the following sections, we provide a more detailed explanation and use case examples for each format.

Dataset statistics

feature value
#nodes 369033
#edges 1131458
#nodes (type=judgment) 366212
#nodes (type=legal_base) 2819
avg(degree) 6.132015294025195

png

JSON format

The JSON format contains graph node types differentiated by node_type attrbute. Each node_type has its additional corresponding attributes (see JuDDGES/pl-court-raw for detailed description of each attribute):

node_type attributes
judgment _id,chairman,court_name,date,department_name,judges,node_type,publisher,recorder,signature,type
legal_base isap_id,node_type,title

Loading

Graph the JSON format is saved in node-link format, and can be readily loaded with networkx library:

import json
import networkx as nx
from huggingface_hub import hf_hub_download

DATA_DIR = "<your_local_data_directory>"
JSON_FILE = "data/judgment_graph.json"
hf_hub_download(repo_id="JuDDGES/pl-court-graph", repo_type="dataset", filename=JSON_FILE, local_dir=DATA_DIR)

with open(f"{DATA_DIR}/{JSON_FILE}") as file:
    g_data = json.load(file)

g = nx.node_link_graph(g_data)

Example usage

# TBD

PyG format

The PyTorch Geometric format includes embeddings of the judgment content, obtained with sdadas/mmlw-roberta-large for judgment nodes, and one-hot-vector identifiers for legal-base nodes (note that for efficiency one can substitute it with random noise identifiers, like in (Abboud et al., 2021)).

Loading

In order to load graph as pytorch geometric, one can leverage the following code snippet

import torch
import os
from torch_geometric.data import InMemoryDataset, download_url


class PlCourtGraphDataset(InMemoryDataset):
    URL = (
        "https://huggingface.co/datasets/JuDDGES/pl-court-graph/resolve/main/"
        "data/pyg_judgment_graph.pt?download=true"
    )

    def __init__(self, root_dir: str, transform=None, pre_transform=None):
        super(PlCourtGraphDataset, self).__init__(root_dir, transform, pre_transform)
        data_file, index_file = self.processed_paths
        self.load(data_file)
        self.judgment_idx_2_iid, self.legal_base_idx_2_isap_id = torch.load(index_file).values()

    @property
    def raw_file_names(self) -> str:
        return "pyg_judgment_graph.pt"

    @property
    def processed_file_names(self) -> list[str]:
        return ["processed_pyg_judgment_graph.pt", "index_map.pt"]

    def download(self) -> None:
        os.makedirs(self.root, exist_ok=True)
        download_url(self.URL + self.raw_file_names, self.raw_dir)

    def process(self) -> None:
        dataset = torch.load(self.raw_paths[0])
        data = dataset["data"]

        if self.pre_transform is not None:
            data = self.pre_transform(data)

        data_file, index_file = self.processed_paths
        self.save([data], data_file)

        torch.save(
            {
                "judgment_idx_2_iid": dataset["judgment_idx_2_iid"],
                "legal_base_idx_2_isap_id": dataset["legal_base_idx_2_isap_id"],
            },
            index_file,
        )

    def __repr__(self) -> str:
        return f"{self.__class__.__name__}({len(self)})"


ds = PlCourtGraphDataset(root_dir="data/datasets/pyg")
print(ds)

Licensing Information

We license the actual packaging of these data under Attribution 4.0 International (CC BY 4.0) https://creativecommons.org/licenses/by/4.0/

Downloads last month
3