Datasets:

srzhang commited on
Commit
a22e20f
·
1 Parent(s): c374dd2
Files changed (1) hide show
  1. LongConL.py +37 -33
LongConL.py CHANGED
@@ -14,42 +14,44 @@ _URLS = {
14
  "test": "data/LongConL-tasks/{task_name}/test.csv",
15
  }
16
 
17
- _CONFIGS = {
18
- "ATS-Jurisdiction": {
19
- "description": "Jurisdiction-specific legal opinions",
20
- "features": {
21
- "Citation": datasets.Value("string"),
22
- "Full Case Name": datasets.Value("string"),
23
- "Opinion Text": datasets.Value("string"),
24
- "Numerical Label": datasets.Value("string", id=None), # Will be optional for some tasks
25
- "Text Label": datasets.Value("string"),
26
- },
27
- },
28
- "ATS-FavorableJudgment": {
29
- "description": "Description for other task 1",
30
- "features": {
31
- "Citation": datasets.Value("string"),
32
- "Full Case Name": datasets.Value("string"),
33
- "Opinion Text": datasets.Value("string"),
34
- "Numerical Label": datasets.Value("string", id=None),
35
- "Text Label": datasets.Value("string"),
36
- },
37
  }
 
 
 
 
 
 
 
 
38
  }
39
 
 
 
40
 
41
  class LongConLDataset(datasets.GeneratorBasedBuilder):
42
  """Legal opinion classification dataset for LongConL tasks"""
43
 
44
  def _info(self):
45
  """Return dataset information."""
46
- features = datasets.Features({
47
- "Citation": datasets.Value("string"),
48
- "Full Case Name": datasets.Value("string"),
49
- "Opinion Text": datasets.Value("string"),
50
- "Numerical Label": datasets.Value("string"), # Will be optional for some tasks
51
- "Text Label": datasets.Value("string"),
52
- })
53
  return datasets.DatasetInfo(
54
  description=_DESCRIPTION,
55
  features=features,
@@ -96,12 +98,14 @@ class LongConLDataset(datasets.GeneratorBasedBuilder):
96
  "Text Label": row["Text Label"],
97
  }
98
 
99
-
100
-
101
- # Use a dynamic config
102
  BUILDER_CONFIGS = [
103
- datasets.BuilderConfig(name=task_name, version=datasets.Version("1.0.0"), description=task_name)
104
- for task_name in ["ATS-Jurisdiction", "ATS-FavorableJudgment"] # Add your task names here
 
 
 
 
 
105
  ]
106
 
107
-
 
14
  "test": "data/LongConL-tasks/{task_name}/test.csv",
15
  }
16
 
17
+ # Define common features
18
+ common_features = {
19
+ "Citation": datasets.Value("string"),
20
+ "Full Case Name": datasets.Value("string"),
21
+ "Opinion Text": datasets.Value("string"),
22
+ "Text Label": datasets.Value("string"),
23
+ }
24
+
25
+ # Function to create the task configuration
26
+ def create_task_config(task_name, has_numerical_label=True):
27
+ """Create a task configuration based on whether a numerical label exists."""
28
+ features = common_features.copy()
29
+ if has_numerical_label:
30
+ features["Numerical Label"] = datasets.Value("string") # Include numerical label if applicable
31
+
32
+ return {
33
+ "description": f"Description for {task_name}",
34
+ "features": features,
 
 
35
  }
36
+
37
+ # List of task names with their numerical label presence
38
+ tasks = {
39
+ "ATS-Jurisdiction": False,
40
+ "ATS-FavorableJudgment": False,
41
+ "JRC-AREA1": True
42
+
43
+ # Add other tasks here with True/False for numerical label presence
44
  }
45
 
46
+ # Generate the configs dynamically
47
+ _CONFIGS = {task_name: create_task_config(task_name, has_numerical_label) for task_name, has_numerical_label in tasks.items()}
48
 
49
  class LongConLDataset(datasets.GeneratorBasedBuilder):
50
  """Legal opinion classification dataset for LongConL tasks"""
51
 
52
  def _info(self):
53
  """Return dataset information."""
54
+ features = self.config.features # Use the features from the current config
 
 
 
 
 
 
55
  return datasets.DatasetInfo(
56
  description=_DESCRIPTION,
57
  features=features,
 
98
  "Text Label": row["Text Label"],
99
  }
100
 
101
+ # Use a dynamic config for all tasks
 
 
102
  BUILDER_CONFIGS = [
103
+ datasets.BuilderConfig(
104
+ name=task_name,
105
+ version=datasets.Version("1.0.0"),
106
+ description=config["description"],
107
+ features=config["features"],
108
+ )
109
+ for task_name, config in _CONFIGS.items()
110
  ]
111