hyp1231 commited on
Commit
1e3f036
1 Parent(s): 33090b3

Fix bugs of missing key

Browse files
Files changed (1) hide show
  1. Amazon-Review-2023.py +37 -2
Amazon-Review-2023.py CHANGED
@@ -65,7 +65,34 @@ class AmazonReview2023(datasets.GeneratorBasedBuilder):
65
 
66
  def _info(self):
67
  return datasets.DatasetInfo(
68
- description=_AMAZON_REVIEW_2023_DESCRIPTION + self.config.description
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  )
70
 
71
  def _split_generators(self, dl_manager):
@@ -95,7 +122,15 @@ class AmazonReview2023(datasets.GeneratorBasedBuilder):
95
  dp['price'] = str(dp['price'])
96
  for optional_key in ['subtitle', 'author']:
97
  if optional_key not in dp:
98
- dp[optional_key] = ''
 
 
 
 
 
 
 
 
99
  except:
100
  continue
101
  else:
 
65
 
66
  def _info(self):
67
  return datasets.DatasetInfo(
68
+ description=_AMAZON_REVIEW_2023_DESCRIPTION + self.config.description,
69
+ features=datasets.Features({
70
+ 'main_category': datasets.Value('string'),
71
+ 'title': datasets.Value('string'),
72
+ 'average_rating': datasets.Value(dtype='float64'),
73
+ 'rating_number': datasets.Value(dtype='int64'),
74
+ 'features': datasets.Sequence(datasets.Value('string')),
75
+ 'description': datasets.Sequence(datasets.Value('string')),
76
+ 'price': datasets.Value('string'),
77
+ 'images': datasets.Sequence({
78
+ 'hi_res': datasets.Value('string'),
79
+ 'large': datasets.Value('string'),
80
+ 'thumb': datasets.Value('string'),
81
+ 'variant': datasets.Value('string')
82
+ }),
83
+ 'videos': datasets.Sequence({
84
+ 'title': datasets.Value('string'),
85
+ 'url': datasets.Value('string'),
86
+ 'user_id': datasets.Value('string')
87
+ }),
88
+ 'store': datasets.Value('string'),
89
+ 'categories': datasets.Sequence(datasets.Value('string')),
90
+ 'details': datasets.Value('string'),
91
+ 'parent_asin': datasets.Value('string'),
92
+ 'bought_together': datasets.Value(dtype='null', id=None),
93
+ 'subtitle': datasets.Value('string'),
94
+ 'author': datasets.Value('string')
95
+ })
96
  )
97
 
98
  def _split_generators(self, dl_manager):
 
122
  dp['price'] = str(dp['price'])
123
  for optional_key in ['subtitle', 'author']:
124
  if optional_key not in dp:
125
+ dp[optional_key] = None
126
+ for i in range(len(dp['images'])):
127
+ for k in ['hi_res', 'large', 'thumb', 'variant']:
128
+ if k not in dp['images'][i]:
129
+ dp['images'][i][k] = None
130
+ for i in range(len(dp['videos'])):
131
+ for k in ['title', 'url', 'user_id']:
132
+ if k not in dp['videos'][i]:
133
+ dp['videos'][i][k] = None
134
  except:
135
  continue
136
  else: