Datasets:
Tasks:
Text Classification
Modalities:
Text
Sub-tasks:
sentiment-classification
Size:
10K - 100K
License:
Add dataset script
Browse files
test.jsonl.gz → dataset/test.jsonl.gz
RENAMED
|
File without changes
|
train.jsonl.gz → dataset/train.jsonl.gz
RENAMED
|
File without changes
|
unsupervised.jsonl.gz → dataset/unsupervised.jsonl.gz
RENAMED
|
File without changes
|
imdb_dutch.py
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# coding=utf-8
|
| 2 |
+
# Copyright 2020 The TensorFlow Datasets Authors and the HuggingFace Datasets Authors.
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
|
| 16 |
+
# Lint as: python3
|
| 17 |
+
"""IMDB movie reviews dataset."""
|
| 18 |
+
import gzip
|
| 19 |
+
import json
|
| 20 |
+
|
| 21 |
+
import datasets
|
| 22 |
+
from datasets.tasks import TextClassification
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
_DESCRIPTION = """\
|
| 26 |
+
Large Movie Review Dataset translated to Dutch.
|
| 27 |
+
|
| 28 |
+
This is a dataset for binary sentiment classification containing substantially \
|
| 29 |
+
more data than previous benchmark datasets. We provide a set of 24,992 highly \
|
| 30 |
+
polar movie reviews for training, and 24,992 for testing. There is additional \
|
| 31 |
+
unlabeled data for use as well.\
|
| 32 |
+
"""
|
| 33 |
+
|
| 34 |
+
_CITATION = """\
|
| 35 |
+
@InProceedings{maas-EtAl:2011:ACL-HLT2011,
|
| 36 |
+
author = {Maas, Andrew L. and Daly, Raymond E. and Pham, Peter T. and Huang, Dan and Ng, Andrew Y. and Potts, Christopher},
|
| 37 |
+
title = {Learning Word Vectors for Sentiment Analysis},
|
| 38 |
+
booktitle = {Proceedings of the 49th Annual Meeting of the Association for Computational Linguistics: Human Language Technologies},
|
| 39 |
+
month = {June},
|
| 40 |
+
year = {2011},
|
| 41 |
+
address = {Portland, Oregon, USA},
|
| 42 |
+
publisher = {Association for Computational Linguistics},
|
| 43 |
+
pages = {142--150},
|
| 44 |
+
url = {http://www.aclweb.org/anthology/P11-1015}
|
| 45 |
+
}
|
| 46 |
+
"""
|
| 47 |
+
|
| 48 |
+
_DOWNLOAD_URL = "https://huggingface.co/datasets/yhavinga/imdb_dutch/resolve/main/dataset/{split}.gz"
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
class IMDBReviewsConfig(datasets.BuilderConfig):
|
| 52 |
+
"""BuilderConfig for IMDBReviews."""
|
| 53 |
+
|
| 54 |
+
def __init__(self, **kwargs):
|
| 55 |
+
"""BuilderConfig for IMDBReviews.
|
| 56 |
+
|
| 57 |
+
Args:
|
| 58 |
+
**kwargs: keyword arguments forwarded to super.
|
| 59 |
+
"""
|
| 60 |
+
super(IMDBReviewsConfig, self).__init__(
|
| 61 |
+
version=datasets.Version("1.0.0", ""), **kwargs
|
| 62 |
+
)
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
class Imdb(datasets.GeneratorBasedBuilder):
|
| 66 |
+
"""IMDB movie reviews dataset."""
|
| 67 |
+
|
| 68 |
+
BUILDER_CONFIGS = [
|
| 69 |
+
IMDBReviewsConfig(
|
| 70 |
+
name="plain_text",
|
| 71 |
+
description="Plain text",
|
| 72 |
+
)
|
| 73 |
+
]
|
| 74 |
+
|
| 75 |
+
def _info(self):
|
| 76 |
+
return datasets.DatasetInfo(
|
| 77 |
+
description=_DESCRIPTION,
|
| 78 |
+
features=datasets.Features(
|
| 79 |
+
{
|
| 80 |
+
"text": datasets.Value("string"),
|
| 81 |
+
"text_en": datasets.Value("string"),
|
| 82 |
+
"label": datasets.features.ClassLabel(names=["neg", "pos"]),
|
| 83 |
+
}
|
| 84 |
+
),
|
| 85 |
+
supervised_keys=None,
|
| 86 |
+
homepage="http://ai.stanford.edu/~amaas/data/sentiment/",
|
| 87 |
+
citation=_CITATION,
|
| 88 |
+
task_templates=[
|
| 89 |
+
TextClassification(text_column="text", label_column="label")
|
| 90 |
+
],
|
| 91 |
+
)
|
| 92 |
+
|
| 93 |
+
def _split_generators(self, dl_manager):
|
| 94 |
+
return [
|
| 95 |
+
datasets.SplitGenerator(
|
| 96 |
+
name=datasets.Split.TRAIN,
|
| 97 |
+
gen_kwargs={
|
| 98 |
+
"files": dl_manager.download(_DOWNLOAD_URL.format(split="train")),
|
| 99 |
+
"split": "train",
|
| 100 |
+
},
|
| 101 |
+
),
|
| 102 |
+
datasets.SplitGenerator(
|
| 103 |
+
name=datasets.Split.TEST,
|
| 104 |
+
gen_kwargs={
|
| 105 |
+
"files": dl_manager.download(_DOWNLOAD_URL.format(split="test")),
|
| 106 |
+
"split": "test",
|
| 107 |
+
},
|
| 108 |
+
),
|
| 109 |
+
datasets.SplitGenerator(
|
| 110 |
+
name=datasets.Split("unsupervised"),
|
| 111 |
+
gen_kwargs={
|
| 112 |
+
"files": dl_manager.download(
|
| 113 |
+
_DOWNLOAD_URL.format(split="unsupervised")
|
| 114 |
+
),
|
| 115 |
+
"split": "unsupervised",
|
| 116 |
+
"labeled": False,
|
| 117 |
+
},
|
| 118 |
+
),
|
| 119 |
+
]
|
| 120 |
+
|
| 121 |
+
def _generate_examples(self, files, split, labeled=True):
|
| 122 |
+
"""Generate aclImdb examples."""
|
| 123 |
+
for filepath in files:
|
| 124 |
+
with gzip.open(open(filepath, "rb"), "rt", encoding="utf-8") as f:
|
| 125 |
+
for _, line in enumerate(f):
|
| 126 |
+
example = json.loads(line)
|
| 127 |
+
yield _, example
|