# coding=utf-8 # Copyright 2020 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. """TODO: Add a description here.""" import csv import json import os import datasets _DESCRIPTION = """\ This is an alloy composition dataset """ _LICENSE = "MIT" # link to the dataset _URL = "https://drive.google.com/uc?export=download&id=" _URLs = { 'train': _URL+'1wAERHsEBvWvCgfiWjtodM_5lV2OPlapC', 'test': _URL+'1TvC3R0gIjFNj2HWyvMZuuubv78vuZpSF', } class GlassAlloyComposition(datasets.GeneratorBasedBuilder): """TODO: Short description of my dataset.""" VERSION = datasets.Version("1.0.0") BUILDER_CONFIGS = [ datasets.BuilderConfig(name="train", version=VERSION, description="Training split of the complete dataset"), datasets.BuilderConfig(name="test", version=VERSION, description="Testing split of the complete dataset"), ] DEFAULT_CONFIG_NAME = "train" def _info(self): """Basic information about the dataset is specified here""" features = datasets.Features( { "alloy_composition": datasets.Value("string") } ) return datasets.DatasetInfo( description=_DESCRIPTION, features=features, supervised_keys=None, license=_LICENSE ) def _split_generators(self, dl_manager): """Generates the training and testing split of the dataset""" urls_to_download = _URLs downloaded_data = dl_manager.download_and_extract(urls_to_download) return [ datasets.SplitGenerator( name=datasets.Split.TRAIN, # These kwargs will be passed to _generate_examples gen_kwargs={ "filepath": downloaded_data['train'] }, ), datasets.SplitGenerator( name=datasets.Split.TEST, # These kwargs will be passed to _generate_examples gen_kwargs={ "filepath": downloaded_data['test'] }, ), ] def _generate_examples( self, filepath ): # Specify the format in which the data is to be returned with open(filepath, encoding="utf-8") as f: for i, line in enumerate(f.readlines()): _id = i row = ' '.join(w for w in line.strip().split(",")) yield _id, {"alloy_composition": row}