Datasets:
Download web_classification.py from TheBritishLibrary/web_archive_classification: direct link, hf CLI and curl.
- Browser
- Download file 9.24 kB
-
https://huggingface.co/datasets/TheBritishLibrary/web_archive_classification/resolve/03ea18f078e30d69486bbe40e7732bf424c6aa5a/web_classification.py
- Command line
-
hf download hf://datasets/TheBritishLibrary/web_archive_classification@03ea18f078e30d69486bbe40e7732bf424c6aa5a/web_classification.py
-
curl -L -o web_classification.py https://huggingface.co/datasets/TheBritishLibrary/web_archive_classification/resolve/03ea18f078e30d69486bbe40e7732bf424c6aa5a/web_classification.py
9.24 kB
| # Copyright 2022 The HuggingFace Datasets Authors and the current dataset script contributor. | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| """British Library Web Classification Dataset.""" | |
| import datasets | |
| import csv | |
| _CITATION = """\ | |
| TODO | |
| """ | |
| _DESCRIPTION = """\ | |
| The dataset comprises a manually curated selective archive produced by UKWA which includes the classification of sites into a two-tiered subject hierarchy. | |
| """ | |
| _HOMEPAGE = "https://doi.org/10.5259/ukwa.ds.1/classification/1" | |
| _LICENSE = "https://creativecommons.org/publicdomain/zero/1.0/" | |
| _URL = "https://bl.iro.bl.uk/downloads/78e2421a-70ea-426d-8a67-57e4a8b23019?locale=en" | |
| class WebArchiveClassificationDataset(datasets.GeneratorBasedBuilder): | |
| """Web Archive Classification Dataset""" | |
| VERSION = datasets.Version("1.1.0") | |
| def _info(self): | |
| features = datasets.Features( | |
| { | |
| "primary_category": datasets.ClassLabel( | |
| names=[ | |
| "Arts & Humanities", | |
| "Business, Economy & Industry", | |
| "Company Web Sites", | |
| "Computer Science, Information Technology and Web Technology", | |
| "Crime, Criminology, Police and Prisons", | |
| "Digital Society", | |
| "Education & Research", | |
| "Environment", | |
| "Government, Law & Politics", | |
| "History", | |
| "Law and Legal System", | |
| "Libraries, Archives and Museums", | |
| "Life Sciences", | |
| "Literature", | |
| "Medicine & Health", | |
| "Politics, Political Theory and Political Systems", | |
| "Popular Science", | |
| "Publishing, Printing and Bookselling", | |
| "Religion", | |
| "Science & Technology", | |
| "Social Problems and Welfare", | |
| "Society & Culture", | |
| "Sports and Recreation", | |
| "Travel & Tourism", | |
| ] | |
| ), | |
| "secondary_category": datasets.ClassLabel( | |
| names=[ | |
| "Architecture", | |
| "Art and Design", | |
| "Comedy and Humour", | |
| "Dance", | |
| "Family History / Genealogy", | |
| "Film / Cinema", | |
| "Geography", | |
| "History", | |
| "Languages", | |
| "Literature", | |
| "Live Art", | |
| "Local History", | |
| "Music", | |
| "News and Contemporary Events", | |
| "Oral History in the UK", | |
| "Philosophy and Ethics", | |
| "Publishing, Printing and Bookselling", | |
| "Religion", | |
| "TV and Radio", | |
| "Theatre", | |
| "Agriculture, Fishing, and Forestry", | |
| "Banking, Insurance, Accountancy and Financial Economics", | |
| "Business Studies and Management Theory", | |
| "Company Web Sites", | |
| "Credit Crunch", | |
| "Economic Development, Enterprise and Aid", | |
| "Economics and Economic Theory", | |
| "Employment, Unemployment and Labour Economics", | |
| "Energy", | |
| "Industries", | |
| "Marketing and Market Research", | |
| "Trade, Commerce, and Globalisation", | |
| "Transport and Infrastructure", | |
| "Cambridge Network", | |
| "Video Games", | |
| "Governing the Police", | |
| "Blogs", | |
| "Dictionaries, Encyclopaedias, and Reference Works", | |
| "Further Education", | |
| "Higher Education", | |
| "Libraries, Archives and Museums", | |
| "Library Key Issues", | |
| "Lifelong Learning", | |
| "Preschool Education", | |
| "School Education", | |
| "Special Needs Education", | |
| "Vocational Education", | |
| "Indian Ocean Tsunami December 2004", | |
| "Central Government", | |
| "Civil Rights, Pressure Groups, and Trade Unions", | |
| "Crime, Criminology, Police and Prisons", | |
| "Devolved Government", | |
| "European Parliament Elections 2009", | |
| "Inter-Governmental Agencies", | |
| "International Relations, Diplomacy, and Peace", | |
| "Law and Legal System", | |
| "Local Government", | |
| "London Mayoral Election 2008", | |
| "Political Parties", | |
| "Politics, Political Theory and Political Systems", | |
| "Public Inquiries", | |
| "Scottish Parliamentary Election - 2007", | |
| "Spending Cuts 2010: Impact on Social Welfare", | |
| "UK General Election 2005", | |
| "Slavery and Abolition in the Caribbean", | |
| "Religion, politics and law since 2005", | |
| "Evolving role of libraries in the UK", | |
| "History of Libraries Collection", | |
| "Darwin 200", | |
| "19th Century English Literature", | |
| "Alternative Medicine / Complementary Medicine", | |
| "Conditions and Diseases", | |
| "Health Organisations and Services", | |
| "Medicines, Treatments and Therapies", | |
| "Men's Issues", | |
| "Mental Health", | |
| "Pandemic Influenza", | |
| "Personal Experiences of Illness", | |
| "Public Health and Safety", | |
| "Women's Issues", | |
| "Political Action and Communication", | |
| "E-publishing Trends", | |
| "Free Church", | |
| "Quakers", | |
| "Computer Science, Information Technology and Web Technology", | |
| "Engineering", | |
| "Environment", | |
| "Life Sciences", | |
| "Mathematics", | |
| "Physical Sciences", | |
| "Popular Science", | |
| "Zoology, Veterinary Science and Animal Health", | |
| "Communities", | |
| "Digital Society", | |
| "Food and Drink", | |
| "London Terrorist Attack 7th July 2005", | |
| "Queen's Diamond Jubilee, 2012", | |
| "Social Problems and Welfare", | |
| "Sociology, Anthropology and Population Studies", | |
| "Sports and Recreation", | |
| "Travel & Tourism", | |
| "British Countryside", | |
| "Olympic & Paralympic Games 2012", | |
| "Cornwall", | |
| ] | |
| ), | |
| "title": datasets.Value("string"), | |
| "url": datasets.Value("string"), | |
| } | |
| ) | |
| return datasets.DatasetInfo( | |
| description=_DESCRIPTION, | |
| features=features, | |
| homepage=_HOMEPAGE, | |
| license=_LICENSE, | |
| citation=_CITATION, | |
| ) | |
| def _split_generators(self, dl_manager): | |
| csv_file = dl_manager.download_and_extract(_URL) | |
| return [ | |
| datasets.SplitGenerator( | |
| name=datasets.Split.TRAIN, | |
| gen_kwargs={"csv_file": csv_file}, | |
| ), | |
| ] | |
| def _generate_examples(self, csv_file): | |
| with open(csv_file) as f: | |
| reader = csv.DictReader(f, dialect="excel-tab") | |
| for id_, row in enumerate(reader): | |
| yield id_, { | |
| "primary_category": row["Primary Category"], | |
| "secondary_category": row["Secondary Category"], | |
| "title": row["Title"], | |
| "url": row["URL"], | |
| } | |