Datasets:

Sub-tasks:
rdf-to-text
Multilinguality:
multilingual
Size Categories:
10K<n<100K
Language Creators:
crowdsourced
Annotations Creators:
found
Tags:
License:
albertvillanova HF staff commited on
Commit
0211ace
1 Parent(s): 10fd5ea
Files changed (3) hide show
  1. README.md +466 -0
  2. challenge-2023.py +175 -0
  3. data.zip +3 -0
README.md ADDED
@@ -0,0 +1,466 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ annotations_creators:
3
+ - found
4
+ language_creators:
5
+ - crowdsourced
6
+ language:
7
+ - br
8
+ - cy
9
+ - ga
10
+ - mt
11
+ - ru
12
+ license:
13
+ - cc-by-sa-3.0
14
+ - cc-by-nc-sa-4.0
15
+ - gfdl
16
+ multilinguality:
17
+ - multilingual
18
+ size_categories:
19
+ - 10K<n<100K
20
+ source_datasets:
21
+ - extended|other-db_pedia
22
+ - original
23
+ task_categories:
24
+ - tabular-to-text
25
+ task_ids:
26
+ - rdf-to-text
27
+ paperswithcode_id: null
28
+ pretty_name: WebNLG 2023 challenge
29
+ dataset_info:
30
+ - config_name: br
31
+ features:
32
+ - name: category
33
+ dtype: string
34
+ - name: size
35
+ dtype: int32
36
+ - name: eid
37
+ dtype: string
38
+ - name: original_triple_sets
39
+ sequence:
40
+ - name: otriple_set
41
+ sequence: string
42
+ - name: modified_triple_sets
43
+ sequence:
44
+ - name: mtriple_set
45
+ sequence: string
46
+ - name: shape
47
+ dtype: string
48
+ - name: shape_type
49
+ dtype: string
50
+ - name: lex
51
+ sequence:
52
+ - name: comment
53
+ dtype: string
54
+ - name: lid
55
+ dtype: string
56
+ - name: text
57
+ dtype: string
58
+ - name: lang
59
+ dtype: string
60
+ splits:
61
+ - name: train
62
+ num_bytes: 14841422
63
+ num_examples: 13211
64
+ - name: validation
65
+ num_bytes: 1394620
66
+ num_examples: 1399
67
+ download_size: 10954332
68
+ dataset_size: 16236042
69
+ - config_name: cy
70
+ features:
71
+ - name: category
72
+ dtype: string
73
+ - name: size
74
+ dtype: int32
75
+ - name: eid
76
+ dtype: string
77
+ - name: original_triple_sets
78
+ sequence:
79
+ - name: otriple_set
80
+ sequence: string
81
+ - name: modified_triple_sets
82
+ sequence:
83
+ - name: mtriple_set
84
+ sequence: string
85
+ - name: shape
86
+ dtype: string
87
+ - name: shape_type
88
+ dtype: string
89
+ - name: lex
90
+ sequence:
91
+ - name: comment
92
+ dtype: string
93
+ - name: lid
94
+ dtype: string
95
+ - name: text
96
+ dtype: string
97
+ - name: lang
98
+ dtype: string
99
+ splits:
100
+ - name: train
101
+ num_bytes: 15070109
102
+ num_examples: 13211
103
+ - name: validation
104
+ num_bytes: 1605315
105
+ num_examples: 1665
106
+ download_size: 10954332
107
+ dataset_size: 16675424
108
+ - config_name: ga
109
+ features:
110
+ - name: category
111
+ dtype: string
112
+ - name: size
113
+ dtype: int32
114
+ - name: eid
115
+ dtype: string
116
+ - name: original_triple_sets
117
+ sequence:
118
+ - name: otriple_set
119
+ sequence: string
120
+ - name: modified_triple_sets
121
+ sequence:
122
+ - name: mtriple_set
123
+ sequence: string
124
+ - name: shape
125
+ dtype: string
126
+ - name: shape_type
127
+ dtype: string
128
+ - name: lex
129
+ sequence:
130
+ - name: comment
131
+ dtype: string
132
+ - name: lid
133
+ dtype: string
134
+ - name: text
135
+ dtype: string
136
+ - name: lang
137
+ dtype: string
138
+ splits:
139
+ - name: train
140
+ num_bytes: 15219249
141
+ num_examples: 13211
142
+ - name: validation
143
+ num_bytes: 1621527
144
+ num_examples: 1665
145
+ download_size: 10954332
146
+ dataset_size: 16840776
147
+ - config_name: mt
148
+ features:
149
+ - name: category
150
+ dtype: string
151
+ - name: size
152
+ dtype: int32
153
+ - name: eid
154
+ dtype: string
155
+ - name: original_triple_sets
156
+ sequence:
157
+ - name: otriple_set
158
+ sequence: string
159
+ - name: modified_triple_sets
160
+ sequence:
161
+ - name: mtriple_set
162
+ sequence: string
163
+ - name: shape
164
+ dtype: string
165
+ - name: shape_type
166
+ dtype: string
167
+ - name: lex
168
+ sequence:
169
+ - name: comment
170
+ dtype: string
171
+ - name: lid
172
+ dtype: string
173
+ - name: text
174
+ dtype: string
175
+ - name: lang
176
+ dtype: string
177
+ splits:
178
+ - name: train
179
+ num_bytes: 15281045
180
+ num_examples: 13211
181
+ - name: validation
182
+ num_bytes: 1611988
183
+ num_examples: 1665
184
+ download_size: 10954332
185
+ dataset_size: 16893033
186
+ - config_name: ru
187
+ features:
188
+ - name: category
189
+ dtype: string
190
+ - name: size
191
+ dtype: int32
192
+ - name: eid
193
+ dtype: string
194
+ - name: original_triple_sets
195
+ sequence:
196
+ - name: otriple_set
197
+ sequence: string
198
+ - name: modified_triple_sets
199
+ sequence:
200
+ - name: mtriple_set
201
+ sequence: string
202
+ - name: shape
203
+ dtype: string
204
+ - name: shape_type
205
+ dtype: string
206
+ - name: lex
207
+ sequence:
208
+ - name: comment
209
+ dtype: string
210
+ - name: lid
211
+ dtype: string
212
+ - name: text
213
+ dtype: string
214
+ - name: lang
215
+ dtype: string
216
+ splits:
217
+ - name: train
218
+ num_bytes: 8145815
219
+ num_examples: 5573
220
+ - name: validation
221
+ num_bytes: 1122090
222
+ num_examples: 790
223
+ download_size: 10954332
224
+ dataset_size: 9267905
225
+ ---
226
+
227
+ # Dataset Card for WebNLG
228
+
229
+ ## Table of Contents
230
+ - [Dataset Description](#dataset-description)
231
+ - [Dataset Summary](#dataset-summary)
232
+ - [Supported Tasks and Leaderboards](#supported-tasks-and-leaderboards)
233
+ - [Languages](#languages)
234
+ - [Dataset Structure](#dataset-structure)
235
+ - [Data Instances](#data-instances)
236
+ - [Data Fields](#data-fields)
237
+ - [Data Splits](#data-splits)
238
+ - [Dataset Creation](#dataset-creation)
239
+ - [Curation Rationale](#curation-rationale)
240
+ - [Source Data](#source-data)
241
+ - [Annotations](#annotations)
242
+ - [Personal and Sensitive Information](#personal-and-sensitive-information)
243
+ - [Considerations for Using the Data](#considerations-for-using-the-data)
244
+ - [Social Impact of Dataset](#social-impact-of-dataset)
245
+ - [Discussion of Biases](#discussion-of-biases)
246
+ - [Other Known Limitations](#other-known-limitations)
247
+ - [Additional Information](#additional-information)
248
+ - [Dataset Curators](#dataset-curators)
249
+ - [Licensing Information](#licensing-information)
250
+ - [Citation Information](#citation-information)
251
+ - [Contributions](#contributions)
252
+
253
+ ## Dataset Description
254
+
255
+ - **Homepage:** [WebNLG 2023 challenge](https://synalp.gitlabpages.inria.fr/webnlg-challenge/challenge_2023/)
256
+ - **Repository:** [GitHub repository](https://github.com/WebNLG/2023-Challenge)
257
+ - **Paper:**
258
+ - **Leaderboard:**
259
+ - **Point of Contact:** [webnlg-challenge@inria.fr](mailto:webnlg-challenge@inria.fr)
260
+
261
+ ### Dataset Summary
262
+
263
+ The WebNLG 2023 challenge focuses on four under-resourced languages which are severely under-represented in research on
264
+ text generation, namely Maltese, Irish, Breton and Welsh. In addition, WebNLG 2023 once again includes Russian, which
265
+ was first featured in WebNLG 2020.
266
+
267
+ The challenge focuses on RDF-to-text generation, similarly to WebNLG 2017 but targeting Breton, Irish, Maltese, Welsh,
268
+ and Russian;
269
+
270
+ The challenge consists in mapping data to text. The training data consists of Data/Text pairs where the data is a set of
271
+ triples extracted from DBpedia and the text is a verbalisation of these triples.
272
+
273
+ For instance, given the 4 RDF triples:
274
+ ```
275
+ <entry category="Company" eid="Id21" shape="(X (X) (X) (X) (X))" shape_type="sibling" size="4">
276
+ <modifiedtripleset>
277
+ <mtriple>Trane | foundingDate | 1913-01-01</mtriple>
278
+ <mtriple>Trane | location | Ireland</mtriple>
279
+ <mtriple>Trane | foundationPlace | La_Crosse,_Wisconsin</mtriple>
280
+ <mtriple>Trane | numberOfEmployees | 29000</mtriple>
281
+ </modifiedtripleset>
282
+ </entry>
283
+ ```
284
+ the aim is to generate a text such as (English text):
285
+ ```
286
+ Trane, which was founded on January 1st 1913 in La Crosse, Wisconsin, is based in Ireland. It has 29,000 employees.
287
+ ```
288
+ or (Russian text):
289
+ ```
290
+ Компания "Тране", основанная 1 января 1913 года в Ла-Кроссе в штате Висконсин, находится в Ирландии. В компании работают 29 тысяч человек.
291
+ ```
292
+
293
+ As the example illustrates, the task involves specific NLG subtasks such as sentence segmentation
294
+ (how to chunk the input data into sentences), lexicalisation (of the DBpedia properties),
295
+ aggregation (how to avoid repetitions) and surface realisation
296
+ (how to build a syntactically correct and natural sounding text).
297
+
298
+ ### Supported Tasks and Leaderboards
299
+
300
+ The dataset supports a Structured to Text task which requires a model takes a set of RDF (Resource Description Format)
301
+ triples from a database (DBpedia) of the form (subject, property, object) as input and write out a natural language
302
+ sentence expressing the information contained in the triples.
303
+
304
+ The dataset is used in the [WebNLG 2023](https://synalp.gitlabpages.inria.fr/webnlg-challenge/challenge_2023/)
305
+ challenge.
306
+
307
+ Results are evaluated with automatic metrics: [BLEU](https://huggingface.co/metrics/bleu),
308
+ [METEOR](https://huggingface.co/metrics/meteor), [ChrF++](https://huggingface.co/metrics/chrf),
309
+ [TER](https://huggingface.co/metrics/ter) and [BERTscore](https://huggingface.co/metrics/bertscore).
310
+ Additionally, result are assessed according to criteria such as grammaticality/correctness, appropriateness/adequacy,
311
+ fluency/naturalness, etc., by native speakers.
312
+
313
+ ### Languages
314
+
315
+ The dataset comprises Breton (`br`), Welsh (`cy`), Irish (`ga`), Maltese (`mt`) and Russian (`ru`) languages.
316
+
317
+ ## Dataset Structure
318
+
319
+ ### Data Instances
320
+
321
+ A typical example contains the original RDF triples in the set, a modified version which presented to crowd workers,
322
+ and a set of possible verbalizations for this set of triples:
323
+ ```
324
+ {'category': 'Airport',
325
+ 'size': 1,
326
+ 'eid': '1',
327
+ 'original_triple_sets': {'otriple_set': [['Aarhus_Airport | cityServed | "Aarhus, Denmark"@en']]},
328
+ 'modified_triple_sets': {'mtriple_set': [['Aarhus_Airport | cityServed | "Aarhus, Denmark"']]},
329
+ 'shape': '(X (X))',
330
+ 'shape_type': 'NA',
331
+ 'lex': {'comment': ['good', 'good', '', ''],
332
+ 'lid': ['Id1', 'Id2', 'Id3', 'Id3'],
333
+ 'text': ['Aarhus a zo an aro-vezh Aarhus.',
334
+ "Aarhus a servijit ar c'hêr Aarhus.",
335
+ 'The Aarhus is the airport of Aarhus, Denmark.',
336
+ 'Aarhus Airport serves the city of Aarhus, Denmark.'],
337
+ 'lang': ['br', 'br', 'en', 'en']}}
338
+ ```
339
+
340
+ ### Data Fields
341
+
342
+ The following fields can be found in the instances:
343
+ - `category`: the category of the DBpedia entities present in the RDF triples.
344
+ - `eid`: an example ID, only unique per split per category.
345
+ - `size`: number of RDF triples in the set.
346
+ - `shape`: (since v2) Each set of RDF-triples is a tree, which is characterised by its shape and shape type. `shape` is a string representation of the tree with nested parentheses where X is a node (see [Newick tree format](https://en.wikipedia.org/wiki/Newick_format))
347
+ - `shape_type`: (since v2) is a type of the tree shape, which can be: `chain` (the object of one triple is the subject of the other); `sibling` (triples with a shared subject); `mixed` (both chain and sibling types present).
348
+ - `test_category`: (for `webnlg_challenge_2017` and `v3`) tells whether the set of RDF triples was present in the training set or not. Several splits of the test set are available: with and without references, and for RDF-to-text generation / for semantic parsing.
349
+ - `lex`: the lexicalizations, with:
350
+ - `text`: the text to be predicted.
351
+ - `lid`: a lexicalization ID, unique per example.
352
+ - `comment`: the lexicalizations were rated by crowd workers are either `good` or `bad`
353
+ - `lang`: (for `release_v3.0_ru`) the language used because original English texts were kept in the Russian version.
354
+
355
+ ### Data Splits
356
+
357
+ The dataset is split into train and validation:
358
+
359
+ | language | train | validation |
360
+ |----------|------:|-----------:|
361
+ | br | 13211 | 1399 |
362
+ | cy | 13211 | 1665 |
363
+ | ga | 13211 | 1665 |
364
+ | mt | 13211 | 1665 |
365
+ | ru | 5573 | 790 |
366
+
367
+ ## Dataset Creation
368
+
369
+ ### Curation Rationale
370
+
371
+ The WebNLG dataset was created to promote the development _(i)_ of RDF verbalisers and _(ii)_ of microplanners able to handle a wide range of linguistic constructions. The dataset aims at covering knowledge in different domains ("categories"). The same properties and entities can appear in several categories.
372
+
373
+ ### Source Data
374
+
375
+ The data was compiled from raw DBpedia triples. [This paper](https://www.aclweb.org/anthology/C16-1141/) explains how the triples were selected.
376
+
377
+ #### Initial Data Collection and Normalization
378
+
379
+ Initial triples extracted from DBpedia were modified in several ways. See [official documentation](https://webnlg-challenge.loria.fr/docs/) for the most frequent changes that have been made. An original tripleset and a modified tripleset usually represent a one-to-one mapping. However, there are cases with many-to-one mappings when several original triplesets are mapped to one modified tripleset.
380
+
381
+ Entities that served as roots of RDF trees are listed in [this file](https://gitlab.com/shimorina/webnlg-dataset/-/blob/master/supplementary/entities_dict.json).
382
+
383
+ The English WebNLG 2020 dataset (v3.0) for training comprises data-text pairs for 16 distinct DBpedia categories:
384
+ - The 10 seen categories used in the 2017 version: Airport, Astronaut, Building, City, ComicsCharacter, Food, Monument, SportsTeam, University, and WrittenWork.
385
+ - The 5 unseen categories of 2017, which are now part of the seen data: Athlete, Artist, CelestialBody, MeanOfTransportation, Politician.
386
+ - 1 new category: Company.
387
+
388
+ The Russian dataset (v3.0) comprises data-text pairs for 9 distinct categories: Airport, Astronaut, Building, CelestialBody, ComicsCharacter, Food, Monument, SportsTeam, and University.
389
+
390
+ #### Who are the source language producers?
391
+
392
+ There are no source texts, all textual material was compiled during the annotation process.
393
+
394
+ ### Annotations
395
+
396
+ #### Annotation process
397
+
398
+ Annotators were first asked to create sentences that verbalise single triples. In a second round, annotators were asked to combine single-triple sentences together into sentences that cover 2 triples. And so on until 7 triples. Quality checks were performed to ensure the quality of the annotations. See Section 3.3 in [the dataset paper](https://www.aclweb.org/anthology/P17-1017.pdf).
399
+
400
+ Russian data was translated from English with an MT system and then was post-edited by crowdworkers. See Section 2.2 of [this paper](https://webnlg-challenge.loria.fr/files/2020.webnlg-papers.7.pdf).
401
+
402
+ #### Who are the annotators?
403
+
404
+ All references were collected through crowdsourcing platforms (CrowdFlower/Figure 8 and Amazon Mechanical Turk). For Russian, post-editing was done using the Yandex.Toloka crowdsourcing platform.
405
+
406
+ ### Personal and Sensitive Information
407
+
408
+ Neither the dataset as published or the annotation process involves the collection or sharing of any kind of personal / demographic information.
409
+
410
+ ## Considerations for Using the Data
411
+
412
+ ### Social Impact of Dataset
413
+
414
+ We do not foresee any negative social impact in particular from this dataset or task.
415
+
416
+ Positive outlooks: Being able to generate good quality text from RDF data would permit, e.g., making this data more accessible to lay users, enriching existing text with information drawn from knowledge bases such as DBpedia or describing, comparing and relating entities present in these knowledge bases.
417
+
418
+ ### Discussion of Biases
419
+
420
+ This dataset is created using DBpedia RDF triples which naturally exhibit biases that have been found to exist in Wikipedia such as some forms of, e.g., gender bias.
421
+
422
+ The choice of [entities](https://gitlab.com/shimorina/webnlg-dataset/-/blob/master/supplementary/entities_dict.json), described by RDF trees, was not controlled. As such, they may contain gender biases; for instance, all the astronauts described by RDF triples are male. Hence, in texts, pronouns _he/him/his_ occur more often. Similarly, entities can be related to the Western culture more often than to other cultures.
423
+
424
+ ### Other Known Limitations
425
+
426
+ The quality of the crowdsourced references is limited, in particular in terms of fluency/naturalness of the collected texts.
427
+
428
+ Russian data was machine-translated and then post-edited by crowdworkers, so some examples may still exhibit issues related to bad translations.
429
+
430
+ ## Additional Information
431
+
432
+ ### Dataset Curators
433
+
434
+ The principle curator of the dataset is Anastasia Shimorina (Université de Lorraine / LORIA, France). Throughout the WebNLG releases, several people contributed to their construction: Claire Gardent (CNRS / LORIA, France), Shashi Narayan (Google, UK), Laura Perez-Beltrachini (University of Edinburgh, UK), Elena Khasanova, and Thiago Castro Ferreira (Federal University of Minas Gerais, Brazil).
435
+ The dataset construction was funded by the French National Research Agency (ANR).
436
+
437
+ ### Licensing Information
438
+
439
+ The dataset uses the `cc-by-nc-sa-4.0` license. The source DBpedia project uses the `cc-by-sa-3.0` and `gfdl-1.1` licenses.
440
+
441
+ ### Citation Information
442
+
443
+ If you use the WebNLG corpus, cite:
444
+ ```
445
+ @inproceedings{web_nlg,
446
+ author = {Claire Gardent and
447
+ Anastasia Shimorina and
448
+ Shashi Narayan and
449
+ Laura Perez{-}Beltrachini},
450
+ editor = {Regina Barzilay and
451
+ Min{-}Yen Kan},
452
+ title = {Creating Training Corpora for {NLG} Micro-Planners},
453
+ booktitle = {Proceedings of the 55th Annual Meeting of the Association for Computational
454
+ Linguistics, {ACL} 2017, Vancouver, Canada, July 30 - August 4, Volume
455
+ 1: Long Papers},
456
+ pages = {179--188},
457
+ publisher = {Association for Computational Linguistics},
458
+ year = {2017},
459
+ url = {https://doi.org/10.18653/v1/P17-1017},
460
+ doi = {10.18653/v1/P17-1017}
461
+ }
462
+ ```
463
+
464
+ ### Contributions
465
+
466
+ Thanks to [@albertvillanova](https://huggingface.co/albertvillanova) for adding this dataset.
challenge-2023.py ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ """The WebNLG 2023 Challenge."""
16
+
17
+
18
+ import os
19
+ import xml.etree.ElementTree as ET
20
+ from collections import defaultdict
21
+
22
+ import datasets
23
+
24
+
25
+ _HOMEPAGE = "https://synalp.gitlabpages.inria.fr/webnlg-challenge/challenge_2023/"
26
+
27
+ _DESCRIPTION = """\
28
+ The WebNLG challenge consists in mapping data to text. The training data consists
29
+ of Data/Text pairs where the data is a set of triples extracted from DBpedia and the text is a verbalisation
30
+ of these triples. For instance, given the 3 DBpedia triples shown in (a), the aim is to generate a text such as (b).
31
+
32
+ a. (John_E_Blaha birthDate 1942_08_26) (John_E_Blaha birthPlace San_Antonio) (John_E_Blaha occupation Fighter_pilot)
33
+ b. John E Blaha, born in San Antonio on 1942-08-26, worked as a fighter pilot
34
+
35
+ As the example illustrates, the task involves specific NLG subtasks such as sentence segmentation
36
+ (how to chunk the input data into sentences), lexicalisation (of the DBpedia properties),
37
+ aggregation (how to avoid repetitions) and surface realisation
38
+ (how to build a syntactically correct and natural sounding text).
39
+ """
40
+
41
+ _LICENSE = ""
42
+
43
+ _CITATION = """\
44
+ @inproceedings{web_nlg,
45
+ author = {Claire Gardent and
46
+ Anastasia Shimorina and
47
+ Shashi Narayan and
48
+ Laura Perez{-}Beltrachini},
49
+ editor = {Regina Barzilay and
50
+ Min{-}Yen Kan},
51
+ title = {Creating Training Corpora for {NLG} Micro-Planners},
52
+ booktitle = {Proceedings of the 55th Annual Meeting of the
53
+ Association for Computational Linguistics,
54
+ {ACL} 2017, Vancouver, Canada, July 30 - August 4,
55
+ Volume 1: Long Papers},
56
+ pages = {179--188},
57
+ publisher = {Association for Computational Linguistics},
58
+ year = {2017},
59
+ url = {https://doi.org/10.18653/v1/P17-1017},
60
+ doi = {10.18653/v1/P17-1017}
61
+ }
62
+ """
63
+
64
+ # From: https://github.com/WebNLG/2023-Challenge
65
+ _URL = "data.zip"
66
+
67
+ _LANGUAGES = ["br", "cy", "ga", "mt", "ru"]
68
+
69
+
70
+ def et_to_dict(tree):
71
+ dct = {tree.tag: {} if tree.attrib else None}
72
+ children = list(tree)
73
+ if children:
74
+ dd = defaultdict(list)
75
+ for dc in map(et_to_dict, children):
76
+ for k, v in dc.items():
77
+ dd[k].append(v)
78
+ dct = {tree.tag: dd}
79
+ if tree.attrib:
80
+ dct[tree.tag].update((k, v) for k, v in tree.attrib.items())
81
+ if tree.text:
82
+ text = tree.text.strip()
83
+ if children or tree.attrib:
84
+ if text:
85
+ dct[tree.tag]["text"] = text
86
+ else:
87
+ dct[tree.tag] = text
88
+ return dct
89
+
90
+
91
+ def parse_entry(entry):
92
+ res = {}
93
+ otriple_set_list = entry["originaltripleset"]
94
+ res["original_triple_sets"] = [{"otriple_set": otriple_set["otriple"]} for otriple_set in otriple_set_list]
95
+ mtriple_set_list = entry["modifiedtripleset"]
96
+ res["modified_triple_sets"] = [{"mtriple_set": mtriple_set["mtriple"]} for mtriple_set in mtriple_set_list]
97
+ res["category"] = entry["category"]
98
+ res["eid"] = entry["eid"]
99
+ res["size"] = int(entry["size"])
100
+ res["lex"] = {
101
+ "comment": [ex.get("comment", "") for ex in entry.get("lex", [])],
102
+ "lid": [ex.get("lid", "") for ex in entry.get("lex", [])],
103
+ "text": [ex.get("text", "") for ex in entry.get("lex", [])],
104
+ "lang": [ex.get("lang", "") for ex in entry.get("lex", [])],
105
+ }
106
+ res["shape"] = entry.get("shape", "")
107
+ res["shape_type"] = entry.get("shape_type", "")
108
+ return res
109
+
110
+
111
+ def xml_file_to_examples(filename):
112
+ tree = ET.parse(filename).getroot()
113
+ examples = et_to_dict(tree)["benchmark"]["entries"][0]["entry"]
114
+ return [parse_entry(entry) for entry in examples]
115
+
116
+
117
+ class Challenge2023(datasets.GeneratorBasedBuilder):
118
+ """The WebNLG 2023 Challenge dataset."""
119
+
120
+ VERSION = datasets.Version("1.0.0")
121
+
122
+ BUILDER_CONFIGS = [datasets.BuilderConfig(name=language) for language in _LANGUAGES]
123
+
124
+ def _info(self):
125
+ features = datasets.Features(
126
+ {
127
+ "category": datasets.Value("string"),
128
+ "size": datasets.Value("int32"),
129
+ "eid": datasets.Value("string"),
130
+ "original_triple_sets": datasets.Sequence(
131
+ {"otriple_set": datasets.Sequence(datasets.Value("string"))}
132
+ ),
133
+ "modified_triple_sets": datasets.Sequence(
134
+ {"mtriple_set": datasets.Sequence(datasets.Value("string"))}
135
+ ),
136
+ "shape": datasets.Value("string"),
137
+ "shape_type": datasets.Value("string"),
138
+ "lex": datasets.Sequence(
139
+ {
140
+ "comment": datasets.Value("string"),
141
+ "lid": datasets.Value("string"),
142
+ "text": datasets.Value("string"),
143
+ "lang": datasets.Value("string"),
144
+ }
145
+ ),
146
+ }
147
+ )
148
+ return datasets.DatasetInfo(
149
+ description=_DESCRIPTION,
150
+ features=features,
151
+ homepage=_HOMEPAGE,
152
+ citation=_CITATION,
153
+ )
154
+
155
+ def _split_generators(self, dl_manager):
156
+ """Returns SplitGenerators."""
157
+ data_dir = dl_manager.download_and_extract(_URL)
158
+ splits = {datasets.Split.TRAIN: "train", datasets.Split.VALIDATION: "dev"}
159
+ return [
160
+ datasets.SplitGenerator(
161
+ name=split,
162
+ # These kwargs will be passed to _generate_examples
163
+ gen_kwargs={
164
+ "xml_file": os.path.join(data_dir, "data", f"{self.config.name}_{split_filename}.xml"),
165
+ },
166
+ )
167
+ for split, split_filename in splits.items()
168
+ ]
169
+
170
+ def _generate_examples(self, xml_file):
171
+ """Yields examples."""
172
+ id_ = 0
173
+ for exple_dict in xml_file_to_examples(xml_file):
174
+ yield id_, exple_dict
175
+ id_ += 1
data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9fa7701d3809f6a263debfaac9b609182f45a9886a92f990eac2aaa26b5c16ff
3
+ size 10954332