martingrzzler commited on
Commit
d0ece79
1 Parent(s): 0f82e58

Update kanjis2radicals.py

Browse files
Files changed (1) hide show
  1. kanjis2radicals.py +10 -4
kanjis2radicals.py CHANGED
@@ -52,10 +52,16 @@ class Kanji2Radicals(datasets.GeneratorBasedBuilder):
52
  ]
53
 
54
  def _generate_examples(self, metadata_path, images_iter):
 
 
55
  with open(metadata_path, encoding="utf-8") as f:
56
  for line in f:
57
  metadata = json.loads(line)
58
- yield metadata["id"], {
59
- "kanji_image": next(iter(images_iter)).read(),
60
- "radicals": metadata,
61
- }
 
 
 
 
 
52
  ]
53
 
54
  def _generate_examples(self, metadata_path, images_iter):
55
+ radicals = []
56
+
57
  with open(metadata_path, encoding="utf-8") as f:
58
  for line in f:
59
  metadata = json.loads(line)
60
+ radicals.append(metadata)
61
+
62
+ for idx, (image_path, image) in enumerate(images_iter):
63
+ yield image_path, {
64
+ "radicals": radicals[idx],
65
+ "kanji_image": image.read(),
66
+ }
67
+