|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""Loading script for output_sample dataset, from the Historical American Buildings, Landscapes, and Engineering Records collection of the Library of Congress.""" |
|
|
|
|
|
import json |
|
import os |
|
|
|
import datasets |
|
|
|
|
|
|
|
|
|
_CITATION = """\ |
|
""" |
|
|
|
_DESCRIPTION = """\ |
|
Sample dataset scraped from https://www.loc.gov/collections/historic-american-buildings-landscapes-and-engineering-records/?c=150&at!=content,pages&fo=json |
|
The dataset contains images and metadata for historic buildings, landscapes, and engineering records. |
|
""" |
|
|
|
_HOMEPAGE = "https://www.loc.gov/collections/historic-american-buildings-landscapes-and-engineering-records" |
|
|
|
_LICENSE = "Creative Commons 1.0 Universal" |
|
|
|
|
|
|
|
|
|
|
|
_URLS = { |
|
"first_domain": "https://huggingface.co/great-new-dataset-first_domain.zip", |
|
"second_domain": "https://huggingface.co/great-new-dataset-second_domain.zip", |
|
} |
|
|
|
|
|
class HABLER_LOC(datasets.GeneratorBasedBuilder): |
|
"""Historical American Buildings, Landscapes, and Engineering Records dataset.""" |
|
|
|
VERSION = datasets.Version("1.1.0") |
|
|
|
def _info(self): |
|
|
|
features = datasets.Features( |
|
{ |
|
"call_number": datasets.Value("string"), |
|
"control_number": datasets.Value("string"), |
|
"created": datasets.Value("string"), |
|
"created_published": datasets.Value("string"), |
|
"created_published_date": datasets.Value("string"), |
|
"creators": datasets.Sequence(feature={"link": datasets.Value("string"), "role": datasets.Value("string"), "title": datasets.Value("string") }), |
|
"date": datasets.Value("string"), |
|
"display_offsite": datasets.Bool(), |
|
"id": datasets.Value("string"), |
|
"link": datasets.Value("string"), |
|
"medium_brief": datasets.Value("string"), |
|
"mediums": datasets.Sequence(datasets.Value("string")), |
|
"modified": datasets.Value("string"), |
|
"notes": datasets.Sequence(datasets.Value("string")), |
|
"part_of": datasets.Value("string"), |
|
"part_of_group": datasets.Value("string"), |
|
"place": datasets.Sequence(features={ |
|
"latitude": datasets.Value("string"), |
|
"link": datasets.Value("string"), |
|
"longitude": datasets.Value("string"), |
|
"title": datasets.Value("string")}), |
|
"repository": datasets.Value("string"), |
|
"resource_links": datasets.Sequence(datasets.Value("string")), |
|
"rights_advisory": datasets.Value("string"), |
|
"rights_information": datasets.Value("string"), |
|
"service_low": datasets.Value("string"), |
|
"service_medium": datasets.Value("string"), |
|
"source_created": datasets.Value("string"), |
|
"source_modified": datasets.Value("string"), |
|
"subject_headings": datasets.Sequence(datasets.Value("string")), |
|
"thumb_gallery": datasets.Value("string"), |
|
"title": datasets.Value("string") |
|
} |
|
) |
|
return datasets.DatasetInfo( |
|
|
|
description=_DESCRIPTION, |
|
|
|
features=features, |
|
|
|
|
|
|
|
|
|
homepage=_HOMEPAGE, |
|
|
|
license=_LICENSE, |
|
|
|
citation=_CITATION, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
|
|
|
|
|
|
|
|
|
|
|
|
urls = _URLS[self.config.name] |
|
data_dir = dl_manager.download_and_extract(urls) |
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TRAIN, |
|
|
|
gen_kwargs={ |
|
"filepath": os.path.join(data_dir, "train.jsonl"), |
|
"split": "train", |
|
}, |
|
), |
|
datasets.SplitGenerator( |
|
name=datasets.Split.VALIDATION, |
|
|
|
gen_kwargs={ |
|
"filepath": os.path.join(data_dir, "dev.jsonl"), |
|
"split": "dev", |
|
}, |
|
), |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TEST, |
|
|
|
gen_kwargs={ |
|
"filepath": os.path.join(data_dir, "test.jsonl"), |
|
"split": "test" |
|
}, |
|
), |
|
] |
|
|
|
|
|
def _generate_examples(self, filepath, split): |
|
|
|
|
|
with open(filepath, encoding="utf-8") as f: |
|
for key, row in enumerate(f): |
|
data = json.loads(row) |
|
if self.config.name == "first_domain": |
|
|
|
yield key, { |
|
"sentence": data["sentence"], |
|
"option1": data["option1"], |
|
"answer": "" if split == "test" else data["answer"], |
|
} |
|
else: |
|
yield key, { |
|
"sentence": data["sentence"], |
|
"option2": data["option2"], |
|
"second_domain_answer": "" if split == "test" else data["second_domain_answer"], |
|
} |