Datasets:

srzhang commited on
Commit
9c84895
·
1 Parent(s): d182e55
Files changed (1) hide show
  1. LongConL.py +0 -106
LongConL.py CHANGED
@@ -30,86 +30,6 @@ _CONFIGS = {
30
  for task_name in TASK_NAMES
31
  }
32
 
33
- class LongConLDataset(datasets.GeneratorBasedBuilder):
34
- """Legal opinion classification dataset for LongConL tasks"""
35
-
36
- def _info(self):
37
- """Return dataset information."""
38
- features = datasets.Features({
39
- "Citation": datasets.Value("string"),
40
- "Full Case Name": datasets.Value("string"),
41
- "Opinion Text": datasets.Value("string"),
42
- "Numerical Label": datasets.Value("string"), # Will be optional for some tasks
43
- "Text Label": datasets.Value("string"),
44
- })
45
- return datasets.DatasetInfo(
46
- description=_DESCRIPTION,
47
- features=features,
48
- homepage=_HOMEPAGE,
49
- citation=_CITATION,
50
- license=_LICENSE,
51
- )
52
-
53
- def _split_generators(self, dl_manager):
54
- """Split the dataset into train, validation, and test."""
55
- task_name = self.config.name # Get the current task name from the config
56
- urls = {key: val.format(task_name=task_name) for key, val in _URLS.items()} # Update URLs with the task name
57
- downloaded_files = dl_manager.download_and_extract(urls)
58
-
59
- return [
60
- datasets.SplitGenerator(
61
- name=datasets.Split.TRAIN,
62
- gen_kwargs={"file_path": downloaded_files["train"]},
63
- ),
64
- datasets.SplitGenerator(
65
- name=datasets.Split.VALIDATION,
66
- gen_kwargs={"file_path": downloaded_files["validation"]},
67
- ),
68
- datasets.SplitGenerator(
69
- name=datasets.Split.TEST,
70
- gen_kwargs={"file_path": downloaded_files["test"]},
71
- ),
72
- ]
73
-
74
- def _generate_examples(self, file_path):
75
- """Generate examples from the dataset CSV."""
76
- data = pd.read_csv(file_path)
77
- print("Data loaded from file:", file_path)
78
- print(data.head()) # Display first few rows
79
-
80
- # Check if the DataFrame is empty or has the correct columns
81
- if data.empty:import datasets
82
- import pandas as pd
83
-
84
- # Dataset metadata
85
- _CITATION = """"""
86
- _DESCRIPTION = """"""
87
- _HOMEPAGE = ""
88
- _LICENSE = ""
89
-
90
- # Updated URLs to dynamically handle task names
91
- _URLS = {
92
- "train": "data/LongConL-tasks/{task_name}/train.csv",
93
- "validation": "data/LongConL-tasks/{task_name}/validation.csv",
94
- "test": "data/LongConL-tasks/{task_name}/test.csv",
95
- }
96
-
97
- TASK_NAMES = ["ATS-Jurisdiction", "ATS-FavorableJudgment"] # Add more task names as needed
98
-
99
- _CONFIGS = {
100
- task_name: {
101
- "description": f"{task_name} specific legal opinions", # Dynamic description based on task name
102
- "features": {
103
- "Citation": datasets.Value("string"),
104
- "Full Case Name": datasets.Value("string"),
105
- "Opinion Text": datasets.Value("string"),
106
- "Numerical Label": datasets.Value("string"), # Will be optional for some tasks
107
- "Text Label": datasets.Value("string"),
108
- },
109
- }
110
- for task_name in TASK_NAMES
111
- }
112
-
113
 
114
 
115
  class LongConLDataset(datasets.GeneratorBasedBuilder):
@@ -179,29 +99,3 @@ class LongConLDataset(datasets.GeneratorBasedBuilder):
179
  ]
180
 
181
 
182
- print(f"Warning: No data found in {file_path}")
183
- return # Early exit if there's no data
184
-
185
- expected_columns = {"Citation", "Full Case Name", "Opinion Text", "Numerical Label", "Text Label"}
186
- if not expected_columns.issubset(data.columns):
187
- print(f"Warning: Missing columns in {file_path}. Expected columns: {expected_columns}. Found columns: {set(data.columns)}")
188
- return # Early exit if columns are missing
189
-
190
- data_dict = data.to_dict(orient="records")
191
- print(f"Number of examples to generate: {len(data_dict)}")
192
-
193
- for id_, row in enumerate(data_dict):
194
- yield id_, {
195
- "Citation": row["Citation"],
196
- "Full Case Name": row["Full Case Name"],
197
- "Opinion Text": row["Opinion Text"],
198
- "Numerical Label": row.get("Numerical Label", None),
199
- "Text Label": row["Text Label"],
200
- }
201
-
202
- # Use a dynamic config
203
- BUILDER_CONFIGS = [
204
- datasets.BuilderConfig(name=task_name, version=datasets.Version("1.0.0"), description=task_name)
205
- for task_name in ["ATS-Jurisdiction", "ATS-FavorableJudgment", "JRC-AREA1", "DC-category", "SC-issueArea", "SSC-ca_disp", "Chevron-Agency", "CoA-geniss"] # Add your task names here
206
- ]
207
-
 
30
  for task_name in TASK_NAMES
31
  }
32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
 
35
  class LongConLDataset(datasets.GeneratorBasedBuilder):
 
99
  ]
100
 
101