tst
Browse files- LongConL.py +33 -37
LongConL.py
CHANGED
|
@@ -30,8 +30,6 @@ _CONFIGS = {
|
|
| 30 |
for task_name in TASK_NAMES
|
| 31 |
}
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|
| 35 |
class LongConLDataset(datasets.GeneratorBasedBuilder):
|
| 36 |
"""Legal opinion classification dataset for LongConL tasks"""
|
| 37 |
|
|
@@ -73,39 +71,37 @@ class LongConLDataset(datasets.GeneratorBasedBuilder):
|
|
| 73 |
),
|
| 74 |
]
|
| 75 |
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
]
|
| 110 |
-
|
| 111 |
|
|
|
|
| 30 |
for task_name in TASK_NAMES
|
| 31 |
}
|
| 32 |
|
|
|
|
|
|
|
| 33 |
class LongConLDataset(datasets.GeneratorBasedBuilder):
|
| 34 |
"""Legal opinion classification dataset for LongConL tasks"""
|
| 35 |
|
|
|
|
| 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:
|
| 82 |
+
print(f"Warning: No data found in {file_path}")
|
| 83 |
+
return # Early exit if there's no data
|
| 84 |
+
|
| 85 |
+
expected_columns = {"Citation", "Full Case Name", "Opinion Text", "Numerical Label", "Text Label"}
|
| 86 |
+
if not expected_columns.issubset(data.columns):
|
| 87 |
+
print(f"Warning: Missing columns in {file_path}. Expected columns: {expected_columns}. Found columns: {set(data.columns)}")
|
| 88 |
+
return # Early exit if columns are missing
|
| 89 |
+
|
| 90 |
+
data_dict = data.to_dict(orient="records")
|
| 91 |
+
print(f"Number of examples to generate: {len(data_dict)}")
|
| 92 |
+
|
| 93 |
+
for id_, row in enumerate(data_dict):
|
| 94 |
+
yield id_, {
|
| 95 |
+
"Citation": row["Citation"],
|
| 96 |
+
"Full Case Name": row["Full Case Name"],
|
| 97 |
+
"Opinion Text": row["Opinion Text"],
|
| 98 |
+
"Numerical Label": row.get("Numerical Label", None),
|
| 99 |
+
"Text Label": row["Text Label"],
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
# Use a dynamic config
|
| 103 |
+
BUILDER_CONFIGS = [
|
| 104 |
+
datasets.BuilderConfig(name=task_name, version=datasets.Version("1.0.0"), description=task_name)
|
| 105 |
+
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
|
| 106 |
+
]
|
|
|
|
|
|
|
| 107 |
|