File size: 3,299 Bytes
ca3a521 |
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 |
import datasets
import os
import json
_CITATION = """
"""
_DESCRIPTION = """
"""
names = ['genre', 'instrument', 'author', 'creator', 'composer', 'director', 'applies_to_jurisdiction', 'overrules', 'laws_applied', 'repealed_by', 'majority_opinion_by', 'plaintiff', 'defendant', 'movement', 'influenced_by', 'member_of_political_party', 'diplomatic_relation', 'position_held', 'basic_form_of_government', 'office_held_by_head_of_state', 'head_of_state', 'office_held_by_head_of_government', 'head_of_government', 'shares_border_with', 'continent', 'capital', 'capital_of', 'country', 'twinned_administrative_body', 'currency', 'central_bank', 'subsidiary', 'stock_exchange', 'industry', 'statement_describes', 'solved_by', 'programming_language', 'file_extension', 'number_of_processor_cores', 'operating_system', 'measured_physical_quantity', 'recommended_unit_of_measurement', 'atomic_number', 'electron_configuration', 'discoverer_or_inventor', 'time_of_discovery_or_invention', 'location_of_discovery', 'medical_condition_treated', 'drug_or_therapy_used_for_treatment', 'genetic_association', 'therapeutic_area', 'symptoms_and_signs', 'place_of_birth', 'place_of_death', 'subclass_of', 'official_language', 'position_played_on_team', 'member_of_sports_team', 'award_received', 'original_network', 'educated_at', 'named_after', 'original_language_of_film_or_TV_show', 'member_of', 'field_of_work', 'participating_team', 'occupation', 'has_part', 'manufacturer', 'developer', 'country_of_citizenship', 'language_of_work_or_name', 'located_in_the_administrative_territorial_entity', 'languages_spoken_written_or_signed', 'employer', 'record_label', 'location', 'work_location', 'religion', 'owned_by', 'native_language', 'instance_of', 'country_of_origin', 'headquarters_location', 'location_of_formation', 'part_of']
class Builder(datasets.GeneratorBasedBuilder):
VERSION = datasets.Version("1.0.0")
BUILDER_CONFIGS = [
datasets.BuilderConfig(name=name, version=datasets.Version("1.0.0"), description=_DESCRIPTION)
for name in names
]
def _info(self):
features = datasets.Features(
{
"question": datasets.Value("string"),
"references": datasets.Sequence(datasets.Value("string")),
}
)
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=features,
homepage="",
license="",
citation=_CITATION,
)
def _split_generators(self, dl_manager):
train_json = dl_manager.download(os.path.join(self.config.name, "train.jsonl"))
test_json = dl_manager.download(os.path.join(self.config.name, "test.jsonl"))
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN,
gen_kwargs={"path": train_json},
),
datasets.SplitGenerator(
name=datasets.Split.TEST,
gen_kwargs={"path": test_json},
),
]
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
def _generate_examples(self, path):
with open(path, encoding="utf-8") as f:
for key, row in enumerate(f):
yield key, json.loads(row)
|