Francisco Castillo commited on
Commit
42ed38f
1 Parent(s): 4877d43
Files changed (1) hide show
  1. reviews_with_drift.py +12 -9
reviews_with_drift.py CHANGED
@@ -189,12 +189,15 @@ class NewDataset(datasets.GeneratorBasedBuilder):
189
  def _generate_examples(self, filepath, split):
190
  # TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
191
  # The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
192
- with open(filepath, encoding="utf-8") as f:
193
- yield 33, {
194
- "prediction_ts":99,
195
- "age":11,
196
- "gender":"maleish",
197
- "context":"movielike",
198
- "text": f.read(),
199
- "label":"Negative"
200
- }
 
 
 
 
189
  def _generate_examples(self, filepath, split):
190
  # TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
191
  # The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
192
+ with open(filepath, encoding="utf-8") as csv_file:
193
+ csv_reader = csv.reader(csv_file)
194
+ for id_, row in enumerate(csv_reader):
195
+ prediction_ts,age,gender,context,text,label = row
196
+ yield id_, {
197
+ "prediction_ts":prediction_ts,
198
+ "age":age,
199
+ "gender":gender,
200
+ "context":context,
201
+ "text": text,
202
+ "label":label
203
+ }