Datasets:
Tasks:
Text Classification
Modalities:
Text
Formats:
parquet
Sub-tasks:
sentiment-classification
Languages:
English
Size:
1M - 10M
ArXiv:
License:
Update files from the datasets library (from 1.16.0)
Browse filesRelease notes: https://github.com/huggingface/datasets/releases/tag/1.16.0
- README.md +2 -1
- amazon_polarity.py +17 -16
README.md
CHANGED
|
@@ -18,9 +18,10 @@ task_categories:
|
|
| 18 |
task_ids:
|
| 19 |
- sentiment-classification
|
| 20 |
paperswithcode_id: null
|
|
|
|
| 21 |
---
|
| 22 |
|
| 23 |
-
# Dataset Card for
|
| 24 |
|
| 25 |
## Table of Contents
|
| 26 |
- [Dataset Description](#dataset-description)
|
|
|
|
| 18 |
task_ids:
|
| 19 |
- sentiment-classification
|
| 20 |
paperswithcode_id: null
|
| 21 |
+
pretty_name: Amazon Review Polarity
|
| 22 |
---
|
| 23 |
|
| 24 |
+
# Dataset Card for Amazon Review Polarity
|
| 25 |
|
| 26 |
## Table of Contents
|
| 27 |
- [Dataset Description](#dataset-description)
|
amazon_polarity.py
CHANGED
|
@@ -16,7 +16,6 @@
|
|
| 16 |
|
| 17 |
|
| 18 |
import csv
|
| 19 |
-
import os
|
| 20 |
|
| 21 |
import datasets
|
| 22 |
|
|
@@ -94,32 +93,34 @@ class AmazonPolarity(datasets.GeneratorBasedBuilder):
|
|
| 94 |
def _split_generators(self, dl_manager):
|
| 95 |
"""Returns SplitGenerators."""
|
| 96 |
my_urls = _URLs[self.config.name]
|
| 97 |
-
|
| 98 |
return [
|
| 99 |
datasets.SplitGenerator(
|
| 100 |
name=datasets.Split.TRAIN,
|
| 101 |
gen_kwargs={
|
| 102 |
-
"filepath":
|
| 103 |
-
"
|
| 104 |
},
|
| 105 |
),
|
| 106 |
datasets.SplitGenerator(
|
| 107 |
name=datasets.Split.TEST,
|
| 108 |
gen_kwargs={
|
| 109 |
-
"filepath":
|
| 110 |
-
"
|
| 111 |
},
|
| 112 |
),
|
| 113 |
]
|
| 114 |
|
| 115 |
-
def _generate_examples(self, filepath,
|
| 116 |
"""Yields examples."""
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
|
| 18 |
import csv
|
|
|
|
| 19 |
|
| 20 |
import datasets
|
| 21 |
|
|
|
|
| 93 |
def _split_generators(self, dl_manager):
|
| 94 |
"""Returns SplitGenerators."""
|
| 95 |
my_urls = _URLs[self.config.name]
|
| 96 |
+
archive = dl_manager.download(my_urls)
|
| 97 |
return [
|
| 98 |
datasets.SplitGenerator(
|
| 99 |
name=datasets.Split.TRAIN,
|
| 100 |
gen_kwargs={
|
| 101 |
+
"filepath": "/".join(["amazon_review_polarity_csv", "train.csv"]),
|
| 102 |
+
"files": dl_manager.iter_archive(archive),
|
| 103 |
},
|
| 104 |
),
|
| 105 |
datasets.SplitGenerator(
|
| 106 |
name=datasets.Split.TEST,
|
| 107 |
gen_kwargs={
|
| 108 |
+
"filepath": "/".join(["amazon_review_polarity_csv", "test.csv"]),
|
| 109 |
+
"files": dl_manager.iter_archive(archive),
|
| 110 |
},
|
| 111 |
),
|
| 112 |
]
|
| 113 |
|
| 114 |
+
def _generate_examples(self, filepath, files):
|
| 115 |
"""Yields examples."""
|
| 116 |
+
for path, f in files:
|
| 117 |
+
if path == filepath:
|
| 118 |
+
lines = (line.decode("utf-8") for line in f)
|
| 119 |
+
data = csv.reader(lines, delimiter=",", quoting=csv.QUOTE_ALL)
|
| 120 |
+
for id_, row in enumerate(data):
|
| 121 |
+
yield id_, {
|
| 122 |
+
"title": row[1],
|
| 123 |
+
"content": row[2],
|
| 124 |
+
"label": int(row[0]) - 1,
|
| 125 |
+
}
|
| 126 |
+
break
|