tombryan commited on
Commit
408407a
1 Parent(s): f7ccb61

Fixing date and article id problems

Browse files
Files changed (1) hide show
  1. AmericanStories.py +3 -4
AmericanStories.py CHANGED
@@ -144,6 +144,7 @@ class AmericanStories(datasets.GeneratorBasedBuilder):
144
  urls = {year: urls[year] for year in self.config.year_list if year in SUPPORTED_YEARS}
145
  year_list = self.config.year_list
146
 
 
147
  archive = dl_manager.download(urls)
148
 
149
  # Return a list of splits, where each split corresponds to a year
@@ -170,8 +171,8 @@ class AmericanStories(datasets.GeneratorBasedBuilder):
170
  Yields:
171
  tuple: The key-value pair containing the example ID and the example data.
172
  """
173
- print("Associated: " + str(associated))
174
  if associated:
 
175
  for filepath, f in files:
176
  if filepath.startswith(year_dir):
177
  try :
@@ -180,6 +181,7 @@ class AmericanStories(datasets.GeneratorBasedBuilder):
180
  print("Error loading file: " + filepath)
181
  continue
182
  if "lccn" in data.keys():
 
183
  scan_id = filepath.split('.')[0]
184
  scan_date = filepath.split("_")[0]
185
  scan_page = filepath.split("_")[1]
@@ -199,7 +201,6 @@ class AmericanStories(datasets.GeneratorBasedBuilder):
199
  "article": article["article"],
200
  }
201
  else:
202
- print("Returning a json as a string, feel free to parse it yourself!")
203
  for filepath, f in files:
204
  if filepath.startswith(year_dir):
205
  try :
@@ -214,5 +215,3 @@ class AmericanStories(datasets.GeneratorBasedBuilder):
214
  yield scan_id, {
215
  "raw_data_string": str(data)
216
  }
217
-
218
-
 
144
  urls = {year: urls[year] for year in self.config.year_list if year in SUPPORTED_YEARS}
145
  year_list = self.config.year_list
146
 
147
+ print(urls)
148
  archive = dl_manager.download(urls)
149
 
150
  # Return a list of splits, where each split corresponds to a year
 
171
  Yields:
172
  tuple: The key-value pair containing the example ID and the example data.
173
  """
 
174
  if associated:
175
+ print('Loading associated')
176
  for filepath, f in files:
177
  if filepath.startswith(year_dir):
178
  try :
 
181
  print("Error loading file: " + filepath)
182
  continue
183
  if "lccn" in data.keys():
184
+ filepath = filepath.split("/")[-1]
185
  scan_id = filepath.split('.')[0]
186
  scan_date = filepath.split("_")[0]
187
  scan_page = filepath.split("_")[1]
 
201
  "article": article["article"],
202
  }
203
  else:
 
204
  for filepath, f in files:
205
  if filepath.startswith(year_dir):
206
  try :
 
215
  yield scan_id, {
216
  "raw_data_string": str(data)
217
  }