Upload create_dataset.py
Browse files- create_dataset.py +18 -0
create_dataset.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from datasets import load_dataset
|
2 |
+
|
3 |
+
|
4 |
+
def main():
|
5 |
+
|
6 |
+
raw_data = load_dataset("amazon_reviews_multi", "zh")
|
7 |
+
raw_data = raw_data.rename_column("review_id", "id")
|
8 |
+
raw_data = raw_data.rename_column("review_body", "text")
|
9 |
+
raw_data = raw_data.rename_column("stars", "label")
|
10 |
+
raw_data = raw_data.remove_columns(["product_id", "reviewer_id", "review_title", "language", "product_category"])
|
11 |
+
|
12 |
+
|
13 |
+
for split, dataset in raw_data.items():
|
14 |
+
dataset.to_json(f"{split}.jsonl")
|
15 |
+
|
16 |
+
if __name__ == "__main__":
|
17 |
+
main()
|
18 |
+
|