Datasets:
Commit
•
0d9e574
1
Parent(s):
199d037
b2w-reviews
Browse files- b2w-reviews01.py +1 -28
b2w-reviews01.py
CHANGED
@@ -18,22 +18,6 @@ _URLS = {
|
|
18 |
"train": "https://raw.githubusercontent.com/americanas-tech/b2w-reviews01/4639429ec698d7821fc99a0bc665fa213d9fcd5a/B2W-Reviews01.csv"
|
19 |
}
|
20 |
|
21 |
-
_LABEL_INT_KEY = {
|
22 |
-
"antisemitism": 1,
|
23 |
-
"apology_for_the_dictatorship": 2,
|
24 |
-
"fatphobia": 3,
|
25 |
-
"homophobia": 4,
|
26 |
-
"partyism": 5,
|
27 |
-
"racism": 6,
|
28 |
-
"religious_intolerance": 7,
|
29 |
-
"sexism": 8,
|
30 |
-
"xenophobia": 9,
|
31 |
-
"offensive_&_non-hate_speech": -1,
|
32 |
-
"non-offensive": 0
|
33 |
-
}
|
34 |
-
|
35 |
-
_INT_LABEL_KEY = {v:k for k,v in _LABEL_INT_KEY.items()}
|
36 |
-
|
37 |
class Reviews(datasets.GeneratorBasedBuilder):
|
38 |
|
39 |
VERSION = datasets.Version("1.0.0")
|
@@ -51,7 +35,7 @@ class Reviews(datasets.GeneratorBasedBuilder):
|
|
51 |
site_category_lv2=datasets.Value("string"),
|
52 |
review_title=datasets.Value("string"),
|
53 |
overall_rating=datasets.Value("int32"),
|
54 |
-
recommend_to_a_friend=datasets.Value("
|
55 |
review_text=datasets.Value("string"),
|
56 |
reviewer_birth_year=datasets.Value("int32"),
|
57 |
reviewer_gender=datasets.Value("string"),
|
@@ -75,23 +59,12 @@ class Reviews(datasets.GeneratorBasedBuilder):
|
|
75 |
def _generate_examples(self, filepath):
|
76 |
def process_row(row):
|
77 |
|
78 |
-
recommend_key = {
|
79 |
-
"Yes": True,
|
80 |
-
"No": False
|
81 |
-
}
|
82 |
-
|
83 |
-
row["recommend_to_a_friend"] = recommend_key.get(row["recommend_to_a_friend"], None)
|
84 |
-
|
85 |
row["overall_rating"] = int(row["overall_rating"])
|
86 |
|
87 |
try:
|
88 |
row["reviewer_birth_year"] = int(float(row["reviewer_birth_year"]))
|
89 |
except ValueError:
|
90 |
row["reviewer_birth_year"] = None
|
91 |
-
|
92 |
-
for key, value in row.items():
|
93 |
-
if isinstance(value, str) and not value.strip():
|
94 |
-
row[key] = None
|
95 |
|
96 |
return row
|
97 |
|
|
|
18 |
"train": "https://raw.githubusercontent.com/americanas-tech/b2w-reviews01/4639429ec698d7821fc99a0bc665fa213d9fcd5a/B2W-Reviews01.csv"
|
19 |
}
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
class Reviews(datasets.GeneratorBasedBuilder):
|
22 |
|
23 |
VERSION = datasets.Version("1.0.0")
|
|
|
35 |
site_category_lv2=datasets.Value("string"),
|
36 |
review_title=datasets.Value("string"),
|
37 |
overall_rating=datasets.Value("int32"),
|
38 |
+
recommend_to_a_friend=datasets.Value("string"),
|
39 |
review_text=datasets.Value("string"),
|
40 |
reviewer_birth_year=datasets.Value("int32"),
|
41 |
reviewer_gender=datasets.Value("string"),
|
|
|
59 |
def _generate_examples(self, filepath):
|
60 |
def process_row(row):
|
61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
row["overall_rating"] = int(row["overall_rating"])
|
63 |
|
64 |
try:
|
65 |
row["reviewer_birth_year"] = int(float(row["reviewer_birth_year"]))
|
66 |
except ValueError:
|
67 |
row["reviewer_birth_year"] = None
|
|
|
|
|
|
|
|
|
68 |
|
69 |
return row
|
70 |
|