Datasets:
Tasks:
Text Classification
Modalities:
Text
Formats:
parquet
Sub-tasks:
sentiment-classification
Languages:
English
Size:
10K - 100K
License:
Commit
•
8ca2693
0
Parent(s):
Update files from the datasets library (from 1.0.0)
Browse filesRelease notes: https://github.com/huggingface/datasets/releases/tag/1.0.0
- .gitattributes +27 -0
- dataset_infos.json +1 -0
- dummy/1.0.0/dummy_data.zip +3 -0
- rotten_tomatoes.py +125 -0
.gitattributes
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
20 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
26 |
+
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
dataset_infos.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"default": {"description": "Movie Review Dataset.\nThis is a dataset of containing 5,331 positive and 5,331 negative processed \nsentences from Rotten Tomatoes movie reviews. This data was first used in Bo \nPang and Lillian Lee, ``Seeing stars: Exploiting class relationships for \nsentiment categorization with respect to rating scales.'', Proceedings of the \nACL, 2005.\n", "citation": "@InProceedings{Pang+Lee:05a,\n author = {Bo Pang and Lillian Lee},\n title = {Seeing stars: Exploiting class relationships for sentiment\n categorization with respect to rating scales},\n booktitle = {Proceedings of the ACL},\n year = 2005\n}\n", "homepage": "http://www.cs.cornell.edu/people/pabo/movie-review-data/", "license": "", "features": {"text": {"dtype": "string", "id": null, "_type": "Value"}, "label": {"num_classes": 2, "names": ["neg", "pos"], "names_file": null, "id": null, "_type": "ClassLabel"}}, "supervised_keys": {"input": "", "output": ""}, "builder_name": "rotten_tomatoes_movie_review", "config_name": "default", "version": {"version_str": "1.0.0", "description": null, "datasets_version_to_prepare": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 1074810, "num_examples": 8530, "dataset_name": "rotten_tomatoes_movie_review"}, "validation": {"name": "validation", "num_bytes": 134679, "num_examples": 1066, "dataset_name": "rotten_tomatoes_movie_review"}, "test": {"name": "test", "num_bytes": 135972, "num_examples": 1066, "dataset_name": "rotten_tomatoes_movie_review"}}, "download_checksums": {"https://storage.googleapis.com/seldon-datasets/sentence_polarity_v1/rt-polaritydata.tar.gz": {"num_bytes": 487770, "checksum": "a05befe52aafda71d458d188a1c54506a998b1308613ba76bbda2e5029409ce9"}}, "download_size": 487770, "dataset_size": 1345461, "size_in_bytes": 1833231}}
|
dummy/1.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:23b0f403770991d7ef26edf47b1117293dd4a0a387a86e0fa6caaf39d8fcb50c
|
3 |
+
size 1568
|
rotten_tomatoes.py
ADDED
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
"""Rotten tomatoes movie reviews dataset."""
|
18 |
+
|
19 |
+
from __future__ import absolute_import, division, print_function
|
20 |
+
|
21 |
+
import os
|
22 |
+
|
23 |
+
import datasets
|
24 |
+
|
25 |
+
|
26 |
+
_DESCRIPTION = """\
|
27 |
+
Movie Review Dataset.
|
28 |
+
This is a dataset of containing 5,331 positive and 5,331 negative processed
|
29 |
+
sentences from Rotten Tomatoes movie reviews. This data was first used in Bo
|
30 |
+
Pang and Lillian Lee, ``Seeing stars: Exploiting class relationships for
|
31 |
+
sentiment categorization with respect to rating scales.'', Proceedings of the
|
32 |
+
ACL, 2005.
|
33 |
+
"""
|
34 |
+
|
35 |
+
_CITATION = """\
|
36 |
+
@InProceedings{Pang+Lee:05a,
|
37 |
+
author = {Bo Pang and Lillian Lee},
|
38 |
+
title = {Seeing stars: Exploiting class relationships for sentiment
|
39 |
+
categorization with respect to rating scales},
|
40 |
+
booktitle = {Proceedings of the ACL},
|
41 |
+
year = 2005
|
42 |
+
}
|
43 |
+
"""
|
44 |
+
|
45 |
+
_DOWNLOAD_URL = "https://storage.googleapis.com/seldon-datasets/sentence_polarity_v1/rt-polaritydata.tar.gz"
|
46 |
+
|
47 |
+
|
48 |
+
class RottenTomatoesMovieReview(datasets.GeneratorBasedBuilder):
|
49 |
+
"""Cornell Rotten Tomatoes movie reviews dataset."""
|
50 |
+
|
51 |
+
VERSION = datasets.Version("1.0.0")
|
52 |
+
|
53 |
+
def _info(self):
|
54 |
+
return datasets.DatasetInfo(
|
55 |
+
description=_DESCRIPTION,
|
56 |
+
features=datasets.Features(
|
57 |
+
{"text": datasets.Value("string"), "label": datasets.features.ClassLabel(names=["neg", "pos"])}
|
58 |
+
),
|
59 |
+
supervised_keys=[""],
|
60 |
+
homepage="http://www.cs.cornell.edu/people/pabo/movie-review-data/",
|
61 |
+
citation=_CITATION,
|
62 |
+
)
|
63 |
+
|
64 |
+
def _vocab_text_gen(self, train_file):
|
65 |
+
for _, ex in self._generate_examples(train_file):
|
66 |
+
yield ex["text"]
|
67 |
+
|
68 |
+
def _split_generators(self, dl_manager):
|
69 |
+
""" Downloads Rotten Tomatoes sentences. """
|
70 |
+
extracted_folder_path = dl_manager.download_and_extract(_DOWNLOAD_URL)
|
71 |
+
return [
|
72 |
+
datasets.SplitGenerator(
|
73 |
+
name=datasets.Split.TRAIN,
|
74 |
+
gen_kwargs={"split_key": "train", "data_dir": extracted_folder_path},
|
75 |
+
),
|
76 |
+
datasets.SplitGenerator(
|
77 |
+
name=datasets.Split.VALIDATION,
|
78 |
+
gen_kwargs={"split_key": "validation", "data_dir": extracted_folder_path},
|
79 |
+
),
|
80 |
+
datasets.SplitGenerator(
|
81 |
+
name=datasets.Split.TEST,
|
82 |
+
gen_kwargs={"split_key": "test", "data_dir": extracted_folder_path},
|
83 |
+
),
|
84 |
+
]
|
85 |
+
|
86 |
+
def _get_examples_from_split(self, split_key, data_dir):
|
87 |
+
"""Reads Rotten Tomatoes sentences and splits into 80% train,
|
88 |
+
10% validation, and 10% test, as is the practice set out in Jinfeng
|
89 |
+
Li, ``TEXTBUGGER: Generating Adversarial Text Against Real-world
|
90 |
+
Applications.''
|
91 |
+
"""
|
92 |
+
data_dir = os.path.join(data_dir, "rt-polaritydata")
|
93 |
+
|
94 |
+
pos_samples = open(os.path.join(data_dir, "rt-polarity.pos"), encoding="latin-1").readlines()
|
95 |
+
pos_samples = list(map(lambda t: t.strip(), pos_samples))
|
96 |
+
|
97 |
+
neg_samples = open(os.path.join(data_dir, "rt-polarity.neg"), encoding="latin-1").readlines()
|
98 |
+
neg_samples = list(map(lambda t: t.strip(), neg_samples))
|
99 |
+
|
100 |
+
# 80/10/10 split
|
101 |
+
i1 = int(len(pos_samples) * 0.8 + 0.5)
|
102 |
+
i2 = int(len(pos_samples) * 0.9 + 0.5)
|
103 |
+
train_samples = pos_samples[:i1] + neg_samples[:i1]
|
104 |
+
train_labels = (["pos"] * i1) + (["neg"] * i1)
|
105 |
+
validation_samples = pos_samples[i1:i2] + neg_samples[i1:i2]
|
106 |
+
validation_labels = (["pos"] * (i2 - i1)) + (["neg"] * (i2 - i1))
|
107 |
+
test_samples = pos_samples[i2:] + neg_samples[i2:]
|
108 |
+
test_labels = (["pos"] * (len(pos_samples) - i2)) + (["neg"] * (len(pos_samples) - i2))
|
109 |
+
|
110 |
+
if split_key == "train":
|
111 |
+
return (train_samples, train_labels)
|
112 |
+
if split_key == "validation":
|
113 |
+
return (validation_samples, validation_labels)
|
114 |
+
if split_key == "test":
|
115 |
+
return (test_samples, test_labels)
|
116 |
+
else:
|
117 |
+
raise ValueError(f"Invalid split key {split_key}")
|
118 |
+
|
119 |
+
def _generate_examples(self, split_key, data_dir):
|
120 |
+
"""Yields examples for a given split of MR."""
|
121 |
+
split_text, split_labels = self._get_examples_from_split(split_key, data_dir)
|
122 |
+
for text, label in zip(split_text, split_labels):
|
123 |
+
data_key = split_key + "_" + text
|
124 |
+
feature_dict = {"text": text, "label": label}
|
125 |
+
yield data_key, feature_dict
|