lhoestq HF staff commited on
Commit
7b5d95c
1 Parent(s): 1d4b232

Replace yelp_review_full data url (#4018)

Browse files

* replace yelp_review_full data url

* remove unused import

* update dummy data

Commit from https://github.com/huggingface/datasets/commit/03934c2c279e1d9e009bd6a16aed74f99fc678ba

dataset_infos.json CHANGED
@@ -1 +1 @@
1
- {"yelp_review_full": {"description": "The Yelp reviews dataset consists of reviews from Yelp. It is extracted from the Yelp Dataset Challenge 2015 data.\nThe Yelp reviews full star dataset is constructed by Xiang Zhang (xiang.zhang@nyu.edu) from the above dataset.\nIt is first used as a text classification benchmark in the following paper: Xiang Zhang, Junbo Zhao, Yann LeCun.\nCharacter-level Convolutional Networks for Text Classification. Advances in Neural Information Processing Systems 28 (NIPS 2015).\n", "citation": "@inproceedings{zhang2015character,\n title={Character-level convolutional networks for text classification},\n author={Zhang, Xiang and Zhao, Junbo and LeCun, Yann},\n booktitle={Advances in neural information processing systems},\n pages={649--657},\n year={2015}\n}\n", "homepage": "https://www.yelp.com/dataset", "license": "https://s3-media3.fl.yelpcdn.com/assets/srv0/engineering_pages/bea5c1e92bf3/assets/vendor/yelp-dataset-agreement.pdf", "features": {"label": {"num_classes": 5, "names": ["1 star", "2 star", "3 stars", "4 stars", "5 stars"], "names_file": null, "id": null, "_type": "ClassLabel"}, "text": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": [{"task": "text-classification", "text_column": "text", "label_column": "label", "labels": ["1 star", "2 star", "3 stars", "4 stars", "5 stars"]}], "builder_name": "yelp_review_full", "config_name": "yelp_review_full", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 483811814, "num_examples": 650000, "dataset_name": "yelp_review_full"}, "test": {"name": "test", "num_bytes": 37271208, "num_examples": 50000, "dataset_name": "yelp_review_full"}}, "download_checksums": {"https://drive.google.com/uc?export=download&id=0Bz8a_Dbh9QhbZlU4dXhHTFhZQU0": {"num_bytes": 196146693, "checksum": "9f4dd0a449885e1b5679cf79cd03f06f157190e53f4af4a325aa7bcc9381bee7"}}, "download_size": 196146693, "post_processing_size": null, "dataset_size": 521083022, "size_in_bytes": 717229715}}
1
+ {"yelp_review_full": {"description": "The Yelp reviews dataset consists of reviews from Yelp. It is extracted from the Yelp Dataset Challenge 2015 data.\nThe Yelp reviews full star dataset is constructed by Xiang Zhang (xiang.zhang@nyu.edu) from the above dataset.\nIt is first used as a text classification benchmark in the following paper: Xiang Zhang, Junbo Zhao, Yann LeCun.\nCharacter-level Convolutional Networks for Text Classification. Advances in Neural Information Processing Systems 28 (NIPS 2015).\n", "citation": "@inproceedings{zhang2015character,\n title={Character-level convolutional networks for text classification},\n author={Zhang, Xiang and Zhao, Junbo and LeCun, Yann},\n booktitle={Advances in neural information processing systems},\n pages={649--657},\n year={2015}\n}\n", "homepage": "https://www.yelp.com/dataset", "license": "https://s3-media3.fl.yelpcdn.com/assets/srv0/engineering_pages/bea5c1e92bf3/assets/vendor/yelp-dataset-agreement.pdf", "features": {"label": {"num_classes": 5, "names": ["1 star", "2 star", "3 stars", "4 stars", "5 stars"], "id": null, "_type": "ClassLabel"}, "text": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": [{"task": "text-classification", "text_column": "text", "label_column": "label"}], "builder_name": "yelp_review_full", "config_name": "yelp_review_full", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 483811554, "num_examples": 650000, "dataset_name": "yelp_review_full"}, "test": {"name": "test", "num_bytes": 37271188, "num_examples": 50000, "dataset_name": "yelp_review_full"}}, "download_checksums": {"https://s3.amazonaws.com/fast-ai-nlp/yelp_review_full_csv.tgz": {"num_bytes": 196146755, "checksum": "56006b0a17a370f1e366504b1f2c3e3754e4a3dda17d3e718a885c552869a559"}}, "download_size": 196146755, "post_processing_size": null, "dataset_size": 521082742, "size_in_bytes": 717229497}}
dummy/yelp_review_full/1.0.0/dummy_data.zip CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:65e877f1d4c2e54d9faf195168ab5dcdd2f7a8f7ee21987cbeccdb7c32b2fde1
3
- size 4946
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:63ceaf01c28d3e6e13130e75a5dbd9ea6517cc0ee803ed97a5b8b446f2f290ee
3
+ size 6088
yelp_review_full.py CHANGED
@@ -16,7 +16,6 @@
16
 
17
 
18
  import csv
19
- import os
20
 
21
  import datasets
22
  from datasets.tasks import TextClassification
@@ -44,7 +43,7 @@ _HOMEPAGE = "https://www.yelp.com/dataset"
44
  _LICENSE = "https://s3-media3.fl.yelpcdn.com/assets/srv0/engineering_pages/bea5c1e92bf3/assets/vendor/yelp-dataset-agreement.pdf"
45
 
46
  _URLs = {
47
- "yelp_review_full": "https://drive.google.com/uc?export=download&id=0Bz8a_Dbh9QhbZlU4dXhHTFhZQU0",
48
  }
49
 
50
 
@@ -99,28 +98,27 @@ class YelpReviewFull(datasets.GeneratorBasedBuilder):
99
  def _split_generators(self, dl_manager):
100
  """Returns SplitGenerators."""
101
  my_urls = _URLs[self.config.name]
102
- data_dir = dl_manager.download_and_extract(my_urls)
103
  return [
104
  datasets.SplitGenerator(
105
  name=datasets.Split.TRAIN,
106
- gen_kwargs={
107
- "filepath": os.path.join(data_dir, "yelp_review_full_csv", "train.csv"),
108
- "split": "train",
109
- },
110
  ),
111
  datasets.SplitGenerator(
112
  name=datasets.Split.TEST,
113
- gen_kwargs={"filepath": os.path.join(data_dir, "yelp_review_full_csv", "test.csv"), "split": "test"},
114
  ),
115
  ]
116
 
117
- def _generate_examples(self, filepath, split):
118
  """Yields examples."""
119
-
120
- with open(filepath, encoding="utf-8") as f:
121
- data = csv.reader(f, delimiter=",", quoting=csv.QUOTE_NONNUMERIC)
122
- for id_, row in enumerate(data):
123
- yield id_, {
124
- "text": row[1],
125
- "label": int(row[0]) - 1,
126
- }
 
 
16
 
17
 
18
  import csv
 
19
 
20
  import datasets
21
  from datasets.tasks import TextClassification
43
  _LICENSE = "https://s3-media3.fl.yelpcdn.com/assets/srv0/engineering_pages/bea5c1e92bf3/assets/vendor/yelp-dataset-agreement.pdf"
44
 
45
  _URLs = {
46
+ "yelp_review_full": "https://s3.amazonaws.com/fast-ai-nlp/yelp_review_full_csv.tgz",
47
  }
48
 
49
 
98
  def _split_generators(self, dl_manager):
99
  """Returns SplitGenerators."""
100
  my_urls = _URLs[self.config.name]
101
+ archive = dl_manager.download(my_urls)
102
  return [
103
  datasets.SplitGenerator(
104
  name=datasets.Split.TRAIN,
105
+ gen_kwargs={"filepath": "yelp_review_full_csv/train.csv", "files": dl_manager.iter_archive(archive)},
 
 
 
106
  ),
107
  datasets.SplitGenerator(
108
  name=datasets.Split.TEST,
109
+ gen_kwargs={"filepath": "yelp_review_full_csv/test.csv", "files": dl_manager.iter_archive(archive)},
110
  ),
111
  ]
112
 
113
+ def _generate_examples(self, filepath, files):
114
  """Yields examples."""
115
+ for path, f in files:
116
+ if path == filepath:
117
+ csvfile = (line.decode("utf-8") for line in f)
118
+ data = csv.reader(csvfile, delimiter=",", quoting=csv.QUOTE_NONNUMERIC)
119
+ for id_, row in enumerate(data):
120
+ yield id_, {
121
+ "text": row[1],
122
+ "label": int(row[0]) - 1,
123
+ }
124
+ break