albertvillanova HF staff commited on
Commit
afe49ad
1 Parent(s): 8300bb2

Delete loading script

Browse files
Files changed (1) hide show
  1. yahoo_answers_topics.py +0 -105
yahoo_answers_topics.py DELETED
@@ -1,105 +0,0 @@
1
- # coding=utf-8
2
- # Copyright 2020 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
- """Yahoo! Answers Topic Classification Dataset"""
16
-
17
-
18
- import csv
19
-
20
- import datasets
21
-
22
-
23
- _DESCRIPTION = """
24
- Yahoo! Answers Topic Classification is text classification dataset. \
25
- The dataset is the Yahoo! Answers corpus as of 10/25/2007. \
26
- The Yahoo! Answers topic classification dataset is constructed using 10 largest main categories. \
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",
34
- "Science & Mathematics",
35
- "Health",
36
- "Education & Reference",
37
- "Computers & Internet",
38
- "Sports",
39
- "Business & Finance",
40
- "Entertainment & Music",
41
- "Family & Relationships",
42
- "Politics & Government",
43
- ]
44
-
45
-
46
- class YahooAnswersTopics(datasets.GeneratorBasedBuilder):
47
- "Yahoo! Answers Topic Classification Dataset"
48
-
49
- VERSION = datasets.Version("1.0.0")
50
- BUILDER_CONFIGS = [
51
- datasets.BuilderConfig(
52
- name="yahoo_answers_topics",
53
- version=datasets.Version("1.0.0", ""),
54
- ),
55
- ]
56
-
57
- def _info(self):
58
- return datasets.DatasetInfo(
59
- description=_DESCRIPTION,
60
- features=datasets.Features(
61
- {
62
- "id": datasets.Value("int32"),
63
- "topic": datasets.features.ClassLabel(names=_TOPICS),
64
- "question_title": datasets.Value("string"),
65
- "question_content": datasets.Value("string"),
66
- "best_answer": datasets.Value("string"),
67
- },
68
- ),
69
- supervised_keys=None,
70
- homepage="https://github.com/LC-John/Yahoo-Answers-Topic-Classification-Dataset",
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