|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""TODO: Add a description here.""" |
|
|
|
|
|
import csv |
|
import json |
|
import os |
|
|
|
import datasets |
|
|
|
|
|
_DESCRIPTION = """\ |
|
This is an alloy composition dataset |
|
""" |
|
|
|
_LICENSE = "MIT" |
|
|
|
|
|
_URL = "https://drive.google.com/uc?export=download&id=" |
|
_URLs = { |
|
'train': _URL+'1wAERHsEBvWvCgfiWjtodM_5lV2OPlapC', |
|
'test': _URL+'1TvC3R0gIjFNj2HWyvMZuuubv78vuZpSF', |
|
} |
|
|
|
class AlloyCompositionDataset(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, |
|
|
|
gen_kwargs={ |
|
"filepath": downloaded_data['train'] |
|
}, |
|
), |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TEST, |
|
|
|
gen_kwargs={ |
|
"filepath": downloaded_data['test'] |
|
}, |
|
), |
|
] |
|
|
|
def _generate_examples( |
|
self, filepath |
|
): |
|
|
|
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} |
|
|