zeio commited on
Commit
804d60f
1 Parent(s): 26fa41e

fix(loader): updated the format of entries in the loader script

Browse files
Files changed (1) hide show
  1. batch.py +14 -13
batch.py CHANGED
@@ -19,7 +19,7 @@ _URLS = {
19
  }
20
  _INDEX = 'https://huggingface.co/datasets/zeio/batch/resolve/main/index.tsv'
21
 
22
- _N_ITEMS = 40
23
  _N_BATCH = 20
24
 
25
 
@@ -49,21 +49,21 @@ class Batch(GeneratorBasedBuilder):
49
  if self.config.name == 'written':
50
  features = Features({
51
  'title': Value('string'),
52
- 'topics': Sequence({
53
- 'posts': Sequence({
54
  'text': Value('string')
55
- })
56
- })
57
  })
58
  elif self.config.name == 'spoken':
59
  features = Features({
60
  'title': Value('string'),
61
  'speech': Audio(sampling_rate = 48_000),
62
- 'topics': Sequence({
63
- 'posts': Sequence({
64
  'text': Value('string')
65
- })
66
- })
67
  })
68
  else:
69
  raise ValueError(f'Unknown config: {self.config.name}')
@@ -121,7 +121,10 @@ class Batch(GeneratorBasedBuilder):
121
  for i, row in read_csv(index, sep = '\t').iterrows():
122
  # print(row)
123
 
124
- path = os.path.join(written[row['path']], f'{row["thread"]}.txt')
 
 
 
125
 
126
  topics = []
127
  posts = []
@@ -150,9 +153,7 @@ class Batch(GeneratorBasedBuilder):
150
  'topics': topics
151
  }
152
 
153
- if spoken is None:
154
- item['speech'] = None
155
- else:
156
  speech_cluster_path = spoken.get(row['path'])
157
 
158
  if speech_cluster_path is None:
 
19
  }
20
  _INDEX = 'https://huggingface.co/datasets/zeio/batch/resolve/main/index.tsv'
21
 
22
+ _N_ITEMS = 1750
23
  _N_BATCH = 20
24
 
25
 
 
49
  if self.config.name == 'written':
50
  features = Features({
51
  'title': Value('string'),
52
+ 'topics': [{
53
+ 'posts': [{
54
  'text': Value('string')
55
+ }]
56
+ }]
57
  })
58
  elif self.config.name == 'spoken':
59
  features = Features({
60
  'title': Value('string'),
61
  'speech': Audio(sampling_rate = 48_000),
62
+ 'topics': [{
63
+ 'posts': [{
64
  'text': Value('string')
65
+ }]
66
+ }]
67
  })
68
  else:
69
  raise ValueError(f'Unknown config: {self.config.name}')
 
121
  for i, row in read_csv(index, sep = '\t').iterrows():
122
  # print(row)
123
 
124
+ try:
125
+ path = os.path.join(written[row['path']], f'{row["thread"]}.txt')
126
+ except KeyError:
127
+ break
128
 
129
  topics = []
130
  posts = []
 
153
  'topics': topics
154
  }
155
 
156
+ if spoken is not None:
 
 
157
  speech_cluster_path = spoken.get(row['path'])
158
 
159
  if speech_cluster_path is None: