File size: 3,041 Bytes
268024e 30d4fcc 268024e 78e07ce 268024e |
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 |
# 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}
|