Zeb commited on
Commit
ce43a94
1 Parent(s): 4d0612f

Add filename to each text row

Browse files
Files changed (1) hide show
  1. BabyLM.py +3 -1
BabyLM.py CHANGED
@@ -44,6 +44,7 @@ class BabyLM(datasets.GeneratorBasedBuilder):
44
  features = datasets.Features(
45
  {
46
  "text": datasets.Value("string"),
 
47
  }
48
  )
49
  return datasets.DatasetInfo(
@@ -106,6 +107,7 @@ class BabyLM(datasets.GeneratorBasedBuilder):
106
 
107
  for filepath in filepaths:
108
  with open(filepath, encoding="utf-8") as f:
 
109
  for row in f:
110
- yield global_idx, {"text": row}
111
  global_idx += 1
 
44
  features = datasets.Features(
45
  {
46
  "text": datasets.Value("string"),
47
+ "filename": datasets.Value("string"),
48
  }
49
  )
50
  return datasets.DatasetInfo(
 
107
 
108
  for filepath in filepaths:
109
  with open(filepath, encoding="utf-8") as f:
110
+ filename = filepath.split("/")[-1]
111
  for row in f:
112
+ yield global_idx, {"text": row, "filename": filename}
113
  global_idx += 1