Datasets:

srzhang commited on
Commit
a926970
·
1 Parent(s): d128568
Files changed (2) hide show
  1. LongConL.py +15 -7
  2. load_data.py +23 -0
LongConL.py CHANGED
@@ -7,12 +7,11 @@ _DESCRIPTION = """"""
7
  _HOMEPAGE = ""
8
  _LICENSE = ""
9
 
10
- # URLs for the dataset (since it's hosted on Hugging Face, you'll load directly from there)
11
  _URLS = {
12
- "train": "data/LongConL-tasks/train.csv",
13
- "validation": "data/LongConL-tasks/validation.csv",
14
- "test": "data/LongConL-tasks/test.csv",
15
- "all": "data/LongConL-tasks/{task_name}.csv"
16
  }
17
 
18
  # Configuration for tasks
@@ -38,7 +37,7 @@ class LongConLDataset(datasets.GeneratorBasedBuilder):
38
  datasets.BuilderConfig(
39
  name=task_name, version=datasets.Version("1.0.0"), description=task_name
40
  )
41
- for task_name in _CONFIGS
42
  ]
43
 
44
  def _info(self):
@@ -54,7 +53,10 @@ class LongConLDataset(datasets.GeneratorBasedBuilder):
54
 
55
  def _split_generators(self, dl_manager):
56
  """Split the dataset into train, validation, and test."""
57
- downloaded_files = dl_manager.download_and_extract(_URLS)
 
 
 
58
  return [
59
  datasets.SplitGenerator(
60
  name=datasets.Split.TRAIN,
@@ -68,6 +70,12 @@ class LongConLDataset(datasets.GeneratorBasedBuilder):
68
  "file_path": downloaded_files["validation"],
69
  },
70
  ),
 
 
 
 
 
 
71
  ]
72
 
73
  def _generate_examples(self, file_path):
 
7
  _HOMEPAGE = ""
8
  _LICENSE = ""
9
 
10
+ # Updated URLs to dynamically handle task names
11
  _URLS = {
12
+ "train": "data/LongConL-tasks/{task_name}/train.csv",
13
+ "validation": "data/LongConL-tasks/{task_name}/validation.csv",
14
+ "test": "data/LongConL-tasks/{task_name}/test.csv",
 
15
  }
16
 
17
  # Configuration for tasks
 
37
  datasets.BuilderConfig(
38
  name=task_name, version=datasets.Version("1.0.0"), description=task_name
39
  )
40
+ for task_name in _CONFIGS # Assuming _CONFIGS contains all task names
41
  ]
42
 
43
  def _info(self):
 
53
 
54
  def _split_generators(self, dl_manager):
55
  """Split the dataset into train, validation, and test."""
56
+ task_name = self.config.name # Get the current task name from the config
57
+ urls = {key: val.format(task_name=task_name) for key, val in _URLS.items()} # Update URLs with the task name
58
+ downloaded_files = dl_manager.download_and_extract(urls)
59
+
60
  return [
61
  datasets.SplitGenerator(
62
  name=datasets.Split.TRAIN,
 
70
  "file_path": downloaded_files["validation"],
71
  },
72
  ),
73
+ datasets.SplitGenerator(
74
+ name=datasets.Split.TEST,
75
+ gen_kwargs={
76
+ "file_path": downloaded_files["test"],
77
+ },
78
+ ),
79
  ]
80
 
81
  def _generate_examples(self, file_path):
load_data.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datasets import load_dataset
2
+ from longconl_dataset import LongConLDataset # Import the dataset class
3
+ from huggingface_hub import login
4
+
5
+ # Login to Hugging Face using your token
6
+ login(token="") # Replace with your actual token
7
+
8
+ # Specify the task name you want to load
9
+ task_name = "ATS-Jurisdiction" # Replace with your desired task
10
+
11
+ # Load the dataset
12
+ dataset = load_dataset(LongConLDataset, name=task_name)
13
+
14
+ # Access train, validation, and test splits
15
+ train_dataset = dataset['train']
16
+ validation_dataset = dataset['validation']
17
+ test_dataset = dataset['test']
18
+
19
+ # Now you can use these datasets as needed
20
+ print(train_dataset)
21
+ print(validation_dataset)
22
+ print(test_dataset)
23
+