|
|
import datasets |
|
|
import pandas as pd |
|
|
|
|
|
|
|
|
_CITATION = """""" |
|
|
_DESCRIPTION = """""" |
|
|
_HOMEPAGE = "" |
|
|
_LICENSE = "" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TASK_NAMES = [ |
|
|
'ATS-ATS Judgment Categories','ATS-Did the Court find ATS Jurisdiction', |
|
|
'ATS-Favorable Judgment for at least one Plaintiff affecting the ATS claim', |
|
|
'ATS-Is at least one defendant a corporation', |
|
|
'Chevron-Ag. Format', 'Chevron-Ag. Interp', 'Chevron-Ag. Iss 3', 'Chevron-Ag. Iss. 1', |
|
|
'Chevron-Ag. Iss. 2', 'Chevron-Ag. Iss. 4', 'Chevron-Agency', 'Chevron-ChevCited', 'Chevron-Chevron', |
|
|
'Chevron-Chief', 'Chevron-Concurr', 'Chevron-Dec. Ag. ', 'Chevron-Dec. Ov. ', 'Chevron-Deference', 'Chevron-Dissents', |
|
|
'Chevron-Notice & Comment', 'Chevron-Outcome', 'Chevron-Step 0', 'Chevron-Step 1', 'Chevron-Step 2', 'Chevron-Subject', |
|
|
'Chevron-Type Del. ', 'Chevron-Unan', |
|
|
'CoA-abusedis', 'CoA-adminrev', 'CoA-alj', 'CoA-altdisp', 'CoA-amicus', 'CoA-appbus', 'CoA-appfed', 'CoA-appfiduc', 'CoA-applfrom', |
|
|
'CoA-appnatpr', 'CoA-appnonp', 'CoA-appstate', 'CoA-appsubst', 'CoA-attyfee', 'CoA-bank_ap1', 'CoA-bank_r1', 'CoA-capric', |
|
|
'CoA-casetyp1', 'CoA-circuit', 'CoA-classact', 'CoA-concur', 'CoA-confess', 'CoA-constit', 'CoA-counsel', 'CoA-counsel1', |
|
|
'CoA-counsel2', 'CoA-crossapp', 'CoA-day', 'CoA-direct1', 'CoA-discover', 'CoA-dissent', 'CoA-district', 'CoA-dueproc', |
|
|
'CoA-entrap', 'CoA-erron', 'CoA-execord', 'CoA-exhaust', 'CoA-fedlaw', 'CoA-fedvst', 'CoA-genapel1', 'CoA-geniss', 'CoA-genresp1', |
|
|
'CoA-genstand', 'CoA-habeas', 'CoA-immunity', 'CoA-improper', 'CoA-indict', 'CoA-initiate', 'CoA-injunct', 'CoA-interven', |
|
|
'CoA-judgdisc', 'CoA-juris', 'CoA-juryinst', 'CoA-majvotes', 'CoA-method', 'CoA-month', 'CoA-notice', 'CoA-numappel', 'CoA-numresp', |
|
|
'CoA-opinstat', 'CoA-origin', 'CoA-othadmis', 'CoA-othjury', 'CoA-plea', 'CoA-post_trl', 'CoA-prejud', 'CoA-pretrial', 'CoA-procdis', |
|
|
'CoA-procedur', 'CoA-r_bus', 'CoA-r_fed', 'CoA-r_fiduc', 'CoA-r_natpr', 'CoA-r_nonp', 'CoA-r_state', 'CoA-r_stid', 'CoA-r_subst', |
|
|
'CoA-realapp', 'CoA-realresp', 'CoA-rtcouns', 'CoA-search', 'CoA-sentence', 'CoA-source', 'CoA-standing', 'CoA-state', 'CoA-statecl', |
|
|
'CoA-stpolicy', 'CoA-subevid', 'CoA-suffic', 'CoA-summary', 'CoA-timely', 'CoA-treat', 'CoA-trialpro', 'CoA-typeiss', 'CoA-weightev', |
|
|
'DC-casetype', 'DC-category', 'DC-circuit', 'DC-libcon', 'DC-month', 'DC-statdist', 'DC-state', 'DC-year', |
|
|
'JRC-AREA1', 'JRC-ATT GEN', 'JRC-CERT', 'JRC-DECISION', 'JRC-DECISION2', 'JRC-DISSENT', 'JRC-GVT PRTY', 'JRC-REVERSD', |
|
|
'SC-adminAction', 'SC-authorityDecision1', 'SC-caseDisposition', 'SC-caseOrigin', 'SC-caseOriginState', 'SC-caseSource', |
|
|
'SC-caseSourceState', 'SC-certReason', 'SC-decisionDirection', 'SC-decisionDirectionDissent', 'SC-decisionType', |
|
|
'SC-declarationUncon', 'SC-issue', 'SC-issueArea', 'SC-jurisdiction', 'SC-lawType', 'SC-lcDisagreement', 'SC-lcDisposition', |
|
|
'SC-lcDispositionDirection', 'SC-majOpinWriter', 'SC-majVotes', 'SC-minVotes', 'SC-partyWinning', 'SC-petitioner', |
|
|
'SC-precedentAlteration', 'SC-respondent', 'SC-respondentState', 'SC-threeJudgeFdc', 'SC-voteUnclear', |
|
|
'SSC-agency', 'SSC-agency_r', 'SSC-amicus', 'SSC-arson', 'SSC-assaulta', 'SSC-burglary', 'SSC-ca_atty', 'SSC-ca_capo', |
|
|
'SSC-ca_conv', 'SSC-ca_cruel', 'SSC-ca_disc', 'SSC-ca_disp', 'SSC-ca_doubj', 'SSC-ca_ev_m', 'SSC-ca_ev_w', 'SSC-ca_gjury', |
|
|
'SSC-ca_insan', 'SSC-ca_jr_in', 'SSC-ca_jr_sl', 'SSC-ca_majfm', 'SSC-ca_opnfm', 'SSC-ca_plea', 'SSC-ca_prej', 'SSC-ca_race', |
|
|
'SSC-ca_recus', 'SSC-ca_self', 'SSC-ca_sent', 'SSC-ca_sento', 'SSC-ca_serch', 'SSC-ca_sevr', 'SSC-ca_speed', 'SSC-ca_stc', |
|
|
'SSC-ca_stcty', 'SSC-ca_stdc', 'SSC-ca_suff', 'SSC-ca_tot_c', 'SSC-ca_tot_i', 'SSC-ca_trial', 'SSC-ca_usc', 'SSC-ca_uscdc', |
|
|
'SSC-ca_uscty', 'SSC-ca_venue', 'SSC-ca_winp', 'SSC-crossapp', 'SSC-death_c', 'SSC-death_im', 'SSC-dec1_day', 'SSC-dec1_mo', |
|
|
'SSC-dec1_yr', 'SSC-decs_day', 'SSC-decs_mo', 'SSC-decs_yr', 'SSC-disorder', 'SSC-docket_n', 'SSC-drugabus', |
|
|
'SSC-drugsell', 'SSC-dui', 'SSC-enbanc', 'SSC-fam_kids', 'SSC-first_ct', 'SSC-fraud', 'SSC-juris', 'SSC-kidnap', 'SSC-mans_neg', |
|
|
'SSC-mans_non', 'SSC-multi_p', 'SSC-multi_r', 'SSC-murder', 'SSC-o_defend', 'SSC-o_plain', 'SSC-p1_persn', 'SSC-p1_sgov', |
|
|
'SSC-parole', 'SSC-r1_persn', 'SSC-rape', 'SSC-rev_ct', 'SSC-robbery', 'SSC-sex_gen', 'SSC-stolen', 'SSC-theft', 'SSC-traffic', |
|
|
'SSC-type_p1', 'SSC-type_p2' |
|
|
] |
|
|
|
|
|
_CONFIGS = { |
|
|
task_name: { |
|
|
"description": f"{task_name} specific legal opinions", |
|
|
"features": { |
|
|
"idx": datasets.Value("string"), |
|
|
"Citation": datasets.Value("string"), |
|
|
"Full Case Name": datasets.Value("string"), |
|
|
"Opinion Text": datasets.Value("string"), |
|
|
"Numerical Label": datasets.Value("string"), |
|
|
"Text Label": datasets.Value("string"), |
|
|
|
|
|
|
|
|
}, |
|
|
} |
|
|
for task_name in TASK_NAMES |
|
|
} |
|
|
|
|
|
|
|
|
class LongConLDataset(datasets.GeneratorBasedBuilder): |
|
|
"""Legal opinion classification dataset for LongConL tasks""" |
|
|
|
|
|
def _info(self): |
|
|
"""Return dataset information.""" |
|
|
features = datasets.Features({ |
|
|
"idx": datasets.Value("string"), |
|
|
"Citation": datasets.Value("string"), |
|
|
"Full Case Name": datasets.Value("string"), |
|
|
"Opinion Text": datasets.Value("string"), |
|
|
"Numerical Label": datasets.Value("string"), |
|
|
"Text Label": datasets.Value("string"), |
|
|
|
|
|
|
|
|
}) |
|
|
return datasets.DatasetInfo( |
|
|
description=_DESCRIPTION, |
|
|
features=features, |
|
|
homepage=_HOMEPAGE, |
|
|
citation=_CITATION, |
|
|
license=_LICENSE, |
|
|
) |
|
|
|
|
|
def _split_generators(self, dl_manager): |
|
|
task_name = self.config.name |
|
|
dataset_prefix = task_name.split("-")[0] |
|
|
|
|
|
urls = { |
|
|
"train": f"data/automated-tasks-subsample/{dataset_prefix}-subsample/{task_name}/{task_name}_train.csv", |
|
|
"validation": f"data/automated-tasks-subsample/{dataset_prefix}-subsample/{task_name}/{task_name}_val.csv", |
|
|
"test": f"data/automated-tasks-subsample/{dataset_prefix}-subsample/{task_name}/{task_name}_test.csv", |
|
|
} |
|
|
|
|
|
downloaded_files = dl_manager.download_and_extract(urls) |
|
|
|
|
|
return [ |
|
|
datasets.SplitGenerator( |
|
|
name=datasets.Split.TRAIN, |
|
|
gen_kwargs={"file_path": downloaded_files["train"]}, |
|
|
), |
|
|
datasets.SplitGenerator( |
|
|
name=datasets.Split.VALIDATION, |
|
|
gen_kwargs={"file_path": downloaded_files["validation"]}, |
|
|
), |
|
|
datasets.SplitGenerator( |
|
|
name=datasets.Split.TEST, |
|
|
gen_kwargs={"file_path": downloaded_files["test"]}, |
|
|
), |
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
def _generate_examples(self, file_path): |
|
|
"""Generate examples from the dataset CSV.""" |
|
|
data = pd.read_csv(file_path) |
|
|
print("Loaded file path:", file_path) |
|
|
print("Shape of data:", data.shape) |
|
|
print(data.head()) |
|
|
data_dict = data.to_dict(orient="records") |
|
|
print(f"Number of examples to generate: {len(data_dict)}") |
|
|
|
|
|
for id_, row in enumerate(data_dict): |
|
|
yield id_, { |
|
|
"idx": row["idx"], |
|
|
"Citation": row["Citation"], |
|
|
"Full Case Name": row["Full Case Name"], |
|
|
"Opinion Text": row["Opinion Text"], |
|
|
"Numerical Label": row.get("Numerical Label", None), |
|
|
"Text Label": row["Text Label"], |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
BUILDER_CONFIGS = [ |
|
|
datasets.BuilderConfig(name=task_name, version=datasets.Version("1.0.0"), description=task_name) |
|
|
for task_name in TASK_NAMES |
|
|
] |
|
|
|
|
|
|