- LongConL.py +23 -28
LongConL.py
CHANGED
|
@@ -40,7 +40,6 @@ _CONFIGS = {
|
|
| 40 |
}
|
| 41 |
|
| 42 |
|
| 43 |
-
|
| 44 |
class LongConLDataset(datasets.GeneratorBasedBuilder):
|
| 45 |
"""Legal opinion classification dataset for LongConL tasks"""
|
| 46 |
|
|
@@ -61,30 +60,29 @@ class LongConLDataset(datasets.GeneratorBasedBuilder):
|
|
| 61 |
license=_LICENSE,
|
| 62 |
)
|
| 63 |
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
|
| 89 |
def _generate_examples(self, file_path):
|
| 90 |
"""Generate examples from the dataset CSV."""
|
|
@@ -103,12 +101,9 @@ class LongConLDataset(datasets.GeneratorBasedBuilder):
|
|
| 103 |
"Text Label": row["Text Label"],
|
| 104 |
}
|
| 105 |
|
| 106 |
-
|
| 107 |
-
|
| 108 |
# Use a dynamic config
|
| 109 |
BUILDER_CONFIGS = [
|
| 110 |
datasets.BuilderConfig(name=task_name, version=datasets.Version("1.0.0"), description=task_name)
|
| 111 |
for task_name in TASK_NAMES
|
| 112 |
]
|
| 113 |
|
| 114 |
-
|
|
|
|
| 40 |
}
|
| 41 |
|
| 42 |
|
|
|
|
| 43 |
class LongConLDataset(datasets.GeneratorBasedBuilder):
|
| 44 |
"""Legal opinion classification dataset for LongConL tasks"""
|
| 45 |
|
|
|
|
| 60 |
license=_LICENSE,
|
| 61 |
)
|
| 62 |
|
| 63 |
+
def _split_generators(self, dl_manager):
|
| 64 |
+
"""Split the dataset into train, validation, and test."""
|
| 65 |
+
task_name = self.config.name # Get the current task name from the config
|
| 66 |
+
valid_task_name = task_name.replace("-", "_") # Replace hyphens with underscores
|
| 67 |
+
|
| 68 |
+
# Update URLs with the valid task name
|
| 69 |
+
urls = {key: val.format(task_name=valid_task_name) for key, val in _URLS.items()}
|
| 70 |
+
downloaded_files = dl_manager.download_and_extract(urls)
|
| 71 |
+
|
| 72 |
+
return [
|
| 73 |
+
datasets.SplitGenerator(
|
| 74 |
+
name=datasets.Split.TRAIN,
|
| 75 |
+
gen_kwargs={"file_path": downloaded_files["train"]},
|
| 76 |
+
),
|
| 77 |
+
datasets.SplitGenerator(
|
| 78 |
+
name=datasets.Split.VALIDATION,
|
| 79 |
+
gen_kwargs={"file_path": downloaded_files["validation"]},
|
| 80 |
+
),
|
| 81 |
+
datasets.SplitGenerator(
|
| 82 |
+
name=datasets.Split.TEST,
|
| 83 |
+
gen_kwargs={"file_path": downloaded_files["test"]},
|
| 84 |
+
),
|
| 85 |
+
]
|
|
|
|
| 86 |
|
| 87 |
def _generate_examples(self, file_path):
|
| 88 |
"""Generate examples from the dataset CSV."""
|
|
|
|
| 101 |
"Text Label": row["Text Label"],
|
| 102 |
}
|
| 103 |
|
|
|
|
|
|
|
| 104 |
# Use a dynamic config
|
| 105 |
BUILDER_CONFIGS = [
|
| 106 |
datasets.BuilderConfig(name=task_name, version=datasets.Version("1.0.0"), description=task_name)
|
| 107 |
for task_name in TASK_NAMES
|
| 108 |
]
|
| 109 |
|
|
|