File size: 5,105 Bytes
4f8d358 c51b050 4f8d358 c51b050 4f8d358 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# coding=utf-8
"""British Library EThos dataset"""
import csv
from datetime import datetime
import datasets
from datasets.features import Features
_CITATION = """\
@misc{british library_genre,
title={UK Doctoral Thesis Metadata from EThOS},
url={UK Doctoral Thesis Metadata from EThOS},
author={{British Library} and {Rosie, Heather}},
year={2021}}
"""
_DESCRIPTION = """\
The data in this collection comprises the bibliographic metadata for all UK doctoral theses listed in EThOS, the UK's national thesis service.
We estimate the data covers around 98% of all PhDs ever awarded by UK Higher Education institutions, dating back to 1787.
Thesis metadata from every PhD-awarding university in the UK is included.
"""
_HOMEPAGE = "https://doi.org/10.23636/rcm4-zk44"
_LICENSE = "CC BY 4.0 Attribution"
_URL = "https://bl.iro.bl.uk/downloads/05b31c0e-da22-4b9f-a17c-35880aa111f4?locale=en"
features = Features(
{
"Title": datasets.Value("string"),
"DOI": datasets.Value("string"),
"Author": datasets.Value("string"),
"Author ISNI": datasets.Value("string"),
"ORCID": datasets.Value("string"),
"Institution": datasets.Value("string"),
"Institution ISNI": datasets.Value("string"),
"Date": datasets.Value("timestamp[s]"),
"Qualification": datasets.Value("string"),
"Abstract": datasets.Value("string"),
"Subject Discipline": datasets.ClassLabel(
names=[
"Physical Sciences",
"Biological Sciences",
"Engineering & Technology",
"Mathematics & Statistics",
"Agriculture & Veterinary Sciences",
"Medicine & Health",
"Computer Science",
"Philosophy, Psychology & Religious Studies",
"Business & Administrative Studies",
"Education",
"Language & Literature",
"Social, Economic & Political Studies",
"Architecture, Building & Planning",
"History & Archaeology",
"Creative Arts & Design",
"Law",
"Sport & Recreation",
"Librarianship & Information Science",
"Music",
" ",
]
),
"Supervisor(s)": datasets.Value("string"),
"Funder(s)": datasets.Value("string"),
"EThOS URL": datasets.Value("string"),
"IR URL": datasets.Value("string"),
}
)
class Ethos(datasets.GeneratorBasedBuilder):
VERSION = datasets.Version("1.1.0")
BUILDER_CONFIGS = [
datasets.BuilderConfig(
name="all",
version=VERSION,
description="",
),
datasets.BuilderConfig(
"skip_empty_abstracts",
version=VERSION,
description="EThOs skipping entires with no abstract",
),
]
DEFAULT_CONFIG_NAME = "all"
def _info(self):
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=features,
supervised_keys=None,
homepage=_HOMEPAGE,
license=_LICENSE,
citation=_CITATION,
)
def _split_generators(self, dl_manager):
"""Returns SplitGenerators."""
data_file = dl_manager.download(_URL)
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN,
# These kwargs will be passed to _generate_examples
gen_kwargs={
"filepath": data_file,
},
),
]
def _generate_examples(self, filepath):
"""Yields examples as (key, example) tuples."""
if self.config.name == "skip_empty_abstracts":
skip = True
else:
skip = False
with open(filepath, encoding="latin-1") as f:
reader = csv.DictReader(f)
id_ = 0
for row in reader:
abstract = row["Abstract"]
if skip and len(abstract) < 2:
continue
try:
date = datetime.strptime(row["Date"], "%Y")
except ValueError:
date = None
id_ += 1
yield id_, {
"Title": row["Title"],
"DOI": row["DOI"],
"Author": row["Author"],
"Author ISNI": row["Author ISNI"],
"ORCID": row["ORCID"],
"Institution": row["Institution"],
"Institution ISNI": row["Institution ISNI"],
"Date": date,
"Qualification": row["Qualification"],
"Abstract": abstract,
"Subject Discipline": row["Subject Discipline"],
"Supervisor(s)": row["Supervisor(s)"],
"Funder(s)": row["Funder(s)"],
"EThOS URL": row["EThOS URL"],
"IR URL": row["IR URL"],
}
|