lara-martin commited on
Commit
36f34c4
1 Parent(s): cbf2696

reading files from list

Browse files
Files changed (1) hide show
  1. FIREBALL.py +7 -4
FIREBALL.py CHANGED
@@ -54,7 +54,7 @@ _LICENSE = "cc-by-4.0"
54
  # The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
55
  # This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
56
  _URLS = {
57
- "FIREBALL": "https://huggingface.co/datasets/lara-martin/FIREBALL/tree/main/filtered",
58
  }
59
 
60
 
@@ -179,14 +179,17 @@ class Fireball(datasets.GeneratorBasedBuilder):
179
 
180
  def _split_generators(self, dl_manager):
181
  # This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
182
-
183
  url = _URLS[self.config.name]
184
  # dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
185
  # It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
186
  # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
187
  #data_dir = dl_manager.download_and_extract(urls)
188
- downloaded_files = dl_manager.download([f for f in os.listdir(url) if os.path.isfile(f)])
189
- print(downloaded_files)
 
 
 
190
  return [
191
  datasets.SplitGenerator(
192
  name=datasets.Split.TRAIN,
 
54
  # The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
55
  # This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
56
  _URLS = {
57
+ "FIREBALL": "https://huggingface.co/datasets/lara-martin/FIREBALL/tree/main/"
58
  }
59
 
60
 
 
179
 
180
  def _split_generators(self, dl_manager):
181
  # This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
182
+ # based off of OSCAR - https://huggingface.co/datasets/oscar/blob/main/oscar.py
183
  url = _URLS[self.config.name]
184
  # dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
185
  # It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
186
  # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
187
  #data_dir = dl_manager.download_and_extract(urls)
188
+ file_list = dl_manager.download(url+"files.txt")
189
+ with open(file_list) as f:
190
+ data_filenames = [line.strip() for line in f if line]
191
+ data_urls = dl_manager.download([url+"filtered/"+data_filename for data_filename in data_filenames])
192
+ downloaded_files = dl_manager.download(data_urls)
193
  return [
194
  datasets.SplitGenerator(
195
  name=datasets.Split.TRAIN,