Datasets:
Tasks:
Text Classification
Modalities:
Text
Formats:
parquet
Sub-tasks:
sentiment-classification
Languages:
Turkish
Size:
100K - 1M
License:
Commit
•
c0c1357
1
Parent(s):
6f0c473
Delete loading script
Browse files- turkish_product_reviews.py +0 -60
turkish_product_reviews.py
DELETED
@@ -1,60 +0,0 @@
|
|
1 |
-
"""Turkish Product Reviews"""
|
2 |
-
|
3 |
-
|
4 |
-
import os
|
5 |
-
|
6 |
-
import datasets
|
7 |
-
from datasets.tasks import TextClassification
|
8 |
-
|
9 |
-
|
10 |
-
logger = datasets.logging.get_logger(__name__)
|
11 |
-
|
12 |
-
|
13 |
-
_CITATION = ""
|
14 |
-
|
15 |
-
_DESCRIPTION = """
|
16 |
-
Turkish Product Reviews.
|
17 |
-
This repository contains 235.165 product reviews collected online. There are 220.284 positive, 14881 negative reviews.
|
18 |
-
"""
|
19 |
-
|
20 |
-
_URL = "https://github.com/fthbrmnby/turkish-text-data/raw/master/reviews.tar.gz"
|
21 |
-
_FILES_PATHS = ["reviews.pos", "reviews.neg"]
|
22 |
-
|
23 |
-
_HOMEPAGE = "https://github.com/fthbrmnby/turkish-text-data"
|
24 |
-
|
25 |
-
|
26 |
-
class TurkishProductReviews(datasets.GeneratorBasedBuilder):
|
27 |
-
VERSION = datasets.Version("1.0.0")
|
28 |
-
|
29 |
-
def _info(self):
|
30 |
-
return datasets.DatasetInfo(
|
31 |
-
description=_DESCRIPTION,
|
32 |
-
features=datasets.Features(
|
33 |
-
{
|
34 |
-
"sentence": datasets.Value("string"),
|
35 |
-
"sentiment": datasets.ClassLabel(names=["negative", "positive"]),
|
36 |
-
}
|
37 |
-
),
|
38 |
-
citation=_CITATION,
|
39 |
-
homepage=_HOMEPAGE,
|
40 |
-
task_templates=[TextClassification(text_column="sentence", label_column="sentiment")],
|
41 |
-
)
|
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 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|