Datasets:
Tasks:
Text Classification
Modalities:
Text
Formats:
parquet
Sub-tasks:
sentiment-classification
Languages:
English
Size:
100K - 1M
ArXiv:
parquet-converter
commited on
Commit
•
247cd49
1
Parent(s):
9281891
Update parquet files
Browse files- .gitattributes +0 -27
- README.md +0 -254
- dataset_infos.json +0 -1
- plain_text/yelp_polarity-test.parquet +3 -0
- plain_text/yelp_polarity-train.parquet +3 -0
- yelp_polarity.py +0 -162
.gitattributes
DELETED
@@ -1,27 +0,0 @@
|
|
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
DELETED
@@ -1,254 +0,0 @@
|
|
1 |
-
---
|
2 |
-
language:
|
3 |
-
- en
|
4 |
-
paperswithcode_id: null
|
5 |
-
pretty_name: YelpPolarity
|
6 |
-
train-eval-index:
|
7 |
-
- config: plain_text
|
8 |
-
task: text-classification
|
9 |
-
task_id: binary_classification
|
10 |
-
splits:
|
11 |
-
train_split: train
|
12 |
-
eval_split: test
|
13 |
-
col_mapping:
|
14 |
-
text: text
|
15 |
-
label: target
|
16 |
-
metrics:
|
17 |
-
- type: accuracy
|
18 |
-
name: Accuracy
|
19 |
-
- type: f1
|
20 |
-
name: F1 binary
|
21 |
-
args:
|
22 |
-
average: binary
|
23 |
-
- type: precision
|
24 |
-
name: Precision macro
|
25 |
-
args:
|
26 |
-
average: macro
|
27 |
-
- type: precision
|
28 |
-
name: Precision micro
|
29 |
-
args:
|
30 |
-
average: micro
|
31 |
-
- type: precision
|
32 |
-
name: Precision weighted
|
33 |
-
args:
|
34 |
-
average: weighted
|
35 |
-
- type: recall
|
36 |
-
name: Recall macro
|
37 |
-
args:
|
38 |
-
average: macro
|
39 |
-
- type: recall
|
40 |
-
name: Recall micro
|
41 |
-
args:
|
42 |
-
average: micro
|
43 |
-
- type: recall
|
44 |
-
name: Recall weighted
|
45 |
-
args:
|
46 |
-
average: weighted
|
47 |
-
dataset_info:
|
48 |
-
features:
|
49 |
-
- name: text
|
50 |
-
dtype: string
|
51 |
-
- name: label
|
52 |
-
dtype:
|
53 |
-
class_label:
|
54 |
-
names:
|
55 |
-
0: '1'
|
56 |
-
1: '2'
|
57 |
-
config_name: plain_text
|
58 |
-
splits:
|
59 |
-
- name: train
|
60 |
-
num_bytes: 413558837
|
61 |
-
num_examples: 560000
|
62 |
-
- name: test
|
63 |
-
num_bytes: 27962097
|
64 |
-
num_examples: 38000
|
65 |
-
download_size: 166373201
|
66 |
-
dataset_size: 441520934
|
67 |
-
---
|
68 |
-
|
69 |
-
# Dataset Card for "yelp_polarity"
|
70 |
-
|
71 |
-
## Table of Contents
|
72 |
-
- [Dataset Description](#dataset-description)
|
73 |
-
- [Dataset Summary](#dataset-summary)
|
74 |
-
- [Supported Tasks and Leaderboards](#supported-tasks-and-leaderboards)
|
75 |
-
- [Languages](#languages)
|
76 |
-
- [Dataset Structure](#dataset-structure)
|
77 |
-
- [Data Instances](#data-instances)
|
78 |
-
- [Data Fields](#data-fields)
|
79 |
-
- [Data Splits](#data-splits)
|
80 |
-
- [Dataset Creation](#dataset-creation)
|
81 |
-
- [Curation Rationale](#curation-rationale)
|
82 |
-
- [Source Data](#source-data)
|
83 |
-
- [Annotations](#annotations)
|
84 |
-
- [Personal and Sensitive Information](#personal-and-sensitive-information)
|
85 |
-
- [Considerations for Using the Data](#considerations-for-using-the-data)
|
86 |
-
- [Social Impact of Dataset](#social-impact-of-dataset)
|
87 |
-
- [Discussion of Biases](#discussion-of-biases)
|
88 |
-
- [Other Known Limitations](#other-known-limitations)
|
89 |
-
- [Additional Information](#additional-information)
|
90 |
-
- [Dataset Curators](#dataset-curators)
|
91 |
-
- [Licensing Information](#licensing-information)
|
92 |
-
- [Citation Information](#citation-information)
|
93 |
-
- [Contributions](#contributions)
|
94 |
-
|
95 |
-
## Dataset Description
|
96 |
-
|
97 |
-
- **Homepage:** [https://course.fast.ai/datasets](https://course.fast.ai/datasets)
|
98 |
-
- **Repository:** [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
|
99 |
-
- **Paper:** [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
|
100 |
-
- **Point of Contact:** [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
|
101 |
-
- **Size of downloaded dataset files:** 158.67 MB
|
102 |
-
- **Size of the generated dataset:** 421.28 MB
|
103 |
-
- **Total amount of disk used:** 579.95 MB
|
104 |
-
|
105 |
-
### Dataset Summary
|
106 |
-
|
107 |
-
Large Yelp Review Dataset.
|
108 |
-
This is a dataset for binary sentiment classification. We provide a set of 560,000 highly polar yelp reviews for training, and 38,000 for testing.
|
109 |
-
ORIGIN
|
110 |
-
The Yelp reviews dataset consists of reviews from Yelp. It is extracted
|
111 |
-
from the Yelp Dataset Challenge 2015 data. For more information, please
|
112 |
-
refer to http://www.yelp.com/dataset_challenge
|
113 |
-
|
114 |
-
The Yelp reviews polarity dataset is constructed by
|
115 |
-
Xiang Zhang (xiang.zhang@nyu.edu) from the above dataset.
|
116 |
-
It is first used as a text classification benchmark in the following paper:
|
117 |
-
Xiang Zhang, Junbo Zhao, Yann LeCun. Character-level Convolutional Networks
|
118 |
-
for Text Classification. Advances in Neural Information Processing Systems 28
|
119 |
-
(NIPS 2015).
|
120 |
-
|
121 |
-
DESCRIPTION
|
122 |
-
|
123 |
-
The Yelp reviews polarity dataset is constructed by considering stars 1 and 2
|
124 |
-
negative, and 3 and 4 positive. For each polarity 280,000 training samples and
|
125 |
-
19,000 testing samples are take randomly. In total there are 560,000 trainig
|
126 |
-
samples and 38,000 testing samples. Negative polarity is class 1,
|
127 |
-
and positive class 2.
|
128 |
-
|
129 |
-
The files train.csv and test.csv contain all the training samples as
|
130 |
-
comma-sparated values. There are 2 columns in them, corresponding to class
|
131 |
-
index (1 and 2) and review text. The review texts are escaped using double
|
132 |
-
quotes ("), and any internal double quote is escaped by 2 double quotes ("").
|
133 |
-
New lines are escaped by a backslash followed with an "n" character,
|
134 |
-
that is "
|
135 |
-
".
|
136 |
-
|
137 |
-
### Supported Tasks and Leaderboards
|
138 |
-
|
139 |
-
[More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
|
140 |
-
|
141 |
-
### Languages
|
142 |
-
|
143 |
-
[More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
|
144 |
-
|
145 |
-
## Dataset Structure
|
146 |
-
|
147 |
-
### Data Instances
|
148 |
-
|
149 |
-
#### plain_text
|
150 |
-
|
151 |
-
- **Size of downloaded dataset files:** 158.67 MB
|
152 |
-
- **Size of the generated dataset:** 421.28 MB
|
153 |
-
- **Total amount of disk used:** 579.95 MB
|
154 |
-
|
155 |
-
An example of 'train' looks as follows.
|
156 |
-
```
|
157 |
-
This example was too long and was cropped:
|
158 |
-
|
159 |
-
{
|
160 |
-
"label": 0,
|
161 |
-
"text": "\"Unfortunately, the frustration of being Dr. Goldberg's patient is a repeat of the experience I've had with so many other doctor..."
|
162 |
-
}
|
163 |
-
```
|
164 |
-
|
165 |
-
### Data Fields
|
166 |
-
|
167 |
-
The data fields are the same among all splits.
|
168 |
-
|
169 |
-
#### plain_text
|
170 |
-
- `text`: a `string` feature.
|
171 |
-
- `label`: a classification label, with possible values including `1` (0), `2` (1).
|
172 |
-
|
173 |
-
### Data Splits
|
174 |
-
|
175 |
-
| name |train |test |
|
176 |
-
|----------|-----:|----:|
|
177 |
-
|plain_text|560000|38000|
|
178 |
-
|
179 |
-
## Dataset Creation
|
180 |
-
|
181 |
-
### Curation Rationale
|
182 |
-
|
183 |
-
[More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
|
184 |
-
|
185 |
-
### Source Data
|
186 |
-
|
187 |
-
#### Initial Data Collection and Normalization
|
188 |
-
|
189 |
-
[More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
|
190 |
-
|
191 |
-
#### Who are the source language producers?
|
192 |
-
|
193 |
-
[More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
|
194 |
-
|
195 |
-
### Annotations
|
196 |
-
|
197 |
-
#### Annotation process
|
198 |
-
|
199 |
-
[More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
|
200 |
-
|
201 |
-
#### Who are the annotators?
|
202 |
-
|
203 |
-
[More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
|
204 |
-
|
205 |
-
### Personal and Sensitive Information
|
206 |
-
|
207 |
-
[More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
|
208 |
-
|
209 |
-
## Considerations for Using the Data
|
210 |
-
|
211 |
-
### Social Impact of Dataset
|
212 |
-
|
213 |
-
[More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
|
214 |
-
|
215 |
-
### Discussion of Biases
|
216 |
-
|
217 |
-
[More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
|
218 |
-
|
219 |
-
### Other Known Limitations
|
220 |
-
|
221 |
-
[More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
|
222 |
-
|
223 |
-
## Additional Information
|
224 |
-
|
225 |
-
### Dataset Curators
|
226 |
-
|
227 |
-
[More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
|
228 |
-
|
229 |
-
### Licensing Information
|
230 |
-
|
231 |
-
[More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
|
232 |
-
|
233 |
-
### Citation Information
|
234 |
-
|
235 |
-
```
|
236 |
-
@article{zhangCharacterlevelConvolutionalNetworks2015,
|
237 |
-
archivePrefix = {arXiv},
|
238 |
-
eprinttype = {arxiv},
|
239 |
-
eprint = {1509.01626},
|
240 |
-
primaryClass = {cs},
|
241 |
-
title = {Character-Level {{Convolutional Networks}} for {{Text Classification}}},
|
242 |
-
abstract = {This article offers an empirical exploration on the use of character-level convolutional networks (ConvNets) for text classification. We constructed several large-scale datasets to show that character-level convolutional networks could achieve state-of-the-art or competitive results. Comparisons are offered against traditional models such as bag of words, n-grams and their TFIDF variants, and deep learning models such as word-based ConvNets and recurrent neural networks.},
|
243 |
-
journal = {arXiv:1509.01626 [cs]},
|
244 |
-
author = {Zhang, Xiang and Zhao, Junbo and LeCun, Yann},
|
245 |
-
month = sep,
|
246 |
-
year = {2015},
|
247 |
-
}
|
248 |
-
|
249 |
-
```
|
250 |
-
|
251 |
-
|
252 |
-
### Contributions
|
253 |
-
|
254 |
-
Thanks to [@patrickvonplaten](https://github.com/patrickvonplaten), [@lewtun](https://github.com/lewtun), [@mariamabarham](https://github.com/mariamabarham), [@thomwolf](https://github.com/thomwolf), [@julien-c](https://github.com/julien-c) for adding this dataset.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dataset_infos.json
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
{"plain_text": {"description": "Large Yelp Review Dataset.\nThis is a dataset for binary sentiment classification. We provide a set of 560,000 highly polar yelp reviews for training, and 38,000 for testing. \nORIGIN\nThe Yelp reviews dataset consists of reviews from Yelp. It is extracted\nfrom the Yelp Dataset Challenge 2015 data. For more information, please\nrefer to http://www.yelp.com/dataset_challenge\n\nThe Yelp reviews polarity dataset is constructed by\nXiang Zhang (xiang.zhang@nyu.edu) from the above dataset.\nIt is first used as a text classification benchmark in the following paper:\nXiang Zhang, Junbo Zhao, Yann LeCun. Character-level Convolutional Networks\nfor Text Classification. Advances in Neural Information Processing Systems 28\n(NIPS 2015).\n\n\nDESCRIPTION\n\nThe Yelp reviews polarity dataset is constructed by considering stars 1 and 2\nnegative, and 3 and 4 positive. For each polarity 280,000 training samples and\n19,000 testing samples are take randomly. In total there are 560,000 trainig\nsamples and 38,000 testing samples. Negative polarity is class 1,\nand positive class 2.\n\nThe files train.csv and test.csv contain all the training samples as\ncomma-sparated values. There are 2 columns in them, corresponding to class\nindex (1 and 2) and review text. The review texts are escaped using double\nquotes (\"), and any internal double quote is escaped by 2 double quotes (\"\").\nNew lines are escaped by a backslash followed with an \"n\" character,\nthat is \"\n\".\n", "citation": "@article{zhangCharacterlevelConvolutionalNetworks2015,\n archivePrefix = {arXiv},\n eprinttype = {arxiv},\n eprint = {1509.01626},\n primaryClass = {cs},\n title = {Character-Level {{Convolutional Networks}} for {{Text Classification}}},\n abstract = {This article offers an empirical exploration on the use of character-level convolutional networks (ConvNets) for text classification. We constructed several large-scale datasets to show that character-level convolutional networks could achieve state-of-the-art or competitive results. Comparisons are offered against traditional models such as bag of words, n-grams and their TFIDF variants, and deep learning models such as word-based ConvNets and recurrent neural networks.},\n journal = {arXiv:1509.01626 [cs]},\n author = {Zhang, Xiang and Zhao, Junbo and LeCun, Yann},\n month = sep,\n year = {2015},\n}\n\n", "homepage": "https://course.fast.ai/datasets", "license": "", "features": {"text": {"dtype": "string", "id": null, "_type": "Value"}, "label": {"num_classes": 2, "names": ["1", "2"], "id": null, "_type": "ClassLabel"}}, "post_processed": null, "supervised_keys": null, "task_templates": [{"task": "text-classification", "text_column": "text", "label_column": "label"}], "builder_name": "yelp_polarity", "config_name": "plain_text", "version": {"version_str": "1.0.0", "description": "", "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 413558837, "num_examples": 560000, "dataset_name": "yelp_polarity"}, "test": {"name": "test", "num_bytes": 27962097, "num_examples": 38000, "dataset_name": "yelp_polarity"}}, "download_checksums": {"https://s3.amazonaws.com/fast-ai-nlp/yelp_review_polarity_csv.tgz": {"num_bytes": 166373201, "checksum": "528f22e286cad085948acbc3bea7e58188416546b0e364d0ae4ca0ce666abe35"}}, "download_size": 166373201, "post_processing_size": null, "dataset_size": 441520934, "size_in_bytes": 607894135}}
|
|
|
|
plain_text/yelp_polarity-test.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7bda66b42b8e0c36f9a7872a034975a0f012d6aa29b6921c32be5fdc7b5a7383
|
3 |
+
size 17701457
|
plain_text/yelp_polarity-train.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6754c3aeca189120e87d1321f7c589918dfa7146782bd87058e353381bf1c8c8
|
3 |
+
size 256101806
|
yelp_polarity.py
DELETED
@@ -1,162 +0,0 @@
|
|
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 |
-
# Copyright 2019 The TensorFlow Datasets Authors and the HuggingFace Datasets Authors.
|
18 |
-
#
|
19 |
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
20 |
-
# you may not use this file except in compliance with the License.
|
21 |
-
# You may obtain a copy of the License at
|
22 |
-
#
|
23 |
-
# http://www.apache.org/licenses/LICENSE-2.0
|
24 |
-
#
|
25 |
-
# Unless required by applicable law or agreed to in writing, software
|
26 |
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
27 |
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
28 |
-
# See the License for the specific language governing permissions and
|
29 |
-
# limitations under the License.
|
30 |
-
"""Yelp Polarity Reviews dataset."""
|
31 |
-
|
32 |
-
|
33 |
-
import datasets
|
34 |
-
from datasets.tasks import TextClassification
|
35 |
-
|
36 |
-
|
37 |
-
_DESCRIPTION = """\
|
38 |
-
Large Yelp Review Dataset.
|
39 |
-
This is a dataset for binary sentiment classification. \
|
40 |
-
We provide a set of 560,000 highly polar yelp reviews for training, and 38,000 for testing. \
|
41 |
-
|
42 |
-
ORIGIN
|
43 |
-
The Yelp reviews dataset consists of reviews from Yelp. It is extracted
|
44 |
-
from the Yelp Dataset Challenge 2015 data. For more information, please
|
45 |
-
refer to http://www.yelp.com/dataset_challenge
|
46 |
-
|
47 |
-
The Yelp reviews polarity dataset is constructed by
|
48 |
-
Xiang Zhang (xiang.zhang@nyu.edu) from the above dataset.
|
49 |
-
It is first used as a text classification benchmark in the following paper:
|
50 |
-
Xiang Zhang, Junbo Zhao, Yann LeCun. Character-level Convolutional Networks
|
51 |
-
for Text Classification. Advances in Neural Information Processing Systems 28
|
52 |
-
(NIPS 2015).
|
53 |
-
|
54 |
-
|
55 |
-
DESCRIPTION
|
56 |
-
|
57 |
-
The Yelp reviews polarity dataset is constructed by considering stars 1 and 2
|
58 |
-
negative, and 3 and 4 positive. For each polarity 280,000 training samples and
|
59 |
-
19,000 testing samples are take randomly. In total there are 560,000 trainig
|
60 |
-
samples and 38,000 testing samples. Negative polarity is class 1,
|
61 |
-
and positive class 2.
|
62 |
-
|
63 |
-
The files train.csv and test.csv contain all the training samples as
|
64 |
-
comma-sparated values. There are 2 columns in them, corresponding to class
|
65 |
-
index (1 and 2) and review text. The review texts are escaped using double
|
66 |
-
quotes ("), and any internal double quote is escaped by 2 double quotes ("").
|
67 |
-
New lines are escaped by a backslash followed with an "n" character,
|
68 |
-
that is "\n".
|
69 |
-
"""
|
70 |
-
|
71 |
-
_CITATION = """\
|
72 |
-
@article{zhangCharacterlevelConvolutionalNetworks2015,
|
73 |
-
archivePrefix = {arXiv},
|
74 |
-
eprinttype = {arxiv},
|
75 |
-
eprint = {1509.01626},
|
76 |
-
primaryClass = {cs},
|
77 |
-
title = {Character-Level {{Convolutional Networks}} for {{Text Classification}}},
|
78 |
-
abstract = {This article offers an empirical exploration on the use of character-level convolutional networks (ConvNets) for text classification. We constructed several large-scale datasets to show that character-level convolutional networks could achieve state-of-the-art or competitive results. Comparisons are offered against traditional models such as bag of words, n-grams and their TFIDF variants, and deep learning models such as word-based ConvNets and recurrent neural networks.},
|
79 |
-
journal = {arXiv:1509.01626 [cs]},
|
80 |
-
author = {Zhang, Xiang and Zhao, Junbo and LeCun, Yann},
|
81 |
-
month = sep,
|
82 |
-
year = {2015},
|
83 |
-
}
|
84 |
-
|
85 |
-
"""
|
86 |
-
|
87 |
-
_DOWNLOAD_URL = "https://s3.amazonaws.com/fast-ai-nlp/yelp_review_polarity_csv.tgz"
|
88 |
-
|
89 |
-
|
90 |
-
class YelpPolarityReviewsConfig(datasets.BuilderConfig):
|
91 |
-
"""BuilderConfig for YelpPolarityReviews."""
|
92 |
-
|
93 |
-
def __init__(self, **kwargs):
|
94 |
-
"""BuilderConfig for YelpPolarityReviews.
|
95 |
-
|
96 |
-
Args:
|
97 |
-
|
98 |
-
**kwargs: keyword arguments forwarded to super.
|
99 |
-
"""
|
100 |
-
super(YelpPolarityReviewsConfig, self).__init__(version=datasets.Version("1.0.0", ""), **kwargs)
|
101 |
-
|
102 |
-
|
103 |
-
class YelpPolarity(datasets.GeneratorBasedBuilder):
|
104 |
-
"""Yelp Polarity reviews dataset."""
|
105 |
-
|
106 |
-
BUILDER_CONFIGS = [
|
107 |
-
YelpPolarityReviewsConfig(
|
108 |
-
name="plain_text",
|
109 |
-
description="Plain text",
|
110 |
-
)
|
111 |
-
]
|
112 |
-
|
113 |
-
def _info(self):
|
114 |
-
return datasets.DatasetInfo(
|
115 |
-
description=_DESCRIPTION,
|
116 |
-
features=datasets.Features(
|
117 |
-
{
|
118 |
-
"text": datasets.Value("string"),
|
119 |
-
"label": datasets.features.ClassLabel(names=["1", "2"]),
|
120 |
-
}
|
121 |
-
),
|
122 |
-
supervised_keys=None,
|
123 |
-
homepage="https://course.fast.ai/datasets",
|
124 |
-
citation=_CITATION,
|
125 |
-
task_templates=[TextClassification(text_column="text", label_column="label")],
|
126 |
-
)
|
127 |
-
|
128 |
-
def _vocab_text_gen(self, train_file):
|
129 |
-
for _, ex in self._generate_examples(train_file):
|
130 |
-
yield ex["text"]
|
131 |
-
|
132 |
-
def _split_generators(self, dl_manager):
|
133 |
-
arch_path = dl_manager.download(_DOWNLOAD_URL)
|
134 |
-
train_file = "yelp_review_polarity_csv/train.csv"
|
135 |
-
test_file = "yelp_review_polarity_csv/test.csv"
|
136 |
-
return [
|
137 |
-
datasets.SplitGenerator(
|
138 |
-
name=datasets.Split.TRAIN,
|
139 |
-
gen_kwargs={
|
140 |
-
"filepath": train_file,
|
141 |
-
"files": dl_manager.iter_archive(arch_path),
|
142 |
-
},
|
143 |
-
),
|
144 |
-
datasets.SplitGenerator(
|
145 |
-
name=datasets.Split.TEST,
|
146 |
-
gen_kwargs={
|
147 |
-
"filepath": test_file,
|
148 |
-
"files": dl_manager.iter_archive(arch_path),
|
149 |
-
},
|
150 |
-
),
|
151 |
-
]
|
152 |
-
|
153 |
-
def _generate_examples(self, filepath, files):
|
154 |
-
"""Generate Yelp examples."""
|
155 |
-
for path, f in files:
|
156 |
-
if path == filepath:
|
157 |
-
for line_id, line in enumerate(f):
|
158 |
-
line = line.decode("utf-8")
|
159 |
-
# The format of the line is:
|
160 |
-
# "1", "The text of the review."
|
161 |
-
yield line_id, {"text": line[5:-2].strip(), "label": line[1]}
|
162 |
-
break
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|