Datasets:
Tasks:
Text Classification
Modalities:
Text
Formats:
parquet
Sub-tasks:
sentiment-classification
Languages:
Turkish
Size:
100K - 1M
License:
Update files from the datasets library (from 1.16.0)
Browse filesRelease notes: https://github.com/huggingface/datasets/releases/tag/1.16.0
- turkish_product_reviews.py +11 -18
turkish_product_reviews.py
CHANGED
@@ -42,26 +42,19 @@ class TurkishProductReviews(datasets.GeneratorBasedBuilder):
|
|
42 |
|
43 |
def _split_generators(self, dl_manager):
|
44 |
"""Returns SplitGenerators."""
|
45 |
-
|
46 |
-
filenames = list(os.listdir(dl_paths))
|
47 |
return [
|
48 |
-
datasets.SplitGenerator(
|
49 |
-
name=datasets.Split.TRAIN, gen_kwargs={"filepath": dl_paths, "filenames": filenames}
|
50 |
-
),
|
51 |
]
|
52 |
|
53 |
-
def _generate_examples(self,
|
54 |
"""Generate TurkishProductReviews examples."""
|
55 |
-
|
56 |
-
|
57 |
-
filename, file_extension = os.path.splitext(f)
|
58 |
label = "negative" if file_extension == ".neg" else "positive"
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
"sentence": line,
|
66 |
-
"sentiment": label,
|
67 |
-
}
|
|
|
42 |
|
43 |
def _split_generators(self, dl_manager):
|
44 |
"""Returns SplitGenerators."""
|
45 |
+
archive = dl_manager.download(_URL)
|
|
|
46 |
return [
|
47 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"files": dl_manager.iter_archive(archive)}),
|
|
|
|
|
48 |
]
|
49 |
|
50 |
+
def _generate_examples(self, files):
|
51 |
"""Generate TurkishProductReviews examples."""
|
52 |
+
for file_idx, (path, f) in enumerate(files):
|
53 |
+
_, file_extension = os.path.splitext(path)
|
|
|
54 |
label = "negative" if file_extension == ".neg" else "positive"
|
55 |
+
for idx, line in enumerate(f):
|
56 |
+
line = line.decode("utf-8").strip()
|
57 |
+
yield f"{file_idx}_{idx}", {
|
58 |
+
"sentence": line,
|
59 |
+
"sentiment": label,
|
60 |
+
}
|
|
|
|
|
|