Datasets:

GiliGold commited on
Commit
c3f3d58
·
verified ·
1 Parent(s): f5d9f50

Upload knessetCorpus.py

Browse files
Files changed (1) hide show
  1. knessetCorpus.py +8 -10
knessetCorpus.py CHANGED
@@ -395,16 +395,14 @@ class KnessetCorpus(datasets.GeneratorBasedBuilder):
395
  print(f"Key '{id_field_name}' not found in row. Skipping this row. row is: {row}")
396
  continue
397
  for feature in self._info().features:
398
- sample[feature] = row[feature]
399
-
400
- # Handle nested structures (e.g., `protocol_sentences`)
401
- # if "protocol_sentences" in row:
402
- # protocol_sentences = row.get("protocol_sentences", [])
403
- # for sentence in protocol_sentences:
404
- # sentence_id = sentence.get("sentence_id", None)
405
- # if sentence_id:
406
- # yield sentence_id, sentence
407
- # else:
408
  try:
409
  yield id_, sample
410
  except Exception as e:
 
395
  print(f"Key '{id_field_name}' not found in row. Skipping this row. row is: {row}")
396
  continue
397
  for feature in self._info().features:
398
+ if feature == "protocol_sentences":
399
+ sample[feature] = []
400
+ protocol_sentences = row.get("protocol_sentences", [])
401
+ for sentence in protocol_sentences:
402
+ sample[feature].append(sentence)
403
+ else:
404
+ sample[feature] = row[feature]
405
+
 
 
406
  try:
407
  yield id_, sample
408
  except Exception as e: