davidlms commited on
Commit
911a721
1 Parent(s): 767a613

Update letras-carnaval-cadiz.py

Browse files
Files changed (1) hide show
  1. letras-carnaval-cadiz.py +13 -1
letras-carnaval-cadiz.py CHANGED
@@ -84,8 +84,20 @@ class CadizCarnivalDataset(GeneratorBasedBuilder):
84
  elif self.config.name == "midaccurate":
85
  return [SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["midaccurate"]})]
86
  else: # Default is "all"
87
- return [SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepaths": [downloaded_files["accurate"], downloaded_files["midaccurate"]]})]
 
 
 
 
 
88
 
 
 
 
 
 
 
 
89
  def _generate_examples(self, filepath: str):
90
  with open(filepath, encoding="utf-8") as f:
91
  data = json.load(f)
 
84
  elif self.config.name == "midaccurate":
85
  return [SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["midaccurate"]})]
86
  else: # Default is "all"
87
+ # Load both JSON files and combine them
88
+ with open(downloaded_files["accurate"], 'r') as f:
89
+ data_accurate = json.load(f)
90
+ with open(downloaded_files["midaccurate"], 'r') as f:
91
+ data_midaccurate = json.load(f)
92
+ data_all = data_accurate + data_midaccurate
93
 
94
+ # Write the combined data to a new JSON file
95
+ all_filepath = os.path.join(os.path.dirname(downloaded_files["accurate"]), 'all.json')
96
+ with open(all_filepath, 'w') as f:
97
+ json.dump(data_all, f)
98
+
99
+ return [SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": all_filepath})]
100
+
101
  def _generate_examples(self, filepath: str):
102
  with open(filepath, encoding="utf-8") as f:
103
  data = json.load(f)