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