Datasets:
Commit
·
0867bca
1
Parent(s):
f26037b
Delete web_classification.py
Browse files- web_classification.py +0 -208
web_classification.py
DELETED
@@ -1,208 +0,0 @@
|
|
1 |
-
# Copyright 2022 The HuggingFace Datasets Authors and the current dataset script contributor.
|
2 |
-
#
|
3 |
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
-
# you may not use this file except in compliance with the License.
|
5 |
-
# You may obtain a copy of the License at
|
6 |
-
#
|
7 |
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8 |
-
#
|
9 |
-
# Unless required by applicable law or agreed to in writing, software
|
10 |
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11 |
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
-
# See the License for the specific language governing permissions and
|
13 |
-
# limitations under the License.
|
14 |
-
"""British Library Web Classification Dataset."""
|
15 |
-
|
16 |
-
import datasets
|
17 |
-
import csv
|
18 |
-
|
19 |
-
_CITATION = """\
|
20 |
-
TODO
|
21 |
-
"""
|
22 |
-
|
23 |
-
_DESCRIPTION = """\
|
24 |
-
The dataset comprises a manually curated selective archive produced by UKWA which includes the classification of sites into a two-tiered subject hierarchy.
|
25 |
-
"""
|
26 |
-
_HOMEPAGE = "https://doi.org/10.5259/ukwa.ds.1/classification/1"
|
27 |
-
|
28 |
-
_LICENSE = "https://creativecommons.org/publicdomain/zero/1.0/"
|
29 |
-
|
30 |
-
_URL = "https://bl.iro.bl.uk/downloads/78e2421a-70ea-426d-8a67-57e4a8b23019?locale=en"
|
31 |
-
|
32 |
-
|
33 |
-
class WebArchiveClassificationDataset(datasets.GeneratorBasedBuilder):
|
34 |
-
"""Web Archive Classification Dataset"""
|
35 |
-
|
36 |
-
VERSION = datasets.Version("1.1.0")
|
37 |
-
|
38 |
-
def _info(self):
|
39 |
-
features = datasets.Features(
|
40 |
-
{
|
41 |
-
"primary_category": datasets.ClassLabel(
|
42 |
-
names=[
|
43 |
-
"Arts & Humanities",
|
44 |
-
"Business, Economy & Industry",
|
45 |
-
"Company Web Sites",
|
46 |
-
"Computer Science, Information Technology and Web Technology",
|
47 |
-
"Crime, Criminology, Police and Prisons",
|
48 |
-
"Digital Society",
|
49 |
-
"Education & Research",
|
50 |
-
"Environment",
|
51 |
-
"Government, Law & Politics",
|
52 |
-
"History",
|
53 |
-
"Law and Legal System",
|
54 |
-
"Libraries, Archives and Museums",
|
55 |
-
"Life Sciences",
|
56 |
-
"Literature",
|
57 |
-
"Medicine & Health",
|
58 |
-
"Politics, Political Theory and Political Systems",
|
59 |
-
"Popular Science",
|
60 |
-
"Publishing, Printing and Bookselling",
|
61 |
-
"Religion",
|
62 |
-
"Science & Technology",
|
63 |
-
"Social Problems and Welfare",
|
64 |
-
"Society & Culture",
|
65 |
-
"Sports and Recreation",
|
66 |
-
"Travel & Tourism",
|
67 |
-
]
|
68 |
-
),
|
69 |
-
"secondary_category": datasets.ClassLabel(
|
70 |
-
names=[
|
71 |
-
"Architecture",
|
72 |
-
"Art and Design",
|
73 |
-
"Comedy and Humour",
|
74 |
-
"Dance",
|
75 |
-
"Family History / Genealogy",
|
76 |
-
"Film / Cinema",
|
77 |
-
"Geography",
|
78 |
-
"History",
|
79 |
-
"Languages",
|
80 |
-
"Literature",
|
81 |
-
"Live Art",
|
82 |
-
"Local History",
|
83 |
-
"Music",
|
84 |
-
"News and Contemporary Events",
|
85 |
-
"Oral History in the UK",
|
86 |
-
"Philosophy and Ethics",
|
87 |
-
"Publishing, Printing and Bookselling",
|
88 |
-
"Religion",
|
89 |
-
"TV and Radio",
|
90 |
-
"Theatre",
|
91 |
-
"Agriculture, Fishing, and Forestry",
|
92 |
-
"Banking, Insurance, Accountancy and Financial Economics",
|
93 |
-
"Business Studies and Management Theory",
|
94 |
-
"Company Web Sites",
|
95 |
-
"Credit Crunch",
|
96 |
-
"Economic Development, Enterprise and Aid",
|
97 |
-
"Economics and Economic Theory",
|
98 |
-
"Employment, Unemployment and Labour Economics",
|
99 |
-
"Energy",
|
100 |
-
"Industries",
|
101 |
-
"Marketing and Market Research",
|
102 |
-
"Trade, Commerce, and Globalisation",
|
103 |
-
"Transport and Infrastructure",
|
104 |
-
"Cambridge Network",
|
105 |
-
"Video Games",
|
106 |
-
"Governing the Police",
|
107 |
-
"Blogs",
|
108 |
-
"Dictionaries, Encyclopaedias, and Reference Works",
|
109 |
-
"Further Education",
|
110 |
-
"Higher Education",
|
111 |
-
"Libraries, Archives and Museums",
|
112 |
-
"Library Key Issues",
|
113 |
-
"Lifelong Learning",
|
114 |
-
"Preschool Education",
|
115 |
-
"School Education",
|
116 |
-
"Special Needs Education",
|
117 |
-
"Vocational Education",
|
118 |
-
"Indian Ocean Tsunami December 2004",
|
119 |
-
"Central Government",
|
120 |
-
"Civil Rights, Pressure Groups, and Trade Unions",
|
121 |
-
"Crime, Criminology, Police and Prisons",
|
122 |
-
"Devolved Government",
|
123 |
-
"European Parliament Elections 2009",
|
124 |
-
"Inter-Governmental Agencies",
|
125 |
-
"International Relations, Diplomacy, and Peace",
|
126 |
-
"Law and Legal System",
|
127 |
-
"Local Government",
|
128 |
-
"London Mayoral Election 2008",
|
129 |
-
"Political Parties",
|
130 |
-
"Politics, Political Theory and Political Systems",
|
131 |
-
"Public Inquiries",
|
132 |
-
"Scottish Parliamentary Election - 2007",
|
133 |
-
"Spending Cuts 2010: Impact on Social Welfare",
|
134 |
-
"UK General Election 2005",
|
135 |
-
"Slavery and Abolition in the Caribbean",
|
136 |
-
"Religion, politics and law since 2005",
|
137 |
-
"Evolving role of libraries in the UK",
|
138 |
-
"History of Libraries Collection",
|
139 |
-
"Darwin 200",
|
140 |
-
"19th Century English Literature",
|
141 |
-
"Alternative Medicine / Complementary Medicine",
|
142 |
-
"Conditions and Diseases",
|
143 |
-
"Health Organisations and Services",
|
144 |
-
"Medicines, Treatments and Therapies",
|
145 |
-
"Men's Issues",
|
146 |
-
"Mental Health",
|
147 |
-
"Pandemic Influenza",
|
148 |
-
"Personal Experiences of Illness",
|
149 |
-
"Public Health and Safety",
|
150 |
-
"Women's Issues",
|
151 |
-
"Political Action and Communication",
|
152 |
-
"E-publishing Trends",
|
153 |
-
"Free Church",
|
154 |
-
"Quakers",
|
155 |
-
"Computer Science, Information Technology and Web Technology",
|
156 |
-
"Engineering",
|
157 |
-
"Environment",
|
158 |
-
"Life Sciences",
|
159 |
-
"Mathematics",
|
160 |
-
"Physical Sciences",
|
161 |
-
"Popular Science",
|
162 |
-
"Zoology, Veterinary Science and Animal Health",
|
163 |
-
"Communities",
|
164 |
-
"Digital Society",
|
165 |
-
"Food and Drink",
|
166 |
-
"London Terrorist Attack 7th July 2005",
|
167 |
-
"Queen's Diamond Jubilee, 2012",
|
168 |
-
"Social Problems and Welfare",
|
169 |
-
"Sociology, Anthropology and Population Studies",
|
170 |
-
"Sports and Recreation",
|
171 |
-
"Travel & Tourism",
|
172 |
-
"British Countryside",
|
173 |
-
"Olympic & Paralympic Games 2012",
|
174 |
-
"Cornwall",
|
175 |
-
]
|
176 |
-
),
|
177 |
-
"title": datasets.Value("string"),
|
178 |
-
"url": datasets.Value("string"),
|
179 |
-
}
|
180 |
-
)
|
181 |
-
return datasets.DatasetInfo(
|
182 |
-
description=_DESCRIPTION,
|
183 |
-
features=features,
|
184 |
-
homepage=_HOMEPAGE,
|
185 |
-
license=_LICENSE,
|
186 |
-
citation=_CITATION,
|
187 |
-
)
|
188 |
-
|
189 |
-
def _split_generators(self, dl_manager):
|
190 |
-
|
191 |
-
csv_file = dl_manager.download_and_extract(_URL)
|
192 |
-
return [
|
193 |
-
datasets.SplitGenerator(
|
194 |
-
name=datasets.Split.TRAIN,
|
195 |
-
gen_kwargs={"csv_file": csv_file},
|
196 |
-
),
|
197 |
-
]
|
198 |
-
|
199 |
-
def _generate_examples(self, csv_file):
|
200 |
-
with open(csv_file) as f:
|
201 |
-
reader = csv.DictReader(f, dialect="excel-tab")
|
202 |
-
for id_, row in enumerate(reader):
|
203 |
-
yield id_, {
|
204 |
-
"primary_category": row["Primary Category"],
|
205 |
-
"secondary_category": row["Secondary Category"],
|
206 |
-
"title": row["Title"],
|
207 |
-
"url": row["URL"],
|
208 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|