File size: 644 Bytes
2b31b25
 
 
 
8c0d5e4
2b31b25
 
 
 
 
 
110a135
8c0d5e4
110a135
2b31b25
 
 
 
 
8c0d5e4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from datasets import load_dataset



def main():
	raw_data = load_dataset("amazon_reviews_multi", "ja")
	raw_data = raw_data.rename_column("review_id", "id")
	raw_data = raw_data.rename_column("review_body", "text")
	raw_data = raw_data.remove_columns(["product_id", "reviewer_id", "review_title", "language", "product_category"])

	for split, dataset in raw_data.items():
		dataset = dataset.map(lambda x: {"label": x["stars"]-1}, num_proc=4)
		dataset = dataset.map(lambda x: {"label_text": str(x["label"])}, num_proc=4)	
		dataset = dataset.remove_columns(["stars"])
		dataset.to_json(f"{split}.jsonl")

if __name__ == "__main__":
	main()