王子傲
commited on
Commit
·
2b8bc83
1
Parent(s):
6c8c662
upload
Browse files- .gitattributes +5 -0
- dev_data.json +3 -0
- load_script.py +188 -0
- test_data.json +3 -0
- train_supervised_large.json +3 -0
- train_supervised_small.json +3 -0
- train_unsupervised.json +3 -0
.gitattributes
CHANGED
|
@@ -35,3 +35,8 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 35 |
*.mp3 filter=lfs diff=lfs merge=lfs -text
|
| 36 |
*.ogg filter=lfs diff=lfs merge=lfs -text
|
| 37 |
*.wav filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
*.mp3 filter=lfs diff=lfs merge=lfs -text
|
| 36 |
*.ogg filter=lfs diff=lfs merge=lfs -text
|
| 37 |
*.wav filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
train_supervised_small.json filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
train_unsupervised.json filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
dev_data.json filter=lfs diff=lfs merge=lfs -text
|
| 41 |
+
test_data.json filter=lfs diff=lfs merge=lfs -text
|
| 42 |
+
train_supervised_large.json filter=lfs diff=lfs merge=lfs -text
|
dev_data.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:58e8a702bababcdae4c0ccd4128c568a20fbe229ff18537cc5975919a7b85f71
|
| 3 |
+
size 2629742
|
load_script.py
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
# TODO: Address all TODOs and remove all explanatory comments
|
| 15 |
+
"""TODO: Add a description here."""
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
import csv
|
| 19 |
+
import json
|
| 20 |
+
import os
|
| 21 |
+
|
| 22 |
+
import datasets
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
# TODO: Add BibTeX citation
|
| 26 |
+
# Find for instance the citation on arxiv or on the dataset repo/website
|
| 27 |
+
_CITATION = """\
|
| 28 |
+
@InProceedings{huggingface:dataset,
|
| 29 |
+
title = {A great new dataset},
|
| 30 |
+
author={huggingface, Inc.
|
| 31 |
+
},
|
| 32 |
+
year={2020}
|
| 33 |
+
}
|
| 34 |
+
"""
|
| 35 |
+
|
| 36 |
+
# TODO: Add description of the dataset here
|
| 37 |
+
# You can copy an official description
|
| 38 |
+
_DESCRIPTION = """\
|
| 39 |
+
This new dataset is designed to solve this great NLP task and is crafted with a lot of care.
|
| 40 |
+
"""
|
| 41 |
+
|
| 42 |
+
# TODO: Add a link to an official homepage for the dataset here
|
| 43 |
+
_HOMEPAGE = ""
|
| 44 |
+
|
| 45 |
+
# TODO: Add the licence for the dataset here if you can find it
|
| 46 |
+
_LICENSE = ""
|
| 47 |
+
|
| 48 |
+
# TODO: Add link to the official dataset URLs here
|
| 49 |
+
# The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
|
| 50 |
+
# This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
|
| 51 |
+
_URLS = {
|
| 52 |
+
"supervised_large": "train_supervised_large.json",
|
| 53 |
+
"supervised_small": "train_supervised_small.json",
|
| 54 |
+
"unsupervised": "unsupervised.json",
|
| 55 |
+
"dev": "dev_data.json",
|
| 56 |
+
"test": "test_data.json"
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
# TODO: Name of the dataset usually match the script name with CamelCase instead of snake_case
|
| 61 |
+
class TimeTravel(datasets.GeneratorBasedBuilder):
|
| 62 |
+
"""TODO: Short description of my dataset."""
|
| 63 |
+
|
| 64 |
+
VERSION = datasets.Version("1.1.0")
|
| 65 |
+
|
| 66 |
+
# This is an example of a dataset with multiple configurations.
|
| 67 |
+
# If you don't want/need to define several sub-sets in your dataset,
|
| 68 |
+
# just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
|
| 69 |
+
|
| 70 |
+
# If you need to make complex sub-parts in the datasets with configurable options
|
| 71 |
+
# You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
|
| 72 |
+
# BUILDER_CONFIG_CLASS = MyBuilderConfig
|
| 73 |
+
|
| 74 |
+
# You will be able to load one or the other configurations in the following list with
|
| 75 |
+
# data = datasets.load_dataset('my_dataset', 'first_domain')
|
| 76 |
+
# data = datasets.load_dataset('my_dataset', 'second_domain')
|
| 77 |
+
BUILDER_CONFIGS = [
|
| 78 |
+
datasets.BuilderConfig(name="supervised_large", version=VERSION, description="Supervised data set large"),
|
| 79 |
+
datasets.BuilderConfig(name="supervised_small", version=VERSION, description="Supervised data set small"),
|
| 80 |
+
datasets.BuilderConfig(name="unsupervised", version=VERSION, description="Unsupervised dataset"),
|
| 81 |
+
]
|
| 82 |
+
|
| 83 |
+
DEFAULT_CONFIG_NAME = "unsupervised" # It's not mandatory to have a default configuration. Just use one if it make sense.
|
| 84 |
+
|
| 85 |
+
def _info(self):
|
| 86 |
+
# TODO: This method specifies the datasets.DatasetInfo object which contains informations and typings for the dataset
|
| 87 |
+
if self.config.name == "unsupervised": # This is the name of the configuration selected in BUILDER_CONFIGS above
|
| 88 |
+
features = datasets.Features(
|
| 89 |
+
{
|
| 90 |
+
"story_id": datasets.Value("string"),
|
| 91 |
+
"premise": datasets.Value("string"),
|
| 92 |
+
"initial": datasets.Value("string"),
|
| 93 |
+
"counterfactual": datasets.Value("string"),
|
| 94 |
+
"original_ending": datasets.Value("string"),
|
| 95 |
+
|
| 96 |
+
# These are the features of your dataset like images, labels ...
|
| 97 |
+
}
|
| 98 |
+
)
|
| 99 |
+
else: # This is an example to show how to have different features for "first_domain" and "second_domain"
|
| 100 |
+
features = datasets.Features(
|
| 101 |
+
{
|
| 102 |
+
"story_id": datasets.Value("string"),
|
| 103 |
+
"premise": datasets.Value("string"),
|
| 104 |
+
"initial": datasets.Value("string"),
|
| 105 |
+
"counterfactual": datasets.Value("string"),
|
| 106 |
+
"original_ending": datasets.Value("string"),
|
| 107 |
+
"edited_ending": datasets.Value("string")
|
| 108 |
+
# These are the features of your dataset like images, labels ...
|
| 109 |
+
}
|
| 110 |
+
)
|
| 111 |
+
return datasets.DatasetInfo(
|
| 112 |
+
# This is the description that will appear on the datasets page.
|
| 113 |
+
description=_DESCRIPTION,
|
| 114 |
+
# This defines the different columns of the dataset and their types
|
| 115 |
+
features=features, # Here we define them above because they are different between the two configurations
|
| 116 |
+
# If there's a common (input, target) tuple from the features, uncomment supervised_keys line below and
|
| 117 |
+
# specify them. They'll be used if as_supervised=True in builder.as_dataset.
|
| 118 |
+
# supervised_keys=("sentence", "label"),
|
| 119 |
+
# Homepage of the dataset for documentation
|
| 120 |
+
homepage=_HOMEPAGE,
|
| 121 |
+
# License for the dataset if available
|
| 122 |
+
license=_LICENSE,
|
| 123 |
+
# Citation for the dataset
|
| 124 |
+
citation=_CITATION,
|
| 125 |
+
)
|
| 126 |
+
|
| 127 |
+
def _split_generators(self, dl_manager):
|
| 128 |
+
# TODO: This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
|
| 129 |
+
# If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
|
| 130 |
+
|
| 131 |
+
# dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
|
| 132 |
+
# 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.
|
| 133 |
+
# By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
|
| 134 |
+
#urls = _URLS[self.config.name]
|
| 135 |
+
data_dir = dl_manager.download_and_extract(_URLS)
|
| 136 |
+
return [
|
| 137 |
+
datasets.SplitGenerator(
|
| 138 |
+
name=datasets.Split.TRAIN,
|
| 139 |
+
# These kwargs will be passed to _generate_examples
|
| 140 |
+
gen_kwargs={
|
| 141 |
+
"filepath": data_dir[self.config.name],
|
| 142 |
+
"split": "train",
|
| 143 |
+
},
|
| 144 |
+
),
|
| 145 |
+
datasets.SplitGenerator(
|
| 146 |
+
name=datasets.Split.TEST,
|
| 147 |
+
# These kwargs will be passed to _generate_examples
|
| 148 |
+
gen_kwargs={
|
| 149 |
+
"filepath": data_dir['test'],
|
| 150 |
+
"split": "test"
|
| 151 |
+
},
|
| 152 |
+
),
|
| 153 |
+
datasets.SplitGenerator(
|
| 154 |
+
name=datasets.Split.VALIDATION,
|
| 155 |
+
# These kwargs will be passed to _generate_examples
|
| 156 |
+
gen_kwargs={
|
| 157 |
+
"filepath": data_dir['dev'],
|
| 158 |
+
"split": "dev",
|
| 159 |
+
},
|
| 160 |
+
),
|
| 161 |
+
]
|
| 162 |
+
|
| 163 |
+
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
| 164 |
+
def _generate_examples(self, filepath, split):
|
| 165 |
+
# TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
|
| 166 |
+
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
|
| 167 |
+
with open(filepath, encoding="utf-8") as f:
|
| 168 |
+
for key, row in enumerate(f):
|
| 169 |
+
data = json.loads(row)
|
| 170 |
+
if self.config.name == "unsupervised":
|
| 171 |
+
# Yields examples as (key, example) tuples
|
| 172 |
+
yield key, {
|
| 173 |
+
"story_id": data["story_id"],
|
| 174 |
+
"premise": data["premise"],
|
| 175 |
+
"initial": data["initial"],
|
| 176 |
+
"counterfactual": data["counterfactual"],
|
| 177 |
+
"original_ending": data["original_ending"],
|
| 178 |
+
"edited_ending": data["edited_ending"] if split == "test" else "",
|
| 179 |
+
}
|
| 180 |
+
else:
|
| 181 |
+
yield key, {
|
| 182 |
+
"story_id": data["story_id"],
|
| 183 |
+
"premise": data["premise"],
|
| 184 |
+
"initial": data["initial"],
|
| 185 |
+
"counterfactual": data["counterfactual"],
|
| 186 |
+
"original_ending": data["original_ending"],
|
| 187 |
+
"edited_ending": data["edited_ending"],
|
| 188 |
+
}
|
test_data.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:926a0efc9513f46e9ac4e78e37194d5049cf0d247e4045680af8c93a33ff0803
|
| 3 |
+
size 2546672
|
train_supervised_large.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:42169edb01755b00fb16b3291fe749a3c258378786d0a5bbbfb7d63b1514fe88
|
| 3 |
+
size 16314889
|
train_supervised_small.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:63e2f26bbfb39dd56929c4c2683a71a0879c7abaabf00fd977e5d043ad400c44
|
| 3 |
+
size 9642013
|
train_unsupervised.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3a8683874caa036a45d2c756fbbd144e9c1df36fd596b36f0bbdc0c1699d3186
|
| 3 |
+
size 39102705
|