albertvillanova HF staff commited on
Commit
3c35933
1 Parent(s): c1ac045

Add SST-2 dataset (#4473)

Browse files

* Add SST-2 dataset

* Add dataset card

* Add metadata JSON

* Add dummy data

* Fix style

* Fix dataset card

* Remove default config from dataset card

Commit from https://github.com/huggingface/datasets/commit/5eac250e652118dff0ba3d528fb9b336a75ade47

Files changed (4) hide show
  1. README.md +177 -0
  2. dataset_infos.json +1 -0
  3. dummy/2.0.0/dummy_data.zip +3 -0
  4. sst2.py +105 -0
README.md ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ annotations_creators:
3
+ - crowdsourced
4
+ language_creators:
5
+ - found
6
+ languages:
7
+ - en
8
+ licenses:
9
+ - unknown
10
+ multilinguality:
11
+ - monolingual
12
+ size_categories:
13
+ - 10K<n<100K
14
+ source_datasets:
15
+ - original
16
+ task_categories:
17
+ - text-classification
18
+ task_ids:
19
+ - sentiment-classification
20
+ paperswithcode_id: sst
21
+ pretty_name: Stanford Sentiment Treebank v2
22
+ ---
23
+
24
+ # Dataset Card for [Dataset Name]
25
+
26
+ ## Table of Contents
27
+ - [Table of Contents](#table-of-contents)
28
+ - [Dataset Description](#dataset-description)
29
+ - [Dataset Summary](#dataset-summary)
30
+ - [Supported Tasks and Leaderboards](#supported-tasks-and-leaderboards)
31
+ - [Languages](#languages)
32
+ - [Dataset Structure](#dataset-structure)
33
+ - [Data Instances](#data-instances)
34
+ - [Data Fields](#data-fields)
35
+ - [Data Splits](#data-splits)
36
+ - [Dataset Creation](#dataset-creation)
37
+ - [Curation Rationale](#curation-rationale)
38
+ - [Source Data](#source-data)
39
+ - [Annotations](#annotations)
40
+ - [Personal and Sensitive Information](#personal-and-sensitive-information)
41
+ - [Considerations for Using the Data](#considerations-for-using-the-data)
42
+ - [Social Impact of Dataset](#social-impact-of-dataset)
43
+ - [Discussion of Biases](#discussion-of-biases)
44
+ - [Other Known Limitations](#other-known-limitations)
45
+ - [Additional Information](#additional-information)
46
+ - [Dataset Curators](#dataset-curators)
47
+ - [Licensing Information](#licensing-information)
48
+ - [Citation Information](#citation-information)
49
+ - [Contributions](#contributions)
50
+
51
+ ## Dataset Description
52
+
53
+ - **Homepage:** https://nlp.stanford.edu/sentiment/
54
+ - **Repository:**
55
+ - **Paper:** [Recursive Deep Models for Semantic Compositionality Over a Sentiment Treebank](https://www.aclweb.org/anthology/D13-1170/)
56
+ - **Leaderboard:**
57
+ - **Point of Contact:**
58
+
59
+ ### Dataset Summary
60
+
61
+ The Stanford Sentiment Treebank is a corpus with fully labeled parse trees that allows for a complete analysis of the
62
+ compositional effects of sentiment in language. The corpus is based on the dataset introduced by Pang and Lee (2005)
63
+ and consists of 11,855 single sentences extracted from movie reviews. It was parsed with the Stanford parser and
64
+ includes a total of 215,154 unique phrases from those parse trees, each annotated by 3 human judges.
65
+
66
+ Binary classification experiments on full sentences (negative or somewhat negative vs somewhat positive or positive
67
+ with neutral sentences discarded) refer to the dataset as SST-2 or SST binary.
68
+
69
+ ### Supported Tasks and Leaderboards
70
+
71
+ - `sentiment-classification`
72
+
73
+ ### Languages
74
+
75
+ The text in the dataset is in English (`en`).
76
+
77
+ ## Dataset Structure
78
+
79
+ ### Data Instances
80
+
81
+ ```
82
+ {'idx': 0,
83
+ 'sentence': 'hide new secretions from the parental units ',
84
+ 'label': 0}
85
+ ```
86
+
87
+ ### Data Fields
88
+
89
+ - `idx`: Monotonically increasing index ID.
90
+ - `sentence`: Complete sentence expressing an opinion about a film.
91
+ - `label`: Sentiment of the opinion, either "negative" (0) or positive (1).
92
+
93
+ ### Data Splits
94
+
95
+ | | train | validation | test |
96
+ |--------------------|---------:|-----------:|-----:|
97
+ | Number of examples | 67349 | 872 | 1821 |
98
+
99
+ ## Dataset Creation
100
+
101
+ ### Curation Rationale
102
+
103
+ [More Information Needed]
104
+
105
+ ### Source Data
106
+
107
+ #### Initial Data Collection and Normalization
108
+
109
+ [More Information Needed]
110
+
111
+ #### Who are the source language producers?
112
+
113
+ Rotten Tomatoes reviewers.
114
+
115
+ ### Annotations
116
+
117
+ #### Annotation process
118
+
119
+ [More Information Needed]
120
+
121
+ #### Who are the annotators?
122
+
123
+ [More Information Needed]
124
+
125
+ ### Personal and Sensitive Information
126
+
127
+ [More Information Needed]
128
+
129
+ ## Considerations for Using the Data
130
+
131
+ ### Social Impact of Dataset
132
+
133
+ [More Information Needed]
134
+
135
+ ### Discussion of Biases
136
+
137
+ [More Information Needed]
138
+
139
+ ### Other Known Limitations
140
+
141
+ [More Information Needed]
142
+
143
+ ## Additional Information
144
+
145
+ ### Dataset Curators
146
+
147
+ [More Information Needed]
148
+
149
+ ### Licensing Information
150
+
151
+ Unknown.
152
+
153
+ ### Citation Information
154
+
155
+ ```bibtex
156
+ @inproceedings{socher-etal-2013-recursive,
157
+ title = "Recursive Deep Models for Semantic Compositionality Over a Sentiment Treebank",
158
+ author = "Socher, Richard and
159
+ Perelygin, Alex and
160
+ Wu, Jean and
161
+ Chuang, Jason and
162
+ Manning, Christopher D. and
163
+ Ng, Andrew and
164
+ Potts, Christopher",
165
+ booktitle = "Proceedings of the 2013 Conference on Empirical Methods in Natural Language Processing",
166
+ month = oct,
167
+ year = "2013",
168
+ address = "Seattle, Washington, USA",
169
+ publisher = "Association for Computational Linguistics",
170
+ url = "https://www.aclweb.org/anthology/D13-1170",
171
+ pages = "1631--1642",
172
+ }
173
+ ```
174
+
175
+ ### Contributions
176
+
177
+ Thanks to [@albertvillanova](https://github.com/albertvillanova) for adding this dataset.
dataset_infos.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"default": {"description": "The Stanford Sentiment Treebank consists of sentences from movie reviews and\nhuman annotations of their sentiment. The task is to predict the sentiment of a\ngiven sentence. We use the two-way (positive/negative) class split, and use only\nsentence-level labels.\n", "citation": "@inproceedings{socher2013recursive,\n title={Recursive deep models for semantic compositionality over a sentiment treebank},\n author={Socher, Richard and Perelygin, Alex and Wu, Jean and Chuang, Jason and Manning, Christopher D and Ng, Andrew and Potts, Christopher},\n booktitle={Proceedings of the 2013 conference on empirical methods in natural language processing},\n pages={1631--1642},\n year={2013}\n}\n", "homepage": "https://nlp.stanford.edu/sentiment/", "license": "Unknown", "features": {"idx": {"dtype": "int32", "id": null, "_type": "Value"}, "sentence": {"dtype": "string", "id": null, "_type": "Value"}, "label": {"num_classes": 2, "names": ["negative", "positive"], "id": null, "_type": "ClassLabel"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "sst2", "config_name": "default", "version": {"version_str": "2.0.0", "description": null, "major": 2, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 4690022, "num_examples": 67349, "dataset_name": "sst2"}, "validation": {"name": "validation", "num_bytes": 106361, "num_examples": 872, "dataset_name": "sst2"}, "test": {"name": "test", "num_bytes": 216868, "num_examples": 1821, "dataset_name": "sst2"}}, "download_checksums": {"https://dl.fbaipublicfiles.com/glue/data/SST-2.zip": {"num_bytes": 7439277, "checksum": "d67e16fb55739c1b32cdce9877596db1c127dc322d93c082281f64057c16deaa"}}, "download_size": 7439277, "post_processing_size": null, "dataset_size": 5013251, "size_in_bytes": 12452528}}
dummy/2.0.0/dummy_data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6cbcdd7df5dc2856008783c13b5cc7d1817b317c26776c44ef55f5814326ec28
3
+ size 4694
sst2.py ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ """SST-2 (Stanford Sentiment Treebank v2) dataset."""
15
+
16
+
17
+ import csv
18
+ import os
19
+
20
+ import datasets
21
+
22
+
23
+ _CITATION = """\
24
+ @inproceedings{socher2013recursive,
25
+ title={Recursive deep models for semantic compositionality over a sentiment treebank},
26
+ author={Socher, Richard and Perelygin, Alex and Wu, Jean and Chuang, Jason and Manning, Christopher D and Ng, Andrew and Potts, Christopher},
27
+ booktitle={Proceedings of the 2013 conference on empirical methods in natural language processing},
28
+ pages={1631--1642},
29
+ year={2013}
30
+ }
31
+ """
32
+
33
+ _DESCRIPTION = """\
34
+ The Stanford Sentiment Treebank consists of sentences from movie reviews and
35
+ human annotations of their sentiment. The task is to predict the sentiment of a
36
+ given sentence. We use the two-way (positive/negative) class split, and use only
37
+ sentence-level labels.
38
+ """
39
+
40
+ _HOMEPAGE = "https://nlp.stanford.edu/sentiment/"
41
+
42
+ _LICENSE = "Unknown"
43
+
44
+ _URL = "https://dl.fbaipublicfiles.com/glue/data/SST-2.zip"
45
+
46
+
47
+ class Sst2(datasets.GeneratorBasedBuilder):
48
+ """SST-2 dataset."""
49
+
50
+ VERSION = datasets.Version("2.0.0")
51
+
52
+ def _info(self):
53
+ features = datasets.Features(
54
+ {
55
+ "idx": datasets.Value("int32"),
56
+ "sentence": datasets.Value("string"),
57
+ "label": datasets.features.ClassLabel(names=["negative", "positive"]),
58
+ }
59
+ )
60
+ return datasets.DatasetInfo(
61
+ description=_DESCRIPTION,
62
+ features=features,
63
+ homepage=_HOMEPAGE,
64
+ license=_LICENSE,
65
+ citation=_CITATION,
66
+ )
67
+
68
+ def _split_generators(self, dl_manager):
69
+ dl_dir = dl_manager.download_and_extract(_URL)
70
+ return [
71
+ datasets.SplitGenerator(
72
+ name=datasets.Split.TRAIN,
73
+ gen_kwargs={
74
+ "file_paths": dl_manager.iter_files(dl_dir),
75
+ "data_filename": "train.tsv",
76
+ },
77
+ ),
78
+ datasets.SplitGenerator(
79
+ name=datasets.Split.VALIDATION,
80
+ gen_kwargs={
81
+ "file_paths": dl_manager.iter_files(dl_dir),
82
+ "data_filename": "dev.tsv",
83
+ },
84
+ ),
85
+ datasets.SplitGenerator(
86
+ name=datasets.Split.TEST,
87
+ gen_kwargs={
88
+ "file_paths": dl_manager.iter_files(dl_dir),
89
+ "data_filename": "test.tsv",
90
+ },
91
+ ),
92
+ ]
93
+
94
+ def _generate_examples(self, file_paths, data_filename):
95
+ for file_path in file_paths:
96
+ filename = os.path.basename(file_path)
97
+ if filename == data_filename:
98
+ with open(file_path, encoding="utf8") as f:
99
+ reader = csv.DictReader(f, delimiter="\t", quoting=csv.QUOTE_NONE)
100
+ for idx, row in enumerate(reader):
101
+ yield idx, {
102
+ "idx": row["index"] if "index" in row else idx,
103
+ "sentence": row["sentence"],
104
+ "label": int(row["label"]) if "label" in row else -1,
105
+ }