hmtkvs commited on
Commit
ed939ce
1 Parent(s): 5c301f8

upload files

Browse files
Files changed (6) hide show
  1. .gitattributes +3 -0
  2. config.yml +26 -0
  3. test.py +164 -0
  4. test_.json +3 -0
  5. train_.json +3 -0
  6. 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
config.yml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ dataset_name: test
2
+ desc: "
3
+ This new dataset is designed to be used in the scope of PhD project.
4
+ "
5
+ citation: "@InProceedings{phd,
6
+ title = {Open Subtitles Machine Translation Dataset},
7
+ author={hmtkvs, Inc.
8
+ },
9
+ year={2022}
10
+ }
11
+ "
12
+ homepage: ''
13
+ licence: ''
14
+ version: 1.1.0
15
+ data:
16
+ train: "train_.json"
17
+ validation: "validation_.json"
18
+ test: "test_.json"
19
+ features:
20
+ title: translation
21
+ col1: Spanish
22
+ col2: Italian
23
+
24
+
25
+
26
+
test.py ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_feat'])
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
+ # features = datasets.Features(
88
+ # {
89
+ # "Spanish": datasets.Value("string"),
90
+ # "Italian": datasets.Value("string")
91
+ # # These are the features of your dataset like images, labels ...
92
+ # }
93
+ # )
94
+
95
+ return datasets.DatasetInfo(
96
+ # This is the description that will appear on the datasets page.
97
+ description=_DESCRIPTION,
98
+ # This defines the different columns of the dataset and their types
99
+ features=features, # Here we define them above because they are different between the two configurations
100
+ # If there's a common (input, target) tuple from the features,
101
+ # specify them here. They'll be used if as_supervised=True in
102
+ # builder.as_dataset.
103
+ supervised_keys=None,
104
+ # Homepage of the dataset for documentation
105
+ homepage=_HOMEPAGE,
106
+ # License for the dataset if available
107
+ license=_LICENSE,
108
+ # Citation for the dataset
109
+ citation=_CITATION,
110
+ )
111
+
112
+ def _split_generators(self, dl_manager):
113
+ """Returns SplitGenerators."""
114
+ # TODO: This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
115
+ # If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
116
+
117
+ # dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLs
118
+ # 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.
119
+ # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
120
+ dl_path = dl_manager.download_and_extract(_URLs)
121
+
122
+ return [
123
+ datasets.SplitGenerator(
124
+ name=datasets.Split.TRAIN,
125
+ # These kwargs will be passed to _generate_examples
126
+ gen_kwargs={
127
+ "filepath": dl_path['train'],
128
+ "split": "train",
129
+ },
130
+ ),
131
+ datasets.SplitGenerator(
132
+ name=datasets.Split.TEST,
133
+ # These kwargs will be passed to _generate_examples
134
+ gen_kwargs={
135
+ "filepath": dl_path['test'],
136
+ "split": "test"
137
+ },
138
+ ),
139
+ datasets.SplitGenerator(
140
+ name=datasets.Split.VALIDATION,
141
+ # These kwargs will be passed to _generate_examples
142
+ gen_kwargs={
143
+ "filepath": dl_path['validation'],
144
+ "split": "validation",
145
+ },
146
+ ),
147
+ ]
148
+
149
+ def _generate_examples(
150
+ self, filepath, split # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
151
+ ):
152
+ """ Yields examples as (key, example) tuples. """
153
+ # This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
154
+ # The `key` is here for legacy reason (tfds) and is not important in itself.
155
+
156
+ with open(filepath, encoding="utf-8") as f:
157
+ for id_, line in enumerate(f):
158
+ data = json.loads(line)
159
+ yield id_, {
160
+ "translation":{"Spanish": data["Spanish"],
161
+ "Italian": data["Italian"]#"" if split == "test" else data["Italian"],
162
+ }
163
+ }
164
+ # '''
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