system HF staff commited on
Commit
9de948e
0 Parent(s):

Update files from the datasets library (from 1.5.0)

Browse files

Release notes: https://github.com/huggingface/datasets/releases/tag/1.5.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
README.md ADDED
@@ -0,0 +1,192 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ annotations_creators:
3
+ - crowdsourced
4
+ language_creators:
5
+ - found
6
+ languages:
7
+ - en
8
+ licenses: []
9
+ multilinguality:
10
+ - monolingual
11
+ size_categories:
12
+ default:
13
+ - 10K<n<100K
14
+ dictionary:
15
+ - 100K<n<1M
16
+ phrases:
17
+ - 100K<n<1M
18
+ ptb:
19
+ - 10K<n<100K
20
+ sentences:
21
+ - 10K<n<100K
22
+ source_datasets: []
23
+ task_categories:
24
+ - text-classification
25
+ - text-scoring
26
+ task_ids:
27
+ - sentiment-classification
28
+ - sentiment-scoring
29
+ ---
30
+
31
+ # Dataset Card for sst
32
+
33
+ ## Table of Contents
34
+ - [Dataset Description](#dataset-description)
35
+ - [Dataset Summary](#dataset-summary)
36
+ - [Supported Tasks](#supported-tasks-and-leaderboards)
37
+ - [Languages](#languages)
38
+ - [Dataset Structure](#dataset-structure)
39
+ - [Data Instances](#data-instances)
40
+ - [Data Fields](#data-instances)
41
+ - [Data Splits](#data-instances)
42
+ - [Dataset Creation](#dataset-creation)
43
+ - [Curation Rationale](#curation-rationale)
44
+ - [Source Data](#source-data)
45
+ - [Annotations](#annotations)
46
+ - [Personal and Sensitive Information](#personal-and-sensitive-information)
47
+ - [Considerations for Using the Data](#considerations-for-using-the-data)
48
+ - [Social Impact of Dataset](#social-impact-of-dataset)
49
+ - [Discussion of Biases](#discussion-of-biases)
50
+ - [Other Known Limitations](#other-known-limitations)
51
+ - [Additional Information](#additional-information)
52
+ - [Dataset Curators](#dataset-curators)
53
+ - [Licensing Information](#licensing-information)
54
+ - [Citation Information](#citation-information)
55
+ - [Contributions](#contributions)
56
+
57
+ ## Dataset Description
58
+
59
+ - **Homepage:** https://nlp.stanford.edu/sentiment/index.html
60
+ - **Repository:** [Needs More Information]
61
+ - **Paper:** [Recursive Deep Models for Semantic Compositionality Over a Sentiment Treebank](https://www.aclweb.org/anthology/D13-1170/)
62
+ - **Leaderboard:** [Needs More Information]
63
+ - **Point of Contact:** [Needs More Information]
64
+
65
+ ### Dataset Summary
66
+
67
+ The Stanford Sentiment Treebank is the first corpus with fully labeled parse trees that allows for a complete analysis of the compositional effects of sentiment in language.
68
+
69
+ ### Supported Tasks and Leaderboards
70
+
71
+ - `sentiment-scoring`: Each complete sentence is annotated with a `float` label that indicates its level of positive sentiment from 0.0 to 1.0. One can decide to use only complete sentences or to include the contributions of the sub-sentences (aka phrases). The labels for each phrase are included in the `dictionary` configuration. To obtain all the phrases in a sentence we need to visit the parse tree included with each example. In contrast, the `ptb` configuration explicitly provides all the labelled parse trees in Penn Treebank format. Here the labels are binned in 5 bins from 0 to 4.
72
+ - `sentiment-classification`: We can transform the above into a binary sentiment classification task by rounding each label to 0 or 1.
73
+
74
+ ### Languages
75
+
76
+ The text in the dataset is in English
77
+
78
+ ## Dataset Structure
79
+
80
+ ### Data Instances
81
+
82
+ For the `default` configuration:
83
+ ```
84
+ {'label': 0.7222200036048889,
85
+ 'sentence': 'Yet the act is still charming here .',
86
+ 'tokens': 'Yet|the|act|is|still|charming|here|.',
87
+ 'tree': '15|13|13|10|9|9|11|12|10|11|12|14|14|15|0'}
88
+ ```
89
+
90
+ For the `dictionary` configuration:
91
+ ```
92
+ {'label': 0.7361099720001221,
93
+ 'phrase': 'still charming'}
94
+ ```
95
+
96
+ For the `ptb` configuration:
97
+ ```
98
+ {'ptb_tree': '(3 (2 Yet) (3 (2 (2 the) (2 act)) (3 (4 (3 (2 is) (3 (2 still) (4 charming))) (2 here)) (2 .))))'}
99
+ ```
100
+
101
+ ### Data Fields
102
+
103
+ - `sentence`: a complete sentence expressing an opinion about a film
104
+ - `label`: the degree of "positivity" of the opinion, on a scale between 0.0 and 1.0
105
+ - `tokens`: a sequence of tokens that form a sentence
106
+ - `tree`: a sentence parse tree formatted as a parent pointer tree
107
+ - `phrase`: a sub-sentence of a complete sentence
108
+ - `ptb_tree`: a sentence parse tree formatted in Penn Treebank-style, where each component's degree of positive sentiment is labelled on a scale from 0 to 4
109
+
110
+ ### Data Splits
111
+
112
+ The set of complete sentences (both `default` and `ptb` configurations) is split into a training, validation and test set. The `dictionary` configuration has only one split as it is used for reference rather than for learning.
113
+
114
+ ## Dataset Creation
115
+
116
+ ### Curation Rationale
117
+
118
+ [Needs More Information]
119
+
120
+ ### Source Data
121
+
122
+ #### Initial Data Collection and Normalization
123
+
124
+ [Needs More Information]
125
+
126
+ #### Who are the source language producers?
127
+
128
+ Rotten Tomatoes reviewers.
129
+
130
+ ### Annotations
131
+
132
+ #### Annotation process
133
+
134
+ [Needs More Information]
135
+
136
+ #### Who are the annotators?
137
+
138
+ [Needs More Information]
139
+
140
+ ### Personal and Sensitive Information
141
+
142
+ [Needs More Information]
143
+
144
+ ## Considerations for Using the Data
145
+
146
+ ### Social Impact of Dataset
147
+
148
+ [Needs More Information]
149
+
150
+ ### Discussion of Biases
151
+
152
+ [Needs More Information]
153
+
154
+ ### Other Known Limitations
155
+
156
+ [Needs More Information]
157
+
158
+ ## Additional Information
159
+
160
+ ### Dataset Curators
161
+
162
+ [Needs More Information]
163
+
164
+ ### Licensing Information
165
+
166
+ [Needs More Information]
167
+
168
+ ### Citation Information
169
+
170
+ ```
171
+ @inproceedings{socher-etal-2013-recursive,
172
+ title = "Recursive Deep Models for Semantic Compositionality Over a Sentiment Treebank",
173
+ author = "Socher, Richard and
174
+ Perelygin, Alex and
175
+ Wu, Jean and
176
+ Chuang, Jason and
177
+ Manning, Christopher D. and
178
+ Ng, Andrew and
179
+ Potts, Christopher",
180
+ booktitle = "Proceedings of the 2013 Conference on Empirical Methods in Natural Language Processing",
181
+ month = oct,
182
+ year = "2013",
183
+ address = "Seattle, Washington, USA",
184
+ publisher = "Association for Computational Linguistics",
185
+ url = "https://www.aclweb.org/anthology/D13-1170",
186
+ pages = "1631--1642",
187
+ }
188
+ ```
189
+
190
+ ### Contributions
191
+
192
+ Thanks to [@patpizio](https://github.com/patpizio) for adding this dataset.
dataset_infos.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"default": {"description": "The Stanford Sentiment Treebank, the first corpus with fully labeled parse trees that allows for a\ncomplete analysis of the compositional effects of sentiment in language.\n", "citation": "@inproceedings{socher-etal-2013-recursive,\n title = \"Recursive Deep Models for Semantic Compositionality Over a Sentiment Treebank\",\n author = \"Socher, Richard and Perelygin, Alex and Wu, Jean and\n 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 month = oct,\n year = \"2013\",\n address = \"Seattle, Washington, USA\",\n publisher = \"Association for Computational Linguistics\",\n url = \"https://www.aclweb.org/anthology/D13-1170\",\n pages = \"1631--1642\",\n}\n", "homepage": "https://nlp.stanford.edu/sentiment/", "license": "", "features": {"sentence": {"dtype": "string", "id": null, "_type": "Value"}, "label": {"dtype": "float32", "id": null, "_type": "Value"}, "tokens": {"dtype": "string", "id": null, "_type": "Value"}, "tree": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "builder_name": "sst", "config_name": "default", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 2818768, "num_examples": 8544, "dataset_name": "sst"}, "validation": {"name": "validation", "num_bytes": 366205, "num_examples": 1101, "dataset_name": "sst"}, "test": {"name": "test", "num_bytes": 730154, "num_examples": 2210, "dataset_name": "sst"}}, "download_checksums": {"https://nlp.stanford.edu/~socherr/stanfordSentimentTreebank.zip": {"num_bytes": 6372817, "checksum": "3f5209483b46bbf129cacbbbe6ae02fe780407034f61cf6342b7833257c3f1db"}, "https://nlp.stanford.edu/sentiment/trainDevTestTrees_PTB.zip": {"num_bytes": 789539, "checksum": "5c613a4f673fc74097d523a2c83f38e0cc462984d847b82c7aaf36b01cbbbfcc"}}, "download_size": 7162356, "post_processing_size": null, "dataset_size": 3915127, "size_in_bytes": 11077483}, "dictionary": {"description": "The Stanford Sentiment Treebank, the first corpus with fully labeled parse trees that allows for a\ncomplete analysis of the compositional effects of sentiment in language.\n", "citation": "@inproceedings{socher-etal-2013-recursive,\n title = \"Recursive Deep Models for Semantic Compositionality Over a Sentiment Treebank\",\n author = \"Socher, Richard and Perelygin, Alex and Wu, Jean and\n 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 month = oct,\n year = \"2013\",\n address = \"Seattle, Washington, USA\",\n publisher = \"Association for Computational Linguistics\",\n url = \"https://www.aclweb.org/anthology/D13-1170\",\n pages = \"1631--1642\",\n}\n", "homepage": "https://nlp.stanford.edu/sentiment/", "license": "", "features": {"phrase": {"dtype": "string", "id": null, "_type": "Value"}, "label": {"dtype": "float32", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "builder_name": "sst", "config_name": "dictionary", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"dictionary": {"name": "dictionary", "num_bytes": 12121843, "num_examples": 239232, "dataset_name": "sst"}}, "download_checksums": {"https://nlp.stanford.edu/~socherr/stanfordSentimentTreebank.zip": {"num_bytes": 6372817, "checksum": "3f5209483b46bbf129cacbbbe6ae02fe780407034f61cf6342b7833257c3f1db"}, "https://nlp.stanford.edu/sentiment/trainDevTestTrees_PTB.zip": {"num_bytes": 789539, "checksum": "5c613a4f673fc74097d523a2c83f38e0cc462984d847b82c7aaf36b01cbbbfcc"}}, "download_size": 7162356, "post_processing_size": null, "dataset_size": 12121843, "size_in_bytes": 19284199}, "ptb": {"description": "The Stanford Sentiment Treebank, the first corpus with fully labeled parse trees that allows for a\ncomplete analysis of the compositional effects of sentiment in language.\n", "citation": "@inproceedings{socher-etal-2013-recursive,\n title = \"Recursive Deep Models for Semantic Compositionality Over a Sentiment Treebank\",\n author = \"Socher, Richard and Perelygin, Alex and Wu, Jean and\n 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 month = oct,\n year = \"2013\",\n address = \"Seattle, Washington, USA\",\n publisher = \"Association for Computational Linguistics\",\n url = \"https://www.aclweb.org/anthology/D13-1170\",\n pages = \"1631--1642\",\n}\n", "homepage": "https://nlp.stanford.edu/sentiment/", "license": "", "features": {"ptb_tree": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "builder_name": "sst", "config_name": "ptb", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 2185694, "num_examples": 8544, "dataset_name": "sst"}, "validation": {"name": "validation", "num_bytes": 284132, "num_examples": 1101, "dataset_name": "sst"}, "test": {"name": "test", "num_bytes": 566248, "num_examples": 2210, "dataset_name": "sst"}}, "download_checksums": {"https://nlp.stanford.edu/~socherr/stanfordSentimentTreebank.zip": {"num_bytes": 6372817, "checksum": "3f5209483b46bbf129cacbbbe6ae02fe780407034f61cf6342b7833257c3f1db"}, "https://nlp.stanford.edu/sentiment/trainDevTestTrees_PTB.zip": {"num_bytes": 789539, "checksum": "5c613a4f673fc74097d523a2c83f38e0cc462984d847b82c7aaf36b01cbbbfcc"}}, "download_size": 7162356, "post_processing_size": null, "dataset_size": 3036074, "size_in_bytes": 10198430}}
dummy/default/1.0.0/dummy_data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:605f2a643fdf537402cadaeec68e1e4c9d773001fc42f954b3aa33a8b752d8ee
3
+ size 7759
dummy/dictionary/1.0.0/dummy_data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:605f2a643fdf537402cadaeec68e1e4c9d773001fc42f954b3aa33a8b752d8ee
3
+ size 7759
dummy/ptb/1.0.0/dummy_data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:605f2a643fdf537402cadaeec68e1e4c9d773001fc42f954b3aa33a8b752d8ee
3
+ size 7759
sst.py ADDED
@@ -0,0 +1,209 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
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
+ """TODO: Add a description here."""
16
+
17
+ from __future__ import absolute_import, division, print_function
18
+
19
+ import csv
20
+ import os
21
+
22
+ import datasets
23
+
24
+
25
+ _CITATION = """\
26
+ @inproceedings{socher-etal-2013-recursive,
27
+ title = "Recursive Deep Models for Semantic Compositionality Over a Sentiment Treebank",
28
+ author = "Socher, Richard and Perelygin, Alex and Wu, Jean and
29
+ Chuang, Jason and Manning, Christopher D. and Ng, Andrew and Potts, Christopher",
30
+ booktitle = "Proceedings of the 2013 Conference on Empirical Methods in Natural Language Processing",
31
+ month = oct,
32
+ year = "2013",
33
+ address = "Seattle, Washington, USA",
34
+ publisher = "Association for Computational Linguistics",
35
+ url = "https://www.aclweb.org/anthology/D13-1170",
36
+ pages = "1631--1642",
37
+ }
38
+ """
39
+
40
+ _DESCRIPTION = """\
41
+ The Stanford Sentiment Treebank, the first corpus with fully labeled parse trees that allows for a
42
+ complete analysis of the compositional effects of sentiment in language.
43
+ """
44
+
45
+ _HOMEPAGE = "https://nlp.stanford.edu/sentiment/"
46
+
47
+ _LICENSE = ""
48
+
49
+ _DEFAULT_URL = "https://nlp.stanford.edu/~socherr/stanfordSentimentTreebank.zip"
50
+ _PTB_URL = "https://nlp.stanford.edu/sentiment/trainDevTestTrees_PTB.zip"
51
+
52
+
53
+ class Sst(datasets.GeneratorBasedBuilder):
54
+ """The Stanford Sentiment Treebank"""
55
+
56
+ VERSION = datasets.Version("1.0.0")
57
+
58
+ BUILDER_CONFIGS = [
59
+ datasets.BuilderConfig(
60
+ name="default",
61
+ version=VERSION,
62
+ description="Sentences and relative parse trees annotated with sentiment labels.",
63
+ ),
64
+ datasets.BuilderConfig(
65
+ name="dictionary",
66
+ version=VERSION,
67
+ description="List of all possible sub-sentences (phrases) with their sentiment label.",
68
+ ),
69
+ datasets.BuilderConfig(
70
+ name="ptb", version=VERSION, description="Penn Treebank-formatted trees with labelled sub-sentences."
71
+ ),
72
+ ]
73
+
74
+ DEFAULT_CONFIG_NAME = "default"
75
+
76
+ def _info(self):
77
+
78
+ if self.config.name == "default":
79
+ features = datasets.Features(
80
+ {
81
+ "sentence": datasets.Value("string"),
82
+ "label": datasets.Value("float"),
83
+ "tokens": datasets.Value("string"),
84
+ "tree": datasets.Value("string"),
85
+ }
86
+ )
87
+ elif self.config.name == "dictionary":
88
+ features = datasets.Features({"phrase": datasets.Value("string"), "label": datasets.Value("float")})
89
+ else:
90
+ features = datasets.Features(
91
+ {
92
+ "ptb_tree": datasets.Value("string"),
93
+ }
94
+ )
95
+
96
+ return datasets.DatasetInfo(
97
+ description=_DESCRIPTION,
98
+ features=features,
99
+ supervised_keys=None,
100
+ homepage=_HOMEPAGE,
101
+ citation=_CITATION,
102
+ )
103
+
104
+ def _split_generators(self, dl_manager):
105
+ default_dir = dl_manager.download_and_extract(_DEFAULT_URL)
106
+ ptb_dir = dl_manager.download_and_extract(_PTB_URL)
107
+
108
+ file_paths = {}
109
+ for split_index in range(0, 4):
110
+ file_paths[split_index] = {
111
+ "phrases_path": os.path.join(default_dir, "stanfordSentimentTreebank/dictionary.txt"),
112
+ "labels_path": os.path.join(default_dir, "stanfordSentimentTreebank/sentiment_labels.txt"),
113
+ "tokens_path": os.path.join(default_dir, "stanfordSentimentTreebank/SOStr.txt"),
114
+ "trees_path": os.path.join(default_dir, "stanfordSentimentTreebank/STree.txt"),
115
+ "splits_path": os.path.join(default_dir, "stanfordSentimentTreebank/datasetSplit.txt"),
116
+ "sentences_path": os.path.join(default_dir, "stanfordSentimentTreebank/datasetSentences.txt"),
117
+ "ptb_filepath": None,
118
+ "split_id": str(split_index),
119
+ }
120
+
121
+ ptb_file_paths = {}
122
+ for ptb_split in ["train", "dev", "test"]:
123
+ ptb_file_paths[ptb_split] = {
124
+ "phrases_path": None,
125
+ "labels_path": None,
126
+ "tokens_path": None,
127
+ "trees_path": None,
128
+ "splits_path": None,
129
+ "sentences_path": None,
130
+ "ptb_filepath": os.path.join(ptb_dir, "trees/" + ptb_split + ".txt"),
131
+ "split_id": None,
132
+ }
133
+
134
+ if self.config.name == "default":
135
+ return [
136
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs=file_paths[1]),
137
+ datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs=file_paths[3]),
138
+ datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs=file_paths[2]),
139
+ ]
140
+ elif self.config.name == "dictionary":
141
+ return [datasets.SplitGenerator(name="dictionary", gen_kwargs=file_paths[0])]
142
+ else:
143
+ return [
144
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs=ptb_file_paths["train"]),
145
+ datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs=ptb_file_paths["dev"]),
146
+ datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs=ptb_file_paths["test"]),
147
+ ]
148
+
149
+ def _generate_examples(
150
+ self, phrases_path, labels_path, tokens_path, trees_path, splits_path, sentences_path, split_id, ptb_filepath
151
+ ):
152
+
153
+ if self.config.name == "ptb":
154
+ with open(ptb_filepath, encoding="utf-8") as fp:
155
+ ptb_reader = csv.reader(fp, delimiter="\t", quoting=csv.QUOTE_NONE)
156
+ for id_, row in enumerate(ptb_reader):
157
+ yield id_, {"ptb_tree": row[0]}
158
+ else:
159
+ labels = {}
160
+ phrases = {}
161
+ with open(labels_path, encoding="utf-8") as g, open(phrases_path, encoding="utf-8") as f:
162
+ label_reader = csv.DictReader(g, delimiter="|", quoting=csv.QUOTE_NONE)
163
+ for row in label_reader:
164
+ labels[row["phrase ids"]] = float(row["sentiment values"])
165
+
166
+ phrase_reader = csv.reader(f, delimiter="|", quoting=csv.QUOTE_NONE)
167
+ if self.config.name == "dictionary":
168
+ for id_, row in enumerate(phrase_reader):
169
+ yield id_, {"phrase": row[0], "label": labels[row[1]]}
170
+ else:
171
+ for row in phrase_reader:
172
+ phrases[row[0]] = labels[row[1]]
173
+
174
+ # Case config=="default"
175
+ # Read parse trees for each complete sentence
176
+ trees = {}
177
+ with open(tokens_path, encoding="utf-8") as tok, open(trees_path, encoding="utf-8") as tr:
178
+ tok_reader = csv.reader(tok, delimiter="\t", quoting=csv.QUOTE_NONE)
179
+ tree_reader = csv.reader(tr, delimiter="\t", quoting=csv.QUOTE_NONE)
180
+ for i, row in enumerate(tok_reader, start=1):
181
+ trees[i] = {}
182
+ trees[i]["tokens"] = row[0]
183
+ for i, row in enumerate(tree_reader, start=1):
184
+ trees[i]["tree"] = row[0]
185
+
186
+ with open(splits_path, encoding="utf-8") as spl, open(sentences_path, encoding="utf-8") as snt:
187
+ splits_reader = csv.DictReader(spl, delimiter=",", quoting=csv.QUOTE_NONE)
188
+ splits = {row["sentence_index"]: row["splitset_label"] for row in splits_reader}
189
+
190
+ sentence_reader = csv.DictReader(snt, delimiter="\t", quoting=csv.QUOTE_NONE)
191
+ for id_, row in enumerate(sentence_reader):
192
+ # fix encoding, see https://github.com/huggingface/datasets/pull/1961#discussion_r585969890
193
+ row["sentence"] = (
194
+ row["sentence"]
195
+ .encode("utf-8")
196
+ .replace(b"\xc3\x83\xc2", b"\xc3")
197
+ .replace(b"\xc3\x82\xc2", b"\xc2")
198
+ .decode("utf-8")
199
+ )
200
+ row["sentence"] = row["sentence"].replace("-LRB-", "(").replace("-RRB-", ")")
201
+ if splits[row["sentence_index"]] == split_id:
202
+ tokens = trees[int(row["sentence_index"])]["tokens"]
203
+ parse_tree = trees[int(row["sentence_index"])]["tree"]
204
+ yield id_, {
205
+ "sentence": row["sentence"],
206
+ "label": phrases[row["sentence"]],
207
+ "tokens": tokens,
208
+ "tree": parse_tree,
209
+ }