albertvillanova HF staff commited on
Commit
7a396a7
1 Parent(s): f302f60

Delete loading script

Browse files
Files changed (1) hide show
  1. amazon_polarity.py +0 -126
amazon_polarity.py DELETED
@@ -1,126 +0,0 @@
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
- """The amazon polarity dataset for text classification."""
16
-
17
-
18
- import csv
19
-
20
- import datasets
21
-
22
-
23
- _CITATION = """\
24
- @inproceedings{mcauley2013hidden,
25
- title={Hidden factors and hidden topics: understanding rating dimensions with review text},
26
- author={McAuley, Julian and Leskovec, Jure},
27
- booktitle={Proceedings of the 7th ACM conference on Recommender systems},
28
- pages={165--172},
29
- year={2013}
30
- }
31
- """
32
-
33
- _DESCRIPTION = """\
34
- The Amazon reviews dataset consists of reviews from amazon.
35
- The data span a period of 18 years, including ~35 million reviews up to March 2013.
36
- Reviews include product and user information, ratings, and a plaintext review.
37
- """
38
-
39
- _HOMEPAGE = "https://registry.opendata.aws/"
40
-
41
- _LICENSE = "Apache License 2.0"
42
-
43
- _URLs = {
44
- "amazon_polarity": "https://s3.amazonaws.com/fast-ai-nlp/amazon_review_polarity_csv.tgz",
45
- }
46
-
47
-
48
- class AmazonPolarityConfig(datasets.BuilderConfig):
49
- """BuilderConfig for AmazonPolarity."""
50
-
51
- def __init__(self, **kwargs):
52
- """BuilderConfig for AmazonPolarity.
53
-
54
- Args:
55
- **kwargs: keyword arguments forwarded to super.
56
- """
57
- super(AmazonPolarityConfig, self).__init__(**kwargs)
58
-
59
-
60
- class AmazonPolarity(datasets.GeneratorBasedBuilder):
61
- """Amazon Polarity Classification Dataset."""
62
-
63
- VERSION = datasets.Version("3.0.0")
64
-
65
- BUILDER_CONFIGS = [
66
- AmazonPolarityConfig(
67
- name="amazon_polarity", version=VERSION, description="Amazon Polarity Classification Dataset."
68
- ),
69
- ]
70
-
71
- def _info(self):
72
- features = datasets.Features(
73
- {
74
- "label": datasets.features.ClassLabel(
75
- names=[
76
- "negative",
77
- "positive",
78
- ]
79
- ),
80
- "title": datasets.Value("string"),
81
- "content": datasets.Value("string"),
82
- }
83
- )
84
- return datasets.DatasetInfo(
85
- description=_DESCRIPTION,
86
- features=features,
87
- supervised_keys=None,
88
- homepage=_HOMEPAGE,
89
- license=_LICENSE,
90
- citation=_CITATION,
91
- )
92
-
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