ebrigham commited on
Commit
e6eed70
·
1 Parent(s): d7738f1

Delete labels.py

Browse files
Files changed (1) hide show
  1. labels.py +0 -73
labels.py DELETED
@@ -1,73 +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
- _TRAIN_DOWNLOAD_URL = "https://drive.google.com/file/d/1Ehv1SSZ4n7ZLpUp7aSKNwHuC8UOgdfzL/view?usp=sharing"
19
- _TEST_DOWNLOAD_URL = "https://drive.google.com/file/d/1UWUuTEkK20Pz-H0rt78n91hHeVUhtCh1/view?usp=sharing"
20
-
21
-
22
- class AGNews(datasets.GeneratorBasedBuilder):
23
- """AG News topic classification dataset."""
24
-
25
- def _info(self):
26
- return datasets.DatasetInfo(
27
- description=_DESCRIPTION,
28
- features=datasets.Features(
29
- {
30
- "text": datasets.Value("string"),
31
- "label": datasets.features.ClassLabel(names=["World", "Sports", "Business", "Sci/Tech"]),
32
- }
33
- ),
34
- homepage="http://groups.di.unipi.it/~gulli/AG_corpus_of_news_articles.html",
35
- citation=_CITATION,
36
- task_templates=[TextClassification(text_column="text", label_column="label")],
37
- )
38
-
39
- def _split_generators(self, dl_manager):
40
- train_path = dl_manager.download_and_extract(_TRAIN_DOWNLOAD_URL)
41
- test_path = dl_manager.download_and_extract(_TEST_DOWNLOAD_URL)
42
- return [
43
- datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": train_path}),
44
- datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": test_path}),
45
- ]
46
-
47
- def _generate_examples(self, filepath):
48
- """Generate AG News examples."""
49
- with open(filepath, encoding="utf-8") as csv_file:
50
- csv_reader = csv.reader(
51
- csv_file, quotechar='"', delimiter=",", quoting=csv.QUOTE_ALL, skipinitialspace=True
52
- )
53
- for id_, row in enumerate(csv_reader):
54
- label, title, description = row
55
- # Original labels are [1, 2, 3, 4] ->
56
- # ['World', 'Sports', 'Business', 'Sci/Tech']
57
- # Re-map to [0, 1, 2, 3].
58
- label = int(label) - 1
59
- text = " ".join((title, description))
60
- yield id_, {"text": text, "label": label}
61
-
62
-
63
- def _generate_examples(self, filepath):
64
- with open(filepath, encoding="utf-8") as f:
65
- rows = csv.reader(f)
66
- for i, row in enumerate(rows):
67
- yield i, {
68
- "id": i,
69
- "topic": int(row[0]) - 1,
70
- "question_title": row[1],
71
- "question_content": row[2],
72
- "best_answer": row[3],
73
- }