bipin commited on
Commit
268024e
1 Parent(s): dd8235a

added dataloader script

Browse files
Files changed (2) hide show
  1. README.md +0 -0
  2. alloy_composition_dataset.py +97 -0
README.md ADDED
File without changes
alloy_composition_dataset.py ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ """TODO: Add a description here."""
16
+
17
+
18
+ import csv
19
+ import json
20
+ import os
21
+
22
+ import datasets
23
+
24
+
25
+ _DESCRIPTION = """\
26
+ This is an alloy composition dataset
27
+ """
28
+
29
+ _LICENSE = "MIT"
30
+
31
+ # link to the dataset
32
+ _URL = "https://drive.google.com/uc?export=download&id="
33
+ _URLs = {
34
+ 'train': _URL+'1wAERHsEBvWvCgfiWjtodM_5lV2OPlapC',
35
+ 'test': _URL+'1TvC3R0gIjFNj2HWyvMZuuubv78vuZpSF',
36
+ }
37
+
38
+ class AlloyCompositionDataset(datasets.GeneratorBasedBuilder):
39
+ """TODO: Short description of my dataset."""
40
+
41
+ VERSION = datasets.Version("1.0.0")
42
+
43
+ BUILDER_CONFIGS = [
44
+ datasets.BuilderConfig(name="train", version=VERSION, description="Training split of the complete dataset"),
45
+ datasets.BuilderConfig(name="test", version=VERSION, description="Testing split of the complete dataset"),
46
+ ]
47
+
48
+ DEFAULT_CONFIG_NAME = "train"
49
+
50
+ def _info(self):
51
+ """Basic information about the dataset is specified here"""
52
+
53
+ features = datasets.Features(
54
+ {
55
+ "alloy_composition": datasets.Value("string")
56
+ }
57
+ )
58
+ return datasets.DatasetInfo(
59
+ description=_DESCRIPTION,
60
+ features=features,
61
+ supervised_keys=None,
62
+ homepage=_HOMEPAGE,
63
+ license=_LICENSE,
64
+ citation=_CITATION,
65
+ )
66
+
67
+ def _split_generators(self, dl_manager):
68
+ """Generates the training and testing split of the dataset"""
69
+
70
+ urls_to_download = _URLs
71
+ downloaded_data = dl_manager.download_and_extract(urls_to_download)
72
+ return [
73
+ datasets.SplitGenerator(
74
+ name=datasets.Split.TRAIN,
75
+ # These kwargs will be passed to _generate_examples
76
+ gen_kwargs={
77
+ "filepath": downloaded_data['train']
78
+ },
79
+ ),
80
+ datasets.SplitGenerator(
81
+ name=datasets.Split.TEST,
82
+ # These kwargs will be passed to _generate_examples
83
+ gen_kwargs={
84
+ "filepath": downloaded_data['test']
85
+ },
86
+ ),
87
+ ]
88
+
89
+ def _generate_examples(
90
+ self, filepath
91
+ ):
92
+ # Specify the format in which the data is to be returned
93
+ with open(filepath, encoding="utf-8") as f:
94
+ for i, line in enumerate(f.readlines()):
95
+ _id = i
96
+ row = ' '.join(w for w in line.strip().split(","))
97
+ yield _id, {"alloy_composition": row}