Add scripts for rating only files
Browse files- Amazon-Review-2023.py +83 -0
Amazon-Review-2023.py
CHANGED
|
@@ -34,6 +34,19 @@ class RawReviewAmazonReview2023Config(datasets.BuilderConfig):
|
|
| 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,6 +84,7 @@ class AmazonReview2023(datasets.GeneratorBasedBuilder):
|
|
| 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'),
|
|
@@ -105,6 +119,70 @@ class AmazonReview2023(datasets.GeneratorBasedBuilder):
|
|
| 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):
|
|
@@ -157,6 +235,8 @@ class AmazonReview2023(datasets.GeneratorBasedBuilder):
|
|
| 157 |
|
| 158 |
def _generate_examples(self, filepath):
|
| 159 |
with open(filepath, 'r', encoding='utf-8') as file:
|
|
|
|
|
|
|
| 160 |
for idx, line in enumerate(file):
|
| 161 |
if self.config.suffix == 'jsonl':
|
| 162 |
try:
|
|
@@ -184,6 +264,9 @@ class AmazonReview2023(datasets.GeneratorBasedBuilder):
|
|
| 184 |
dp['videos'][i][k] = None
|
| 185 |
except:
|
| 186 |
continue
|
|
|
|
|
|
|
|
|
|
| 187 |
else:
|
| 188 |
raise ValueError(f'Unknown suffix {self.config.suffix}.')
|
| 189 |
yield idx, dp
|
|
|
|
| 34 |
self.data_dir = f'raw/review_categories/{self.domain}.jsonl'
|
| 35 |
|
| 36 |
|
| 37 |
+
class BenchmarkRatingOnlyAmazonReview2023Config(datasets.BuilderConfig):
|
| 38 |
+
def __init__(self, **kwargs):
|
| 39 |
+
super(BenchmarkRatingOnlyAmazonReview2023Config, self).__init__(**kwargs)
|
| 40 |
+
|
| 41 |
+
self.suffix = 'csv'
|
| 42 |
+
self.kcore = self.name[:len('0core')]
|
| 43 |
+
self.domain = self.name[len(f'0core_rating_only_'):]
|
| 44 |
+
self.description = \
|
| 45 |
+
f'This is the preprocessed benchmark in domain: {self.domain}.' \
|
| 46 |
+
f'The preprocessing includes {self.kcore} filtering and <user, item> interaction deduplication'
|
| 47 |
+
self.data_dir = f'benchmark/{self.kcore}/rating_only/{self.domain}.csv'
|
| 48 |
+
|
| 49 |
+
|
| 50 |
class AmazonReview2023(datasets.GeneratorBasedBuilder):
|
| 51 |
BUILDER_CONFIGS = [
|
| 52 |
# Raw item metadata
|
|
|
|
| 84 |
RawMetaAmazonReview2023Config(name='raw_meta_Health_and_Personal_Care'),
|
| 85 |
RawMetaAmazonReview2023Config(name='raw_meta_Appliances'),
|
| 86 |
RawMetaAmazonReview2023Config(name='raw_meta_Movies_and_TV'),
|
| 87 |
+
# Raw review
|
| 88 |
RawReviewAmazonReview2023Config(name='raw_review_All_Beauty'),
|
| 89 |
RawReviewAmazonReview2023Config(name='raw_review_Toys_and_Games'),
|
| 90 |
RawReviewAmazonReview2023Config(name='raw_review_Cell_Phones_and_Accessories'),
|
|
|
|
| 119 |
RawReviewAmazonReview2023Config(name='raw_review_Health_and_Personal_Care'),
|
| 120 |
RawReviewAmazonReview2023Config(name='raw_review_Appliances'),
|
| 121 |
RawReviewAmazonReview2023Config(name='raw_review_Movies_and_TV'),
|
| 122 |
+
# Rating only - 0core
|
| 123 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='0core_rating_only_All_Beauty'),
|
| 124 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='0core_rating_only_Toys_and_Games'),
|
| 125 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='0core_rating_only_Cell_Phones_and_Accessories'),
|
| 126 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='0core_rating_only_Industrial_and_Scientific'),
|
| 127 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='0core_rating_only_Gift_Cards'),
|
| 128 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='0core_rating_only_Musical_Instruments'),
|
| 129 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='0core_rating_only_Electronics'),
|
| 130 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='0core_rating_only_Handmade_Products'),
|
| 131 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='0core_rating_only_Arts_Crafts_and_Sewing'),
|
| 132 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='0core_rating_only_Baby_Products'),
|
| 133 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='0core_rating_only_Health_and_Household'),
|
| 134 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='0core_rating_only_Office_Products'),
|
| 135 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='0core_rating_only_Digital_Music'),
|
| 136 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='0core_rating_only_Grocery_and_Gourmet_Food'),
|
| 137 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='0core_rating_only_Sports_and_Outdoors'),
|
| 138 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='0core_rating_only_Home_and_Kitchen'),
|
| 139 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='0core_rating_only_Subscription_Boxes'),
|
| 140 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='0core_rating_only_Tools_and_Home_Improvement'),
|
| 141 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='0core_rating_only_Pet_Supplies'),
|
| 142 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='0core_rating_only_Video_Games'),
|
| 143 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='0core_rating_only_Kindle_Store'),
|
| 144 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='0core_rating_only_Clothing_Shoes_and_Jewelry'),
|
| 145 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='0core_rating_only_Patio_Lawn_and_Garden'),
|
| 146 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='0core_rating_only_Unknown'),
|
| 147 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='0core_rating_only_Books'),
|
| 148 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='0core_rating_only_Automotive'),
|
| 149 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='0core_rating_only_CDs_and_Vinyl'),
|
| 150 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='0core_rating_only_Beauty_and_Personal_Care'),
|
| 151 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='0core_rating_only_Amazon_Fashion'),
|
| 152 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='0core_rating_only_Magazine_Subscriptions'),
|
| 153 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='0core_rating_only_Software'),
|
| 154 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='0core_rating_only_Health_and_Personal_Care'),
|
| 155 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='0core_rating_only_Appliances'),
|
| 156 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='0core_rating_only_Movies_and_TV'),
|
| 157 |
+
# Rating only - 5core
|
| 158 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='5core_rating_only_All_Beauty'),
|
| 159 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='5core_rating_only_Toys_and_Games'),
|
| 160 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='5core_rating_only_Cell_Phones_and_Accessories'),
|
| 161 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='5core_rating_only_Industrial_and_Scientific'),
|
| 162 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='5core_rating_only_Gift_Cards'),
|
| 163 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='5core_rating_only_Musical_Instruments'),
|
| 164 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='5core_rating_only_Electronics'),
|
| 165 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='5core_rating_only_Arts_Crafts_and_Sewing'),
|
| 166 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='5core_rating_only_Baby_Products'),
|
| 167 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='5core_rating_only_Health_and_Household'),
|
| 168 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='5core_rating_only_Office_Products'),
|
| 169 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='5core_rating_only_Grocery_and_Gourmet_Food'),
|
| 170 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='5core_rating_only_Sports_and_Outdoors'),
|
| 171 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='5core_rating_only_Home_and_Kitchen'),
|
| 172 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='5core_rating_only_Tools_and_Home_Improvement'),
|
| 173 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='5core_rating_only_Pet_Supplies'),
|
| 174 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='5core_rating_only_Video_Games'),
|
| 175 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='5core_rating_only_Kindle_Store'),
|
| 176 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='5core_rating_only_Clothing_Shoes_and_Jewelry'),
|
| 177 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='5core_rating_only_Patio_Lawn_and_Garden'),
|
| 178 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='5core_rating_only_Unknown'),
|
| 179 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='5core_rating_only_Books'),
|
| 180 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='5core_rating_only_Automotive'),
|
| 181 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='5core_rating_only_CDs_and_Vinyl'),
|
| 182 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='5core_rating_only_Beauty_and_Personal_Care'),
|
| 183 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='5core_rating_only_Magazine_Subscriptions'),
|
| 184 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='5core_rating_only_Software'),
|
| 185 |
+
BenchmarkRatingOnlyAmazonReview2023Config(name='5core_rating_only_Movies_and_TV'),
|
| 186 |
]
|
| 187 |
|
| 188 |
def _info(self):
|
|
|
|
| 235 |
|
| 236 |
def _generate_examples(self, filepath):
|
| 237 |
with open(filepath, 'r', encoding='utf-8') as file:
|
| 238 |
+
if self.config.suffix == 'csv':
|
| 239 |
+
colnames = file.readline().strip().split(',')
|
| 240 |
for idx, line in enumerate(file):
|
| 241 |
if self.config.suffix == 'jsonl':
|
| 242 |
try:
|
|
|
|
| 264 |
dp['videos'][i][k] = None
|
| 265 |
except:
|
| 266 |
continue
|
| 267 |
+
elif self.config.suffix == 'csv':
|
| 268 |
+
line = line.strip().split(',')
|
| 269 |
+
dp = {k: v for k, v in zip(colnames, line)}
|
| 270 |
else:
|
| 271 |
raise ValueError(f'Unknown suffix {self.config.suffix}.')
|
| 272 |
yield idx, dp
|