Sebastian Gehrmann
commited on
Commit
·
1bfed91
1
Parent(s):
fe1f9e0
- Taskmaster.py +34 -33
Taskmaster.py
CHANGED
|
@@ -12,7 +12,7 @@
|
|
| 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 |
-
"""
|
| 16 |
|
| 17 |
|
| 18 |
import csv
|
|
@@ -36,12 +36,18 @@ _CITATION = """\
|
|
| 36 |
# TODO: Add description of the dataset here
|
| 37 |
# You can copy an official description
|
| 38 |
_DESCRIPTION = """\
|
| 39 |
-
The Taskmaster-3 (aka TicketTalk) dataset consists of 23,789 movie ticketing dialogs
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
"""
|
| 42 |
|
| 43 |
# TODO: Add a link to an official homepage for the dataset here
|
| 44 |
-
_HOMEPAGE =
|
|
|
|
|
|
|
| 45 |
|
| 46 |
# TODO: Add the licence for the dataset here if you can find it
|
| 47 |
_LICENSE = "CC BY 4.0"
|
|
@@ -73,7 +79,6 @@ class Taskmaster(datasets.GeneratorBasedBuilder):
|
|
| 73 |
|
| 74 |
VERSION = datasets.Version("3.0.0")
|
| 75 |
|
| 76 |
-
|
| 77 |
# If you need to make complex sub-parts in the datasets with configurable options
|
| 78 |
# You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
|
| 79 |
# BUILDER_CONFIG_CLASS = MyBuilderConfig
|
|
@@ -88,7 +93,7 @@ class Taskmaster(datasets.GeneratorBasedBuilder):
|
|
| 88 |
# datasets.TaskmasterConfig(name="test", version=VERSION, description="test set"),
|
| 89 |
# ]
|
| 90 |
|
| 91 |
-
#DEFAULT_CONFIG_NAME = "TaskmasterConfig" # It's not mandatory to have a default configuration. Just use one if it makes sense.
|
| 92 |
|
| 93 |
def _info(self):
|
| 94 |
# TODO: This method specifies the datasets.DatasetInfo object which contains informations and typings for the dataset
|
|
@@ -134,23 +139,22 @@ class Taskmaster(datasets.GeneratorBasedBuilder):
|
|
| 134 |
# dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLs
|
| 135 |
# 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.
|
| 136 |
# By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
|
| 137 |
-
#_URLs = { "train": "train.csv", "test": "test.csv", "validation": "dev.csv", }
|
| 138 |
-
my_urls = {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
data_dir = dl_manager.download_and_extract(my_urls)
|
| 140 |
-
challenge_sets = [
|
| 141 |
-
# ("challenge_%s_nov_%s" % (split,lvl),"%s-%s_nv2_%s.jsonl" % (split,self.config.name,lvl)) \
|
| 142 |
-
# for split in ["train","valid","test"] for lvl in ["low","mid","high"]
|
| 143 |
-
("challenge_%s_nov_%s" % (split,lvl),"%s-%s_nv2_%s.csv" % (split,self.config.name,lvl)) \
|
| 144 |
-
for split in ["train","valid","test"] for lvl in ["low","mid","high"]
|
| 145 |
-
]
|
| 146 |
-
# + ...
|
| 147 |
|
| 148 |
return [
|
| 149 |
datasets.SplitGenerator(
|
| 150 |
name=datasets.Split.TRAIN,
|
| 151 |
# These kwargs will be passed to _generate_examples
|
| 152 |
gen_kwargs={
|
| 153 |
-
"filepath": os.path.join(
|
|
|
|
|
|
|
| 154 |
"split": "train",
|
| 155 |
},
|
| 156 |
),
|
|
@@ -158,38 +162,35 @@ class Taskmaster(datasets.GeneratorBasedBuilder):
|
|
| 158 |
name=datasets.Split.TEST,
|
| 159 |
# These kwargs will be passed to _generate_examples
|
| 160 |
gen_kwargs={
|
| 161 |
-
"filepath": os.path.join(
|
| 162 |
-
|
|
|
|
|
|
|
| 163 |
},
|
| 164 |
),
|
| 165 |
datasets.SplitGenerator(
|
| 166 |
name=datasets.Split.VALIDATION,
|
| 167 |
# These kwargs will be passed to _generate_examples
|
| 168 |
gen_kwargs={
|
| 169 |
-
"filepath": os.path.join(
|
|
|
|
|
|
|
| 170 |
"split": "dev",
|
| 171 |
},
|
| 172 |
),
|
| 173 |
-
]
|
| 174 |
-
datasets.SplitGenerator(
|
| 175 |
-
name=challenge_split,
|
| 176 |
-
gen_kwargs={
|
| 177 |
-
"filepath": os.path.join(data_dir[challenge_split], filename),
|
| 178 |
-
"split": challenge_split,
|
| 179 |
-
},
|
| 180 |
-
)
|
| 181 |
-
for challenge_split, filename in challenge_sets
|
| 182 |
-
]
|
| 183 |
|
| 184 |
def _generate_examples(
|
| 185 |
-
self,
|
|
|
|
|
|
|
| 186 |
):
|
| 187 |
-
"""
|
| 188 |
# This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
|
| 189 |
# The `key` is here for legacy reason (tfds) and is not important in itself.
|
| 190 |
|
| 191 |
with open(filepath, encoding="utf-8") as f:
|
| 192 |
for row in f:
|
| 193 |
data = csv.loads(row)
|
| 194 |
-
data["gem_id"] = "GEM-TASKMASTER-%s-%d" % (split,data["id"]+1)
|
| 195 |
-
yield data["id"],data
|
|
|
|
| 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 |
+
"""A movie ticketing dialog dataset with 23,789 annotated conversations.."""
|
| 16 |
|
| 17 |
|
| 18 |
import csv
|
|
|
|
| 36 |
# TODO: Add description of the dataset here
|
| 37 |
# You can copy an official description
|
| 38 |
_DESCRIPTION = """\
|
| 39 |
+
The Taskmaster-3 (aka TicketTalk) dataset consists of 23,789 movie ticketing dialogs
|
| 40 |
+
(located in Taskmaster/TM-3-2020/data/). By "movie ticketing" we mean conversations
|
| 41 |
+
where the customer's goal is to purchase tickets after deciding on theater, time,
|
| 42 |
+
movie name, number of tickets, and date, or opt out of the transaction.
|
| 43 |
+
The columns are gem_id, 0, 1 for serial numbering, 2 for the text dialog and id
|
| 44 |
+
for the default id by the authors.
|
| 45 |
"""
|
| 46 |
|
| 47 |
# TODO: Add a link to an official homepage for the dataset here
|
| 48 |
+
_HOMEPAGE = (
|
| 49 |
+
"https://github.com/google-research-datasets/Taskmaster/tree/master/TM-3-2020"
|
| 50 |
+
)
|
| 51 |
|
| 52 |
# TODO: Add the licence for the dataset here if you can find it
|
| 53 |
_LICENSE = "CC BY 4.0"
|
|
|
|
| 79 |
|
| 80 |
VERSION = datasets.Version("3.0.0")
|
| 81 |
|
|
|
|
| 82 |
# If you need to make complex sub-parts in the datasets with configurable options
|
| 83 |
# You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
|
| 84 |
# BUILDER_CONFIG_CLASS = MyBuilderConfig
|
|
|
|
| 93 |
# datasets.TaskmasterConfig(name="test", version=VERSION, description="test set"),
|
| 94 |
# ]
|
| 95 |
|
| 96 |
+
# DEFAULT_CONFIG_NAME = "TaskmasterConfig" # It's not mandatory to have a default configuration. Just use one if it makes sense.
|
| 97 |
|
| 98 |
def _info(self):
|
| 99 |
# TODO: This method specifies the datasets.DatasetInfo object which contains informations and typings for the dataset
|
|
|
|
| 139 |
# dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLs
|
| 140 |
# 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.
|
| 141 |
# By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
|
| 142 |
+
# _URLs = { "train": "train.csv", "test": "test.csv", "validation": "dev.csv", }
|
| 143 |
+
my_urls = {
|
| 144 |
+
"train": "train.csv",
|
| 145 |
+
"test": "test.csv",
|
| 146 |
+
"validation": "dev.csv",
|
| 147 |
+
} # _URLs[self.config.name]
|
| 148 |
data_dir = dl_manager.download_and_extract(my_urls)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
|
| 150 |
return [
|
| 151 |
datasets.SplitGenerator(
|
| 152 |
name=datasets.Split.TRAIN,
|
| 153 |
# These kwargs will be passed to _generate_examples
|
| 154 |
gen_kwargs={
|
| 155 |
+
"filepath": os.path.join(
|
| 156 |
+
data_dir["train"], "train-%s.csv"
|
| 157 |
+
), # % (self.config.name)),
|
| 158 |
"split": "train",
|
| 159 |
},
|
| 160 |
),
|
|
|
|
| 162 |
name=datasets.Split.TEST,
|
| 163 |
# These kwargs will be passed to _generate_examples
|
| 164 |
gen_kwargs={
|
| 165 |
+
"filepath": os.path.join(
|
| 166 |
+
data_dir["test"], "test-%s.csv"
|
| 167 |
+
), # % (self.config.name)),
|
| 168 |
+
"split": "test",
|
| 169 |
},
|
| 170 |
),
|
| 171 |
datasets.SplitGenerator(
|
| 172 |
name=datasets.Split.VALIDATION,
|
| 173 |
# These kwargs will be passed to _generate_examples
|
| 174 |
gen_kwargs={
|
| 175 |
+
"filepath": os.path.join(
|
| 176 |
+
data_dir["validation"], "valid-%s.csv"
|
| 177 |
+
), # % (self.config.name)),
|
| 178 |
"split": "dev",
|
| 179 |
},
|
| 180 |
),
|
| 181 |
+
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
|
| 183 |
def _generate_examples(
|
| 184 |
+
self,
|
| 185 |
+
filepath,
|
| 186 |
+
split, # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
| 187 |
):
|
| 188 |
+
"""Yields examples as (key, example) tuples."""
|
| 189 |
# This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
|
| 190 |
# The `key` is here for legacy reason (tfds) and is not important in itself.
|
| 191 |
|
| 192 |
with open(filepath, encoding="utf-8") as f:
|
| 193 |
for row in f:
|
| 194 |
data = csv.loads(row)
|
| 195 |
+
data["gem_id"] = "GEM-TASKMASTER-%s-%d" % (split, data["id"] + 1)
|
| 196 |
+
yield data["id"], data
|