hyp1231 commited on
Commit
9826c99
1 Parent(s): 1e3f036

Add script for reviews

Browse files
Files changed (1) hide show
  1. Amazon-Review-2023.py +55 -4
Amazon-Review-2023.py CHANGED
@@ -24,6 +24,16 @@ class RawMetaAmazonReview2023Config(datasets.BuilderConfig):
24
  self.data_dir = f'raw/meta_categories/meta_{self.domain}.jsonl'
25
 
26
 
 
 
 
 
 
 
 
 
 
 
27
  class AmazonReview2023(datasets.GeneratorBasedBuilder):
28
  BUILDER_CONFIGS = [
29
  # Raw item metadata
@@ -61,12 +71,46 @@ class AmazonReview2023(datasets.GeneratorBasedBuilder):
61
  RawMetaAmazonReview2023Config(name='raw_meta_Health_and_Personal_Care'),
62
  RawMetaAmazonReview2023Config(name='raw_meta_Appliances'),
63
  RawMetaAmazonReview2023Config(name='raw_meta_Movies_and_TV'),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  ]
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'),
@@ -89,10 +133,17 @@ class AmazonReview2023(datasets.GeneratorBasedBuilder):
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):
 
24
  self.data_dir = f'raw/meta_categories/meta_{self.domain}.jsonl'
25
 
26
 
27
+ class RawReviewAmazonReview2023Config(datasets.BuilderConfig):
28
+ def __init__(self, **kwargs):
29
+ super(RawReviewAmazonReview2023Config, self).__init__(**kwargs)
30
+
31
+ self.suffix = 'jsonl'
32
+ self.domain = self.name[len(f'raw_review_'):]
33
+ self.description = f'This is a subset for reviews in domain: {self.domain}.'
34
+ self.data_dir = f'raw/review_categories/{self.domain}.jsonl'
35
+
36
+
37
  class AmazonReview2023(datasets.GeneratorBasedBuilder):
38
  BUILDER_CONFIGS = [
39
  # Raw item metadata
 
71
  RawMetaAmazonReview2023Config(name='raw_meta_Health_and_Personal_Care'),
72
  RawMetaAmazonReview2023Config(name='raw_meta_Appliances'),
73
  RawMetaAmazonReview2023Config(name='raw_meta_Movies_and_TV'),
74
+ RawReviewAmazonReview2023Config(name='raw_review_All_Beauty'),
75
+ RawReviewAmazonReview2023Config(name='raw_review_Toys_and_Games'),
76
+ RawReviewAmazonReview2023Config(name='raw_review_Cell_Phones_and_Accessories'),
77
+ RawReviewAmazonReview2023Config(name='raw_review_Industrial_and_Scientific'),
78
+ RawReviewAmazonReview2023Config(name='raw_review_Gift_Cards'),
79
+ RawReviewAmazonReview2023Config(name='raw_review_Musical_Instruments'),
80
+ RawReviewAmazonReview2023Config(name='raw_review_Electronics'),
81
+ RawReviewAmazonReview2023Config(name='raw_review_Handmade_Products'),
82
+ RawReviewAmazonReview2023Config(name='raw_review_Arts_Crafts_and_Sewing'),
83
+ RawReviewAmazonReview2023Config(name='raw_review_Baby_Products'),
84
+ RawReviewAmazonReview2023Config(name='raw_review_Health_and_Household'),
85
+ RawReviewAmazonReview2023Config(name='raw_review_Office_Products'),
86
+ RawReviewAmazonReview2023Config(name='raw_review_Digital_Music'),
87
+ RawReviewAmazonReview2023Config(name='raw_review_Grocery_and_Gourmet_Food'),
88
+ RawReviewAmazonReview2023Config(name='raw_review_Sports_and_Outdoors'),
89
+ RawReviewAmazonReview2023Config(name='raw_review_Home_and_Kitchen'),
90
+ RawReviewAmazonReview2023Config(name='raw_review_Subscription_Boxes'),
91
+ RawReviewAmazonReview2023Config(name='raw_review_Tools_and_Home_Improvement'),
92
+ RawReviewAmazonReview2023Config(name='raw_review_Pet_Supplies'),
93
+ RawReviewAmazonReview2023Config(name='raw_review_Video_Games'),
94
+ RawReviewAmazonReview2023Config(name='raw_review_Kindle_Store'),
95
+ RawReviewAmazonReview2023Config(name='raw_review_Clothing_Shoes_and_Jewelry'),
96
+ RawReviewAmazonReview2023Config(name='raw_review_Patio_Lawn_and_Garden'),
97
+ RawReviewAmazonReview2023Config(name='raw_review_Unknown'),
98
+ RawReviewAmazonReview2023Config(name='raw_review_Books'),
99
+ RawReviewAmazonReview2023Config(name='raw_review_Automotive'),
100
+ RawReviewAmazonReview2023Config(name='raw_review_CDs_and_Vinyl'),
101
+ RawReviewAmazonReview2023Config(name='raw_review_Beauty_and_Personal_Care'),
102
+ RawReviewAmazonReview2023Config(name='raw_review_Amazon_Fashion'),
103
+ RawReviewAmazonReview2023Config(name='raw_review_Magazine_Subscriptions'),
104
+ RawReviewAmazonReview2023Config(name='raw_review_Software'),
105
+ RawReviewAmazonReview2023Config(name='raw_review_Health_and_Personal_Care'),
106
+ RawReviewAmazonReview2023Config(name='raw_review_Appliances'),
107
+ RawReviewAmazonReview2023Config(name='raw_review_Movies_and_TV'),
108
  ]
109
 
110
  def _info(self):
111
+ features = None
112
+ if isinstance(self.config, RawMetaAmazonReview2023Config):
113
+ features = datasets.Features({
114
  'main_category': datasets.Value('string'),
115
  'title': datasets.Value('string'),
116
  'average_rating': datasets.Value(dtype='float64'),
 
133
  'categories': datasets.Sequence(datasets.Value('string')),
134
  'details': datasets.Value('string'),
135
  'parent_asin': datasets.Value('string'),
136
+ 'bought_together': datasets.Value('string'), # TODO: Check this type
137
  'subtitle': datasets.Value('string'),
138
  'author': datasets.Value('string')
139
  })
140
+ elif isinstance(self.config, RawReviewAmazonReview2023Config):
141
+ # TODO: Check review features
142
+ pass
143
+
144
+ return datasets.DatasetInfo(
145
+ description=_AMAZON_REVIEW_2023_DESCRIPTION + self.config.description,
146
+ features=features
147
  )
148
 
149
  def _split_generators(self, dl_manager):