Datasets:

Languages:
Turkish
Multilinguality:
monolingual
Size Categories:
100K<n<1M
Language Creators:
found
Annotations Creators:
found
Source Datasets:
original
Tags:
License:
File size: 1,930 Bytes
34dfcd0
 
 
 
 
 
4fac4c9
34dfcd0
 
253f7bf
 
 
34dfcd0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4fac4c9
34dfcd0
 
 
 
50eeb28
34dfcd0
50eeb28
34dfcd0
 
50eeb28
34dfcd0
50eeb28
 
ad8f596
50eeb28
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""Turkish Product Reviews"""


import os

import datasets
from datasets.tasks import TextClassification


logger = datasets.logging.get_logger(__name__)


_CITATION = ""

_DESCRIPTION = """
Turkish Product Reviews.
This repository contains 235.165 product reviews collected online. There are 220.284 positive, 14881 negative reviews.
"""

_URL = "https://github.com/fthbrmnby/turkish-text-data/raw/master/reviews.tar.gz"
_FILES_PATHS = ["reviews.pos", "reviews.neg"]

_HOMEPAGE = "https://github.com/fthbrmnby/turkish-text-data"


class TurkishProductReviews(datasets.GeneratorBasedBuilder):
    VERSION = datasets.Version("1.0.0")

    def _info(self):
        return datasets.DatasetInfo(
            description=_DESCRIPTION,
            features=datasets.Features(
                {
                    "sentence": datasets.Value("string"),
                    "sentiment": datasets.ClassLabel(names=["negative", "positive"]),
                }
            ),
            citation=_CITATION,
            homepage=_HOMEPAGE,
            task_templates=[TextClassification(text_column="sentence", label_column="sentiment")],
        )

    def _split_generators(self, dl_manager):
        """Returns SplitGenerators."""
        archive = dl_manager.download(_URL)
        return [
            datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"files": dl_manager.iter_archive(archive)}),
        ]

    def _generate_examples(self, files):
        """Generate TurkishProductReviews examples."""
        for file_idx, (path, f) in enumerate(files):
            _, file_extension = os.path.splitext(path)
            label = "negative" if file_extension == ".neg" else "positive"
            for idx, line in enumerate(f):
                line = line.decode("utf-8").strip()
                yield f"{file_idx}_{idx}", {
                    "sentence": line,
                    "sentiment": label,
                }