firsts
Browse files- .gitattributes +3 -0
- test2.py +165 -0
- test_.json +3 -0
- train_.json +3 -0
- validation_.json +3 -0
.gitattributes
CHANGED
@@ -25,3 +25,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
25 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
26 |
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
27 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
25 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
26 |
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
27 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
test_.json filter=lfs diff=lfs merge=lfs -text
|
29 |
+
train_.json filter=lfs diff=lfs merge=lfs -text
|
30 |
+
validation_.json filter=lfs diff=lfs merge=lfs -text
|
test2.py
ADDED
@@ -0,0 +1,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
import csv
|
18 |
+
import json
|
19 |
+
import os
|
20 |
+
import sys
|
21 |
+
|
22 |
+
import datasets
|
23 |
+
|
24 |
+
import yaml
|
25 |
+
|
26 |
+
with open("config.yml", "r") as ymlfile:
|
27 |
+
cfg = yaml.safe_load(ymlfile)
|
28 |
+
|
29 |
+
print('description : ', cfg['citation'])
|
30 |
+
|
31 |
+
|
32 |
+
# TODO: Add BibTeX citation
|
33 |
+
# Find for instance the citation on arxiv or on the dataset repo/website
|
34 |
+
_CITATION = cfg['citation']
|
35 |
+
|
36 |
+
# TODO: Add description of the dataset here
|
37 |
+
# You can copy an official description
|
38 |
+
_DESCRIPTION = cfg['desc']
|
39 |
+
|
40 |
+
# TODO: Add a link to an official homepage for the dataset here
|
41 |
+
_HOMEPAGE = cfg['homepage']
|
42 |
+
|
43 |
+
# TODO: Add the licence for the dataset here if you can find it
|
44 |
+
_LICENSE = cfg['licence']
|
45 |
+
|
46 |
+
# TODO: Add link to the official dataset URLs here
|
47 |
+
# The HuggingFace dataset library don't host the datasets but only point to the original files
|
48 |
+
# This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
|
49 |
+
# url = "https://drive.google.com/drive/folders/1Jvvddj0abp9rMAGhqXqpPbE8-Y28iyM3?usp=sharing"
|
50 |
+
_URLs = {
|
51 |
+
"train": cfg['data']['train'],#"train_.json",#"https://drive.google.com/uc?export=download&id=1-0r83eGwRfmfVAEtdyiregvneJ81ev1N",
|
52 |
+
"validation": cfg['data']['validation'],#"validation_.json",#"https://drive.google.com/uc?export=download&id=1-0zTW12OKIPrH3Zmad6tvSte7bA8O4RR",
|
53 |
+
"test": cfg['data']['test']#"test_.json"#"https://drive.google.com/uc?export=download&id=1-2U6BeDluJxIieMA6JTjLoij_KcMhl4Y"
|
54 |
+
}
|
55 |
+
|
56 |
+
# print(cfg['translation_fesat'])
|
57 |
+
|
58 |
+
|
59 |
+
|
60 |
+
# TODO: Name of the dataset usually match the script name with CamelCase instead of snake_case
|
61 |
+
class NewDataset(datasets.GeneratorBasedBuilder):
|
62 |
+
|
63 |
+
VERSION = datasets.Version(cfg['version'])
|
64 |
+
|
65 |
+
# This is an example of a dataset with multiple configurations.
|
66 |
+
# If you don't want/need to define several sub-sets in your dataset,
|
67 |
+
# just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
|
68 |
+
|
69 |
+
# If you need to make complex sub-parts in the datasets with configurable options
|
70 |
+
# You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
|
71 |
+
# BUILDER_CONFIG_CLASS = MyBuilderConfig
|
72 |
+
|
73 |
+
# You will be able to load one or the other configurations in the following list with
|
74 |
+
# data = datasets.load_dataset('my_dataset', 'first_domain')
|
75 |
+
# data = datasets.load_dataset('my_dataset', 'second_domain')
|
76 |
+
BUILDER_CONFIGS = [
|
77 |
+
datasets.BuilderConfig(name=cfg['dataset_name'], version=VERSION, description=cfg['desc'])
|
78 |
+
]
|
79 |
+
|
80 |
+
# DEFAULT_CONFIG_NAME = "opus_books_es_it" # It's not mandatory to have a default configuration. Just use one if it make sense.
|
81 |
+
|
82 |
+
def _info(self):
|
83 |
+
# TODO: This method specifies the datasets.DatasetInfo object which contains informations and typings for the dataset
|
84 |
+
# if self.config.name == "opus_books_es_it": # This is the name of the configuration selected in BUILDER_CONFIGS above
|
85 |
+
features=datasets.Features({"translation": datasets.features.Translation(languages=("Spanish", "Italian"))})
|
86 |
+
# features=datasets.Features({cfg["title"]: datasets.features.Translation(languages=(cfg["col1"], cfg{"col2"}))})
|
87 |
+
|
88 |
+
# features = datasets.Features(
|
89 |
+
# {
|
90 |
+
# "Spanish": datasets.Value("string"),
|
91 |
+
# "Italian": datasets.Value("string")
|
92 |
+
# # These are the features of your dataset like images, labels ...
|
93 |
+
# }
|
94 |
+
# )
|
95 |
+
|
96 |
+
return datasets.DatasetInfo(
|
97 |
+
# This is the description that will appear on the datasets page.
|
98 |
+
description=_DESCRIPTION,
|
99 |
+
# This defines the different columns of the dataset and their types
|
100 |
+
features=features, # Here we define them above because they are different between the two configurations
|
101 |
+
# If there's a common (input, target) tuple from the features,
|
102 |
+
# specify them here. They'll be used if as_supervised=True in
|
103 |
+
# builder.as_dataset.
|
104 |
+
supervised_keys=None,
|
105 |
+
# Homepage of the dataset for documentation
|
106 |
+
homepage=_HOMEPAGE,
|
107 |
+
# License for the dataset if available
|
108 |
+
license=_LICENSE,
|
109 |
+
# Citation for the dataset
|
110 |
+
citation=_CITATION,
|
111 |
+
)
|
112 |
+
|
113 |
+
def _split_generators(self, dl_manager):
|
114 |
+
"""Returns SplitGenerators."""
|
115 |
+
# TODO: This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
|
116 |
+
# If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
|
117 |
+
|
118 |
+
# dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLs
|
119 |
+
# It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
|
120 |
+
# By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
|
121 |
+
dl_path = dl_manager.download_and_extract(_URLs)
|
122 |
+
|
123 |
+
return [
|
124 |
+
datasets.SplitGenerator(
|
125 |
+
name=datasets.Split.TRAIN,
|
126 |
+
# These kwargs will be passed to _generate_examples
|
127 |
+
gen_kwargs={
|
128 |
+
"filepath": dl_path['train'],
|
129 |
+
"split": "train",
|
130 |
+
},
|
131 |
+
),
|
132 |
+
datasets.SplitGenerator(
|
133 |
+
name=datasets.Split.TEST,
|
134 |
+
# These kwargs will be passed to _generate_examples
|
135 |
+
gen_kwargs={
|
136 |
+
"filepath": dl_path['test'],
|
137 |
+
"split": "test"
|
138 |
+
},
|
139 |
+
),
|
140 |
+
datasets.SplitGenerator(
|
141 |
+
name=datasets.Split.VALIDATION,
|
142 |
+
# These kwargs will be passed to _generate_examples
|
143 |
+
gen_kwargs={
|
144 |
+
"filepath": dl_path['validation'],
|
145 |
+
"split": "validation",
|
146 |
+
},
|
147 |
+
),
|
148 |
+
]
|
149 |
+
|
150 |
+
def _generate_examples(
|
151 |
+
self, filepath, split # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
152 |
+
):
|
153 |
+
""" Yields examples as (key, example) tuples. """
|
154 |
+
# This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
|
155 |
+
# The `key` is here for legacy reason (tfds) and is not important in itself.
|
156 |
+
|
157 |
+
with open(filepath, encoding="utf-8") as f:
|
158 |
+
for id_, line in enumerate(f):
|
159 |
+
data = json.loads(line)
|
160 |
+
yield id_, {
|
161 |
+
"translation":{"Spanish": data["Spanish"],
|
162 |
+
"Italian": data["Italian"]#"" if split == "test" else data["Italian"],
|
163 |
+
}
|
164 |
+
}
|
165 |
+
# '''
|
test_.json
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4abb2db17421a4c3dbc3cfddba21d81dd2bc241a772eaa70bc89fcba6d6e728a
|
3 |
+
size 715403
|
train_.json
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4abb2db17421a4c3dbc3cfddba21d81dd2bc241a772eaa70bc89fcba6d6e728a
|
3 |
+
size 715403
|
validation_.json
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4abb2db17421a4c3dbc3cfddba21d81dd2bc241a772eaa70bc89fcba6d6e728a
|
3 |
+
size 715403
|