patriziobellan commited on
Commit
a185ae4
1 Parent(s): 2f33d7a

Delete PET.py

Browse files
Files changed (1) hide show
  1. PET.py +0 -220
PET.py DELETED
@@ -1,220 +0,0 @@
1
- # https://huggingface.co/docs/datasets/v1.2.1/add_dataset.html
2
- # TO login
3
- # TO CREATE dataset_infos.json use:
4
- # $ datasets-cli test PET --save_infos --all_configs
5
- #
6
- # DO
7
- # $ huggingface-cli login
8
- # then.
9
- # in pytohn:
10
- # dataset.push_to_hub(patriziobellan/PET) to set the preview on the web interface
11
- #
12
- # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
13
- #
14
- # Licensed under the Apache License, Version 2.0 (the "License");
15
- # you may not use this file except in compliance with the License.
16
- # You may obtain a copy of the License at
17
- #
18
- # http://www.apache.org/licenses/LICENSE-2.0
19
- #
20
- # Unless required by applicable law or agreed to in writing, software
21
- # distributed under the License is distributed on an "AS IS" BASIS,
22
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23
- # See the License for the specific language governing permissions and
24
- # limitations under the License.
25
-
26
- import csv
27
- import json
28
- import os
29
-
30
- import datasets
31
-
32
-
33
- # Find for instance the citation on arxiv or on the dataset repo/website
34
- _CITATION = """\
35
- @article{DBLP:journals/corr/abs-2203-04860,
36
- author = {Patrizio Bellan and
37
- Han van der Aa and
38
- Mauro Dragoni and
39
- Chiara Ghidini and
40
- Simone Paolo Ponzetto},
41
- title = {{PET:} {A} new Dataset for Process Extraction from Natural Language
42
- Text},
43
- journal = {CoRR},
44
- volume = {abs/2203.04860},
45
- year = {2022},
46
- url = {https://doi.org/10.48550/arXiv.2203.04860},
47
- doi = {10.48550/arXiv.2203.04860},
48
- eprinttype = {arXiv},
49
- eprint = {2203.04860},
50
- biburl = {https://dblp.org/rec/journals/corr/abs-2203-04860.bib}
51
- }
52
- """
53
-
54
- # You can copy an official description
55
- _DESCRIPTION = """\
56
- 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.
57
- """
58
-
59
- _HOMEPAGE = "https://pdi.fbk.eu/pet-dataset/"
60
-
61
- _LICENSE = "MIT"
62
-
63
- _URL = "https://pdi.fbk.eu/pet/PETHuggingFace/"
64
- # _TRAINING_FILE = "train.json"
65
- # _DEV_FILE = "dev.json"
66
- _TEST_FILE = "test.json"
67
- _TEST_FILE_RELATIONS = 'PETrelations.json'
68
-
69
- _NER = 'token-classification'
70
- _RELATIONS_EXTRACTION = 'relations-extraction'
71
- _NER_TAGS = [ "O",
72
- "B-Actor",
73
- "I-Actor",
74
- "B-Activity",
75
- "I-Activity",
76
- "B-Activity Data",
77
- "I-Activity Data",
78
- "B-Further Specification",
79
- "I-Further Specification",
80
- "B-XOR Gateway",
81
- "I-XOR Gateway",
82
- "B-Condition Specification",
83
- "I-Condition Specification",
84
- "B-AND Gateway",
85
- "I-AND Gateway"]
86
-
87
- _STR_PET = """\n
88
- _______ _ _ _______ _____ _______ _______ ______ _______ _______ _______ _______ _______ _______
89
- | |_____| |______ |_____] |______ | | \ |_____| | |_____| |______ |______ |
90
- | | | |______ | |______ | |_____/ | | | | | ______| |______ |
91
-
92
- \n\n\n
93
-
94
- Discover more at: [https://pdi.fbk.eu/pet-dataset/]
95
- """
96
-
97
-
98
- class PETConfig(datasets.BuilderConfig):
99
- """The PET Dataset."""
100
-
101
- def __init__(self, **kwargs):
102
- """BuilderConfig for PET.
103
- Args:
104
- **kwargs: keyword arguments forwarded to super.
105
- """
106
- super(PETConfig, self).__init__(**kwargs)
107
-
108
- class PET(datasets.GeneratorBasedBuilder):
109
- """PET DATASET."""
110
-
111
- features_ner = {
112
- "document name": datasets.Value("string"),
113
- "sentence-ID": datasets.Value("int8"),
114
- "tokens": datasets.Sequence(datasets.Value("string")),
115
- "ner-tags": datasets.Sequence(datasets.features.ClassLabel(names=_NER_TAGS)),
116
- }
117
-
118
- features_relations = datasets.Sequence(
119
- datasets.Features(
120
-
121
- {
122
- 'source-head-sentence-ID': datasets.Value("int8"),
123
- 'source-head-word-ID': datasets.Value("int8"),
124
- 'relation-type': datasets.Value("string"),
125
- 'target-head-sentence-ID': datasets.Value("int8"),
126
- 'target-head-word-ID' : datasets.Value("int8"),
127
- }
128
- ))
129
- BUILDER_CONFIGS = [ PETConfig(
130
- name=_NER,
131
- version=datasets.Version("1.0.1"),
132
- description="The PET Dataset for Token Classification"
133
- ),
134
- PETConfig(
135
- name=_RELATIONS_EXTRACTION,
136
- version=datasets.Version("1.0.1"),
137
- description="The PET Dataset for Relation Extraction"
138
- ),
139
- ]
140
-
141
- DEFAULT_CONFIG_NAME = _RELATIONS_EXTRACTION
142
-
143
- def _info(self):
144
- print(_STR_PET)
145
- if self.config.name == _NER:
146
- features = datasets.Features(self.features_ner)
147
- else:
148
- features = datasets.Features(
149
- {
150
- "document name": datasets.Value("string"),
151
- 'tokens':datasets.Sequence(datasets.Value("string")),
152
- 'tokens-IDs':datasets.Sequence(datasets.Value("int8")),
153
- 'ner_tags': datasets.Sequence(datasets.Value("string")),
154
- 'sentence-IDs':datasets.Sequence(datasets.Value("int8")),
155
- "relations": self.features_relations
156
- }
157
- )
158
- # print(features)
159
- return datasets.DatasetInfo(
160
- description=_DESCRIPTION,
161
- features=datasets.Features(features),
162
- homepage=_HOMEPAGE,
163
- license=_LICENSE,
164
- citation=_CITATION,
165
- )
166
-
167
- def _split_generators(self, dl_manager):
168
- if self.config.name == _NER:
169
- urls_to_download = {
170
- # "train": f"{_URL}{_TRAINING_FILE}",
171
- # "dev": f"{_URL}{_DEV_FILE}",
172
- "test": f"{_URL}{_TEST_FILE}",
173
- }
174
- downloaded_files = dl_manager.download_and_extract(urls_to_download)
175
- return [datasets.SplitGenerator(
176
- name=datasets.Split.TEST,
177
- # These kwargs will be passed to _generate_examples
178
- gen_kwargs={
179
- "filepath": downloaded_files["test"],
180
- "split": "test"
181
- },
182
- )]
183
- else:
184
- urls_to_download = {
185
- # "train": f"{_URL}{_TRAINING_FILE}",
186
- # "dev": f"{_URL}{_DEV_FILE}",
187
- "test": f"{_URL}{_TEST_FILE_RELATIONS}",
188
- }
189
- downloaded_files = dl_manager.download_and_extract(urls_to_download)
190
- return [datasets.SplitGenerator(
191
- name=datasets.Split.TEST,
192
- # These kwargs will be passed to _generate_examples
193
- gen_kwargs={
194
- "filepath": downloaded_files["test"],
195
- "split": "test"
196
- },
197
- )]
198
-
199
- def _generate_examples(self, filepath, split):
200
- if self.config.name == _NER:
201
- with open(filepath, encoding="utf-8", mode='r') as f:
202
- for key, row in enumerate(f):
203
- row = json.loads(row)
204
- yield key, {
205
- "document name": row["document name"],
206
- "sentence-ID": row["sentence-ID"],
207
- "tokens": row["tokens"],
208
- "ner-tags": row["ner-tags"]
209
- }
210
- else:
211
- with open(filepath, encoding="utf-8", mode='r') as f:
212
- for key, row in enumerate(json.load(f)):
213
- yield key, {"document name": row["document name"], # datasets.Value("string"),
214
- 'tokens': row["tokens"], # sentences['tokens'],
215
- 'tokens-IDs': row["tokens-IDs"],
216
- 'ner_tags': row["ner_tags"],
217
- 'sentence-IDs': row["sentence-IDs"], # sentences['sentence-IDs'],
218
-
219
- "relations": row["relations"]
220
- }