Datasets:
Upload knessetCorpus.py
Browse files- knessetCorpus.py +13 -4
knessetCorpus.py
CHANGED
@@ -370,10 +370,19 @@ class KnessetCorpus(datasets.GeneratorBasedBuilder):
|
|
370 |
continue
|
371 |
for feature in self._info().features:
|
372 |
sample[feature] = row[feature]
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
377 |
except Exception as e:
|
378 |
print(f"Error opening file '{filepath}': {e}. Skipping.")
|
379 |
|
|
|
370 |
continue
|
371 |
for feature in self._info().features:
|
372 |
sample[feature] = row[feature]
|
373 |
+
|
374 |
+
# Handle nested structures (e.g., `protocol_sentences`)
|
375 |
+
if "protocol_sentences" in row:
|
376 |
+
protocol_sentences = row.get("protocol_sentences", [])
|
377 |
+
for sentence in protocol_sentences:
|
378 |
+
sentence_id = sentence.get("sentence_id", None)
|
379 |
+
if sentence_id:
|
380 |
+
yield sentence_id, sentence
|
381 |
+
else:
|
382 |
+
try:
|
383 |
+
yield id_, sample
|
384 |
+
except Exception as e:
|
385 |
+
print(f'couldnt yield sample. error: {e}. sample is: {sample}.', flush=True)
|
386 |
except Exception as e:
|
387 |
print(f"Error opening file '{filepath}': {e}. Skipping.")
|
388 |
|