xavierdurawa commited on
Commit
1b35e27
1 Parent(s): 6b0aeb8

Update proof-pile-2.py

Browse files
Files changed (1) hide show
  1. proof-pile-2.py +21 -10
proof-pile-2.py CHANGED
@@ -187,13 +187,24 @@ class ProofPile2(datasets.GeneratorBasedBuilder):
187
  ]
188
 
189
  def _generate_examples(self, data_files):
190
- key = 0
191
- for name in data_files:
192
- with zstd.open(open(name, "rb"), "rt", encoding="utf-8") as f:
193
- for x in f.readlines():
194
- instance = json.loads(x)
195
- if instance:
196
- if "meta" not in instance:
197
- instance["meta"] = dict()
198
- yield key, {"text": instance["text"], "meta": json.dumps(instance["meta"])}
199
- key += 1
 
 
 
 
 
 
 
 
 
 
 
 
187
  ]
188
 
189
  def _generate_examples(self, data_files):
190
+ key = 0
191
+ for name in data_files:
192
+ print( "###{}####".format(name))
193
+ try:
194
+ with zstd.open(open(name, "rb"), "rt", encoding="utf-8") as f:
195
+ for x in f.readlines():
196
+ instance = json.loads(x)
197
+ if instance:
198
+ if "meta" not in instance:
199
+ instance["meta"] = dict()
200
+ yield key, {"text": instance["text"], "meta": json.dumps(instance["meta"])}
201
+ key += 1
202
+ except:
203
+ with open(name, "r", encoding="utf-8") as f:
204
+ for x in f.readlines():
205
+ instance = json.loads(x)
206
+ if instance:
207
+ if "meta" not in instance:
208
+ instance["meta"] = dict()
209
+ yield key, {"text": instance["text"], "meta": json.dumps(instance["meta"])}
210
+ key += 1