Datasets:
File size: 7,378 Bytes
cb13d61 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# TO CREATE dataset_infos.json use: datasets-cli test PET --save_infos --all_configs
#
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import csv
import json
import os
import datasets
# Find for instance the citation on arxiv or on the dataset repo/website
_CITATION = """\
@article{DBLP:journals/corr/abs-2203-04860,
author = {Patrizio Bellan and
Han van der Aa and
Mauro Dragoni and
Chiara Ghidini and
Simone Paolo Ponzetto},
title = {{PET:} {A} new Dataset for Process Extraction from Natural Language
Text},
journal = {CoRR},
volume = {abs/2203.04860},
year = {2022},
url = {https://doi.org/10.48550/arXiv.2203.04860},
doi = {10.48550/arXiv.2203.04860},
eprinttype = {arXiv},
eprint = {2203.04860},
biburl = {https://dblp.org/rec/journals/corr/abs-2203-04860.bib}
}
"""
# You can copy an official description
_DESCRIPTION = """\
Abstract. Although there is a long tradition of work in NLP on extracting entities and relations from text, to date there exists little work on the acquisition of business processes from unstructured data such as textual corpora of process descriptions. With this work we aim at filling this gap and establishing the first steps towards bridging data-driven information extraction methodologies from Natural Language Processing and the model-based formalization that is aimed from Business Process Management. For this, we develop the first corpus of business process descriptions annotated with activities, gateways, actors and flow information. We present our new resource, including a detailed overview of the annotation schema and guidelines, as well as a variety of baselines to benchmark the difficulty and challenges of business process extraction from text.
"""
_HOMEPAGE = "https://pdi.fbk.eu/pet-dataset/"
_LICENSE = "MIT"
_URL = "https://pdi.fbk.eu/pet/PETHuggingFace/"
# _TRAINING_FILE = "train.json"
# _DEV_FILE = "dev.json"
_TEST_FILE = "test.json"
class PETConfig(datasets.BuilderConfig):
"""The PET Dataset."""
def __init__(self, **kwargs):
"""BuilderConfig for PET.
Args:
**kwargs: keyword arguments forwarded to super.
"""
super(PETConfig, self).__init__(**kwargs)
class PET(datasets.GeneratorBasedBuilder):
"""PET DATASET."""
BUILDER_CONFIGS = [
PETConfig(
name="PET", version=datasets.Version("1.0.0"), description="The PET Dataset"
),
]
def _info(self):
features = datasets.Features(
{
"document name": datasets.Value("string"),
"sentence-ID": datasets.Value("int8"),
"tokens": datasets.Sequence(datasets.Value("string")),
"ner-tags": datasets.Sequence(
datasets.features.ClassLabel(
names=[
"O",
"B-Actor",
"I-Actor",
"B-Activity",
"I-Activity",
"B-Activity Data",
"I-Activity Data",
"B-Further Specification",
"I-Further Specification",
"B-XOR Gateway",
"I-XOR Gateway",
"B-Condition Specification",
"I-Condition Specification",
"B-AND Gateway",
"I-AND Gateway",
]
)
),
}
)
return datasets.DatasetInfo(
# This is the description that will appear on the datasets page.
description=_DESCRIPTION,
# This defines the different columns of the dataset and their types
features=features, # Here we define them above because they are different between the two configurations
# If there's a common (input, target) tuple from the features, uncomment supervised_keys line below and
# specify them. They'll be used if as_supervised=True in builder.as_dataset.
# supervised_keys=("sentence", "label"),
# Homepage of the dataset for documentation
homepage=_HOMEPAGE,
# License for the dataset if available
license=_LICENSE,
# Citation for the dataset
citation=_CITATION,
)
def _split_generators(self, dl_manager):
urls_to_download = {
# "train": f"{_URL}{_TRAINING_FILE}",
# "dev": f"{_URL}{_DEV_FILE}",
"test": f"{_URL}{_TEST_FILE}",
}
downloaded_files = dl_manager.download_and_extract(urls_to_download)
return [
# datasets.SplitGenerator(
# name=datasets.Split.TRAIN,
# # These kwargs will be passed to _generate_examples
# gen_kwargs={
# "filepath": downloaded_files["train"],
# "split": "train",
# },
# ),
datasets.SplitGenerator(
name=datasets.Split.TEST,
# These kwargs will be passed to _generate_examples
gen_kwargs={
"filepath": downloaded_files["test"],
"split": "test"
},
),
#
# datasets.SplitGenerator(
# name=datasets.Split.VALIDATION,
# # These kwargs will be passed to _generate_examples
# gen_kwargs={
# "filepath": os.path.join(data_dir, "dev.jsonl"),
# "split": "dev",
# },
# ),
]
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
def _generate_examples(self, filepath, split):
# TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
with open(filepath, encoding="utf-8", mode='r') as f:
for key, row in enumerate(f):
row = json.loads(row)
yield key, {
"document name": row["document name"],
"sentence-ID": row["sentence-ID"],
"tokens": row["tokens"],
"ner-tags": row["ner-tags"]
}
|