Datasets:
Tasks:
Text Classification
Modalities:
Text
Formats:
parquet
Sub-tasks:
sentiment-classification
Languages:
Turkish
Size:
100K - 1M
License:
File size: 2,085 Bytes
34dfcd0 |
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 62 63 64 65 |
"""Turkish Product Reviews"""
from __future__ import absolute_import, division, print_function
import logging
import os
import datasets
_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,
)
def _split_generators(self, dl_manager):
"""Returns SplitGenerators."""
dl_paths = dl_manager.download_and_extract(_URL)
filenames = list(os.listdir(dl_paths))
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN, gen_kwargs={"filepath": dl_paths, "filenames": filenames}
),
]
def _generate_examples(self, filepath, filenames):
"""Generate TurkishProductReviews examples."""
logging.info("⏳ Generating examples from = %s", filepath)
for f in sorted(filenames):
filename, file_extension = os.path.splitext(f)
label = "negative" if file_extension == "neg" else "positive"
file_fullpath = os.path.join(filepath, f)
with open(file_fullpath, encoding="utf-8") as f:
for idx, line in enumerate(f):
line = line.strip()
yield idx, {
"sentence": line,
"sentiment": label,
}
|