Datasets:

srzhang commited on
Commit
e55621c
·
1 Parent(s): 5c1f9f0
Files changed (1) hide show
  1. LongConL.py +45 -35
LongConL.py CHANGED
@@ -14,45 +14,56 @@ _URLS = {
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
- # Add other tasks here with True/False for numerical label presence
43
  }
44
 
45
- # Generate the configs dynamically
46
- _CONFIGS = {task_name: create_task_config(task_name, has_numerical_label) for task_name, has_numerical_label in tasks.items()}
47
 
48
  class LongConLDataset(datasets.GeneratorBasedBuilder):
49
  """Legal opinion classification dataset for LongConL tasks"""
50
 
51
  def _info(self):
52
  """Return dataset information."""
53
- features = self.config.features # Use the features from the current config
 
 
 
 
 
 
54
  return datasets.DatasetInfo(
55
- description=_CONFIGS[self.config.name]["description"], # Get description from _CONFIGS
56
  features=features,
57
  homepage=_HOMEPAGE,
58
  citation=_CITATION,
@@ -97,13 +108,12 @@ class LongConLDataset(datasets.GeneratorBasedBuilder):
97
  "Text Label": row["Text Label"],
98
  }
99
 
100
- # Use a dynamic config for all tasks
 
 
101
  BUILDER_CONFIGS = [
102
- datasets.BuilderConfig(
103
- name=task_name,
104
- version=datasets.Version("1.0.0"),
105
- description=config["description"],
106
- )
107
- for task_name, config in _CONFIGS.items()
108
  ]
109
 
 
 
14
  "test": "data/LongConL-tasks/{task_name}/test.csv",
15
  }
16
 
17
+ TASK_NAMES = ["ATS-Jurisdiction", "ATS-FavorableJudgment"] # Add more task names as needed
 
 
 
 
 
 
18
 
19
+ _CONFIGS = {
20
+ task_name: {
21
+ "description": "Jurisdiction-specific legal opinions",
22
+ "features": {
23
+ "Citation": datasets.Value("string"),
24
+ "Full Case Name": datasets.Value("string"),
25
+ "Opinion Text": datasets.Value("string"),
26
+ "Numerical Label": datasets.Value("string"), # Will be optional for some tasks
27
+ "Text Label": datasets.Value("string"),
28
+ },
29
+ },
30
+ "ATS-FavorableJudgment": {
31
+ "description": "Description for other task 1",
32
+ "features": {
33
+ "Citation": datasets.Value("string"),
34
+ "Full Case Name": datasets.Value("string"),
35
+ "Opinion Text": datasets.Value("string"),
36
+ "Numerical Label": datasets.Value("string", id=None),
37
+ "Text Label": datasets.Value("string"),
38
+ },
39
+ },
40
+ "ATS-FavorableJudgment": {
41
+ "description": "Description for other task 1",
42
+ "features": {
43
+ "Citation": datasets.Value("string"),
44
+ "Full Case Name": datasets.Value("string"),
45
+ "Opinion Text": datasets.Value("string"),
46
+ "Numerical Label": datasets.Value("string", id=None),
47
+ "Text Label": datasets.Value("string"),
48
+ },
49
  }
 
 
 
 
 
 
 
50
  }
51
 
 
 
52
 
53
  class LongConLDataset(datasets.GeneratorBasedBuilder):
54
  """Legal opinion classification dataset for LongConL tasks"""
55
 
56
  def _info(self):
57
  """Return dataset information."""
58
+ features = datasets.Features({
59
+ "Citation": datasets.Value("string"),
60
+ "Full Case Name": datasets.Value("string"),
61
+ "Opinion Text": datasets.Value("string"),
62
+ "Numerical Label": datasets.Value("string"), # Will be optional for some tasks
63
+ "Text Label": datasets.Value("string"),
64
+ })
65
  return datasets.DatasetInfo(
66
+ description=_DESCRIPTION,
67
  features=features,
68
  homepage=_HOMEPAGE,
69
  citation=_CITATION,
 
108
  "Text Label": row["Text Label"],
109
  }
110
 
111
+
112
+
113
+ # Use a dynamic config
114
  BUILDER_CONFIGS = [
115
+ datasets.BuilderConfig(name=task_name, version=datasets.Version("1.0.0"), description=task_name)
116
+ for task_name in ["ATS-Jurisdiction", "ATS-FavorableJudgment",] # Add your task names here
 
 
 
 
117
  ]
118
 
119
+