lhoestq HF staff commited on
Commit
ff3a363
1 Parent(s): dae9318

Replace yahoo_answers_topics data url (#4023)

Browse files

* replace yahoo_answers_topics data url

* update dummy data

Commit from https://github.com/huggingface/datasets/commit/84f5681217714e856fac127f3b236ac3758da8dd

dataset_infos.json CHANGED
@@ -1 +1 @@
1
- {"yahoo_answers_topics": {"description": "\nYahoo! Answers Topic Classification is text classification dataset. The dataset is the Yahoo! Answers corpus as of 10/25/2007. The Yahoo! Answers topic classification dataset is constructed using 10 largest main categories. From all the answers and other meta-information, this dataset only used the best answer content and the main category information.\n", "citation": "", "homepage": "https://github.com/LC-John/Yahoo-Answers-Topic-Classification-Dataset", "license": "", "features": {"id": {"dtype": "int32", "id": null, "_type": "Value"}, "topic": {"num_classes": 10, "names": ["Society & Culture", "Science & Mathematics", "Health", "Education & Reference", "Computers & Internet", "Sports", "Business & Finance", "Entertainment & Music", "Family & Relationships", "Politics & Government"], "names_file": null, "id": null, "_type": "ClassLabel"}, "question_title": {"dtype": "string", "id": null, "_type": "Value"}, "question_content": {"dtype": "string", "id": null, "_type": "Value"}, "best_answer": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "builder_name": "yahoo_answers_topics", "config_name": "yahoo_answers_topics", "version": {"version_str": "1.0.0", "description": "", "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 760287375, "num_examples": 1400000, "dataset_name": "yahoo_answers_topics"}, "test": {"name": "test", "num_bytes": 32653934, "num_examples": 60000, "dataset_name": "yahoo_answers_topics"}}, "download_checksums": {"https://drive.google.com/uc?export=download&id=0Bz8a_Dbh9Qhbd2JNdDBsQUdocVU": {"num_bytes": 319476309, "checksum": "db51df05ca9f6652ef722e7168291a073c859b1ade3493b0ec74174ca0d777a0"}}, "download_size": 319476309, "post_processing_size": null, "dataset_size": 792941309, "size_in_bytes": 1112417618}}
 
1
+ {"yahoo_answers_topics": {"description": "\nYahoo! Answers Topic Classification is text classification dataset. The dataset is the Yahoo! Answers corpus as of 10/25/2007. The Yahoo! Answers topic classification dataset is constructed using 10 largest main categories. From all the answers and other meta-information, this dataset only used the best answer content and the main category information.\n", "citation": "", "homepage": "https://github.com/LC-John/Yahoo-Answers-Topic-Classification-Dataset", "license": "", "features": {"id": {"dtype": "int32", "id": null, "_type": "Value"}, "topic": {"num_classes": 10, "names": ["Society & Culture", "Science & Mathematics", "Health", "Education & Reference", "Computers & Internet", "Sports", "Business & Finance", "Entertainment & Music", "Family & Relationships", "Politics & Government"], "id": null, "_type": "ClassLabel"}, "question_title": {"dtype": "string", "id": null, "_type": "Value"}, "question_content": {"dtype": "string", "id": null, "_type": "Value"}, "best_answer": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "yahoo_answers_topics", "config_name": "yahoo_answers_topics", "version": {"version_str": "1.0.0", "description": "", "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 760460695, "num_examples": 1400000, "dataset_name": "yahoo_answers_topics"}, "test": {"name": "test", "num_bytes": 32661362, "num_examples": 60000, "dataset_name": "yahoo_answers_topics"}}, "download_checksums": {"https://s3.amazonaws.com/fast-ai-nlp/yahoo_answers_csv.tgz": {"num_bytes": 319476345, "checksum": "2d4277855faf8b35259009425fa8f7fe1888b5644b47165508942d000f4c96ae"}}, "download_size": 319476345, "post_processing_size": null, "dataset_size": 793122057, "size_in_bytes": 1112598402}}
dummy/yahoo_answers_topics/1.0.0/dummy_data.zip CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:7be3aa2e8f6603c76da91c675e4e80de5008483c7b4d4458febdf395c3df1bcc
3
- size 4437
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d8f0088fdaea629d5b61db618d9aeb38c574114205c7c951ba4dcab3c0727324
3
+ size 5544
yahoo_answers_topics.py CHANGED
@@ -16,7 +16,6 @@
16
 
17
 
18
  import csv
19
- import os
20
 
21
  import datasets
22
 
@@ -28,7 +27,7 @@ The Yahoo! Answers topic classification dataset is constructed using 10 largest
28
  From all the answers and other meta-information, this dataset only used the best answer content and the main category information.
29
  """
30
 
31
- _URL = "https://drive.google.com/uc?export=download&id=0Bz8a_Dbh9Qhbd2JNdDBsQUdocVU"
32
 
33
  _TOPICS = [
34
  "Society & Culture",
@@ -72,27 +71,35 @@ class YahooAnswersTopics(datasets.GeneratorBasedBuilder):
72
  )
73
 
74
  def _split_generators(self, dl_manager):
75
- data_dir = dl_manager.download_and_extract(_URL)
76
-
77
- # Extracting (un-taring) the training data
78
- data_dir = os.path.join(data_dir, "yahoo_answers_csv")
79
  return [
80
  datasets.SplitGenerator(
81
- name=datasets.Split.TRAIN, gen_kwargs={"filepath": os.path.join(data_dir, "train.csv")}
 
 
 
 
82
  ),
83
  datasets.SplitGenerator(
84
- name=datasets.Split.TEST, gen_kwargs={"filepath": os.path.join(data_dir, "test.csv")}
 
 
 
 
85
  ),
86
  ]
87
 
88
- def _generate_examples(self, filepath):
89
- with open(filepath, encoding="utf-8") as f:
90
- rows = csv.reader(f)
91
- for i, row in enumerate(rows):
92
- yield i, {
93
- "id": i,
94
- "topic": int(row[0]) - 1,
95
- "question_title": row[1],
96
- "question_content": row[2],
97
- "best_answer": row[3],
98
- }
 
 
 
 
16
 
17
 
18
  import csv
 
19
 
20
  import datasets
21
 
 
27
  From all the answers and other meta-information, this dataset only used the best answer content and the main category information.
28
  """
29
 
30
+ _URL = "https://s3.amazonaws.com/fast-ai-nlp/yahoo_answers_csv.tgz"
31
 
32
  _TOPICS = [
33
  "Society & Culture",
 
71
  )
72
 
73
  def _split_generators(self, dl_manager):
74
+ archive = dl_manager.download(_URL)
 
 
 
75
  return [
76
  datasets.SplitGenerator(
77
+ name=datasets.Split.TRAIN,
78
+ gen_kwargs={
79
+ "filepath": "yahoo_answers_csv/train.csv",
80
+ "files": dl_manager.iter_archive(archive),
81
+ },
82
  ),
83
  datasets.SplitGenerator(
84
+ name=datasets.Split.TEST,
85
+ gen_kwargs={
86
+ "filepath": "yahoo_answers_csv/test.csv",
87
+ "files": dl_manager.iter_archive(archive),
88
+ },
89
  ),
90
  ]
91
 
92
+ def _generate_examples(self, filepath, files):
93
+ for path, f in files:
94
+ if path == filepath:
95
+ lines = (line.decode("utf-8") for line in f)
96
+ rows = csv.reader(lines)
97
+ for i, row in enumerate(rows):
98
+ yield i, {
99
+ "id": i,
100
+ "topic": int(row[0]) - 1,
101
+ "question_title": row[1],
102
+ "question_content": row[2],
103
+ "best_answer": row[3],
104
+ }
105
+ break