Datasets:
Adding Text-based NP Enrichment (TNE) dataset (#4153)
Browse files* Adding Text-based NP Enrichment (TNE) dataset
* Tests fix: explicit file encoding + yaml format in readme
* contribution section in the readme
* Update datasets/tne/README.md
Co-authored-by: Quentin Lhoest <42851186+lhoestq@users.noreply.github.com>
* Update datasets/tne/README.md
Co-authored-by: Quentin Lhoest <42851186+lhoestq@users.noreply.github.com>
* Update datasets/tne/README.md
Co-authored-by: Quentin Lhoest <42851186+lhoestq@users.noreply.github.com>
* Update datasets/tne/README.md
Co-authored-by: Quentin Lhoest <42851186+lhoestq@users.noreply.github.com>
* Update datasets/tne/README.md
Co-authored-by: Quentin Lhoest <42851186+lhoestq@users.noreply.github.com>
* converting to a single config + updated preposition labels. Moving to single config instead of one for train and one for test. Using an empty list in case of test files, that do not contain the np links labels publicly available. The preposition labels is now using the ClassLabel, with a predefined list of 24 possible values
* Updating the number of documents
Co-authored-by: Quentin Lhoest <42851186+lhoestq@users.noreply.github.com>
* Update datasets/tne/README.md
Co-authored-by: Quentin Lhoest <42851186+lhoestq@users.noreply.github.com>
* fixed remaining of previous separation between labaled/unlabaled
Co-authored-by: Quentin Lhoest <42851186+lhoestq@users.noreply.github.com>
Commit from https://github.com/huggingface/datasets/commit/329781e193dfc373c875d3dc9f8b91644d2b27b1
- README.md +188 -0
- dataset_infos.json +1 -0
- dummy/1.1.0/dummy_data.zip +3 -0
- tne.py +210 -0
@@ -0,0 +1,188 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
annotations_creators:
|
3 |
+
- crowdsourced
|
4 |
+
language_creators:
|
5 |
+
- found
|
6 |
+
languages:
|
7 |
+
- en
|
8 |
+
licenses:
|
9 |
+
- mit
|
10 |
+
multilinguality:
|
11 |
+
- monolingual
|
12 |
+
pretty_name: Text-based NP Enrichment
|
13 |
+
size_categories:
|
14 |
+
- 1K<n<10K
|
15 |
+
source_datasets:
|
16 |
+
- original
|
17 |
+
task_categories:
|
18 |
+
- text-retrieval
|
19 |
+
task_ids:
|
20 |
+
- document-retrieval
|
21 |
+
---
|
22 |
+
|
23 |
+
# Dataset Card for Text-based NP Enrichment
|
24 |
+
|
25 |
+
## Table of Contents
|
26 |
+
- [Dataset Description](#dataset-description)
|
27 |
+
- [Dataset Summary](#dataset-summary)
|
28 |
+
- [Supported Tasks](#supported-tasks-and-leaderboards)
|
29 |
+
- [Languages](#languages)
|
30 |
+
- [Dataset Structure](#dataset-structure)
|
31 |
+
- [Data Instances](#data-instances)
|
32 |
+
- [Data Fields](#data-instances)
|
33 |
+
- [Data Splits](#data-instances)
|
34 |
+
- [Dataset Creation](#dataset-creation)
|
35 |
+
- [Curation Rationale](#curation-rationale)
|
36 |
+
- [Source Data](#source-data)
|
37 |
+
- [Annotations](#annotations)
|
38 |
+
- [Personal and Sensitive Information](#personal-and-sensitive-information)
|
39 |
+
- [Considerations for Using the Data](#considerations-for-using-the-data)
|
40 |
+
- [Social Impact of Dataset](#social-impact-of-dataset)
|
41 |
+
- [Discussion of Biases](#discussion-of-biases)
|
42 |
+
- [Other Known Limitations](#other-known-limitations)
|
43 |
+
- [Additional Information](#additional-information)
|
44 |
+
- [Dataset Curators](#dataset-curators)
|
45 |
+
- [Licensing Information](#licensing-information)
|
46 |
+
- [Citation Information](#citation-information)
|
47 |
+
|
48 |
+
## Dataset Description
|
49 |
+
|
50 |
+
- **Homepage:** https://yanaiela.github.io/TNE/
|
51 |
+
- **Repository:** https://github.com/yanaiela/TNE
|
52 |
+
- **Paper:** https://arxiv.org/abs/2109.12085
|
53 |
+
- **Leaderboard:** [TNE](https://leaderboard.allenai.org/tne/submissions/public)
|
54 |
+
[TNE OOD](https://leaderboard.allenai.org/tne-ood/submissions/public)
|
55 |
+
- **Point of Contact:** [Yanai Elazar](mailto:yanaiela@gmail.com)
|
56 |
+
|
57 |
+
### Dataset Summary
|
58 |
+
|
59 |
+
Text-based NP Enrichment (TNE) is a natural language understanding (NLU) task, which focus on relations between noun phrases (NPs) that can be mediated via prepositions. The dataset contains 5,497 documents, annotated exhaustively with all possible links between the NPs in each document.
|
60 |
+
|
61 |
+
The main data comes from WikiNews, which is used for train/dev/test. We also collected an additional set of 509 documents to serve as out of distribution (OOD) data points, from the Book Corpus, IMDB reviews and Reddit.
|
62 |
+
|
63 |
+
### Supported Tasks and Leaderboards
|
64 |
+
|
65 |
+
[Needs More Information]
|
66 |
+
|
67 |
+
### Languages
|
68 |
+
|
69 |
+
The text in the dataset is in English, as spoken in the different domains we include. The associated BCP-47 code is `en`.
|
70 |
+
|
71 |
+
## Dataset Structure
|
72 |
+
|
73 |
+
### Data Instances
|
74 |
+
|
75 |
+
The original files are in a jsonl format, containing a dictionary of a single document, in each line.
|
76 |
+
Each document contain a different amount of labels, due to the different amount of NPs.
|
77 |
+
The test and ood splits come without the annotated labels.
|
78 |
+
|
79 |
+
### Data Fields
|
80 |
+
|
81 |
+
A document consists of:
|
82 |
+
|
83 |
+
* `id`: a unique identifier of a document, beginning with `r` and followed by a number
|
84 |
+
* `text`: the text of the document. The title and subtitles (if exists) are separated with two new lines. The paragraphs
|
85 |
+
are separated by a single new line.
|
86 |
+
* `tokens`: a list of string, containing the tokenized tokens
|
87 |
+
* `nps`: a list of dictionaries, containing the following entries:
|
88 |
+
* `text`: the text of the np
|
89 |
+
* `start_index`: an integer indicating the starting index in the text
|
90 |
+
* `end_index`: an integer indicating the ending index in the text
|
91 |
+
* `start_token`: an integer indicating the first token of the np out of the tokenized tokens
|
92 |
+
* `end_token`: an integer indicating the last token of the np out of the tokenized tokens
|
93 |
+
* `id`: the id of the np
|
94 |
+
* `np_relations`: these are the relation labels of the document. It is a list of dictionaries, where each
|
95 |
+
dictionary contains:
|
96 |
+
* `anchor`: the id of the anchor np
|
97 |
+
* `complement`: the id of the complement np
|
98 |
+
* `preposition`: the preposition that links between the anchor and the complement. This can take one out of 24 pre-defined preposition (23 + member(s)-of)
|
99 |
+
* `complement_coref_cluster_id`: the coreference id, which the complement is part of.
|
100 |
+
* `coref`: the coreference labels. It contains a list of dictionaries, where each dictionary contains:
|
101 |
+
* `id`: the id of the coreference cluster
|
102 |
+
* `members`: the ids of the nps members of such cluster
|
103 |
+
* `np_type`: the type of cluster. It can be either
|
104 |
+
* `standard`: regular coreference cluster
|
105 |
+
* `time/date/measurement`: a time / date / measurement np. These will be singletons.
|
106 |
+
* `idiomatic`: an idiomatic expression
|
107 |
+
* `metadata`: metadata of the document. It contains the following:
|
108 |
+
* `annotators`: a dictionary with anonymized annotators id
|
109 |
+
* `coref_worker`: the coreference worker id
|
110 |
+
* `consolidator_worker`: the consolidator worker id
|
111 |
+
* `np-relations_worker`: the np relations worker id
|
112 |
+
* `url`: the url where the document was taken from (not always existing)
|
113 |
+
* `source`: the original file name where the document was taken from
|
114 |
+
|
115 |
+
|
116 |
+
### Data Splits
|
117 |
+
|
118 |
+
The dataset is spread across four files, for the four different splits: train, dev, test and test_ood.
|
119 |
+
Additional details on the data statistics can be found in the [paper](https://arxiv.org/abs/2109.12085)
|
120 |
+
|
121 |
+
## Dataset Creation
|
122 |
+
|
123 |
+
### Curation Rationale
|
124 |
+
|
125 |
+
TNE was build as a new task for language understanding, focusing on extracting relations between nouns, moderated by prepositions.
|
126 |
+
|
127 |
+
### Source Data
|
128 |
+
|
129 |
+
#### Initial Data Collection and Normalization
|
130 |
+
|
131 |
+
[Needs More Information]
|
132 |
+
|
133 |
+
#### Who are the source language producers?
|
134 |
+
|
135 |
+
[Needs More Information]
|
136 |
+
|
137 |
+
### Annotations
|
138 |
+
|
139 |
+
#### Annotation process
|
140 |
+
|
141 |
+
[Needs More Information]
|
142 |
+
|
143 |
+
#### Who are the annotators?
|
144 |
+
|
145 |
+
[Needs More Information]
|
146 |
+
|
147 |
+
### Personal and Sensitive Information
|
148 |
+
|
149 |
+
[Needs More Information]
|
150 |
+
|
151 |
+
## Considerations for Using the Data
|
152 |
+
|
153 |
+
### Social Impact of Dataset
|
154 |
+
|
155 |
+
[Needs More Information]
|
156 |
+
|
157 |
+
### Discussion of Biases
|
158 |
+
|
159 |
+
[Needs More Information]
|
160 |
+
|
161 |
+
### Other Known Limitations
|
162 |
+
|
163 |
+
[Needs More Information]
|
164 |
+
|
165 |
+
## Additional Information
|
166 |
+
|
167 |
+
### Dataset Curators
|
168 |
+
|
169 |
+
The dataset was created by Yanai Elazar, Victoria Basmov, Yoav Goldberg, Reut Tsarfaty, during work done at Bar-Ilan University, and AI2.
|
170 |
+
|
171 |
+
### Licensing Information
|
172 |
+
|
173 |
+
The data is released under the MIT license.
|
174 |
+
|
175 |
+
### Citation Information
|
176 |
+
|
177 |
+
```bibtex
|
178 |
+
@article{tne,
|
179 |
+
author = {Elazar, Yanai and Basmov, Victoria and Goldberg, Yoav and Tsarfaty, Reut},
|
180 |
+
title = "{Text-based NP Enrichment}",
|
181 |
+
journal = {Transactions of the Association for Computational Linguistics},
|
182 |
+
year = {2022},
|
183 |
+
}
|
184 |
+
```
|
185 |
+
|
186 |
+
### Contributions
|
187 |
+
|
188 |
+
Thanks to [@yanaiela](https://github.com/yanaiela), who is also the first author of the paper, for adding this dataset.
|
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"default": {"description": "TNE is an NLU task, which focus on relations between noun phrases (NPs) that can be mediated via prepositions.\nThe dataset contains 5,497 documents, annotated exhaustively with all possible links between the NPs in each document.\n", "citation": "@article{tne,\n author = {Elazar, Yanai and Basmov, Victoria and Goldberg, Yoav and Tsarfaty, Reut},\n title = \"{Text-based NP Enrichment}\",\n journal = {Transactions of the Association for Computational Linguistics},\n year = {2022},\n}\n", "homepage": "https://yanaiela.github.io/TNE/", "license": "MIT", "features": {"id": {"dtype": "string", "id": null, "_type": "Value"}, "text": {"dtype": "string", "id": null, "_type": "Value"}, "tokens": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "nps": [{"text": {"dtype": "string", "id": null, "_type": "Value"}, "first_char": {"dtype": "int32", "id": null, "_type": "Value"}, "last_char": {"dtype": "int32", "id": null, "_type": "Value"}, "first_token": {"dtype": "int32", "id": null, "_type": "Value"}, "last_token": {"dtype": "int32", "id": null, "_type": "Value"}, "id": {"dtype": "string", "id": null, "_type": "Value"}}], "np_relations": [{"anchor": {"dtype": "string", "id": null, "_type": "Value"}, "complement": {"dtype": "string", "id": null, "_type": "Value"}, "preposition": {"num_classes": 24, "names": ["about", "for", "with", "from", "among", "by", "on", "at", "during", "of", "member(s) of", "in", "after", "under", "to", "into", "before", "near", "outside", "around", "between", "against", "over", "inside"], "id": null, "_type": "ClassLabel"}, "complement_coref_cluster_id": {"dtype": "string", "id": null, "_type": "Value"}}], "coref": [{"id": {"dtype": "string", "id": null, "_type": "Value"}, "members": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "np_type": {"num_classes": 3, "names": ["standard", "time/date/measurement", "idiomatic"], "id": null, "_type": "ClassLabel"}}], "metadata": {"annotators": {"coref_worker": {"dtype": "int32", "id": null, "_type": "Value"}, "consolidator_worker": {"dtype": "int32", "id": null, "_type": "Value"}, "np-relations_worker": {"feature": {"dtype": "int32", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}}, "url": {"dtype": "string", "id": null, "_type": "Value"}, "source": {"dtype": "string", "id": null, "_type": "Value"}}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "tne_dataset", "config_name": "default", "version": {"version_str": "1.1.0", "description": null, "major": 1, "minor": 1, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 41308170, "num_examples": 3988, "dataset_name": "tne_dataset"}, "validation": {"name": "validation", "num_bytes": 5495419, "num_examples": 500, "dataset_name": "tne_dataset"}, "test": {"name": "test", "num_bytes": 2203716, "num_examples": 500, "dataset_name": "tne_dataset"}, "test_ood": {"name": "test_ood", "num_bytes": 2249352, "num_examples": 509, "dataset_name": "tne_dataset"}}, "download_checksums": {"https://github.com/yanaiela/TNE/raw/main/data/train-v1.1.jsonl.gz": {"num_bytes": 11135145, "checksum": "d616372e92e6334dfddaaca3c7898f7aeed7b8827c9821aa555ad1d1a8e8eb1c"}, "https://github.com/yanaiela/TNE/raw/main/data/dev-v1.1.jsonl.gz": {"num_bytes": 1466591, "checksum": "3f3e466330908270ee742725c6b68f92b3243b988aa8b8c9bfef69ad8e68fe14"}, "https://github.com/yanaiela/TNE/raw/main/data/test_unlabeled-v1.1.jsonl.gz": {"num_bytes": 781824, "checksum": "a461ef30beba25feefbb1777ecb42e63a1ce20f3675e2c551a442c393f4118c7"}, "https://github.com/yanaiela/TNE/raw/main/data/ood_unlabeled-v1.1.jsonl.gz": {"num_bytes": 811018, "checksum": "9278c13c381f1f3b6623e599086984695c00e31840c121c2053d3f466f2d2170"}}, "download_size": 14194578, "post_processing_size": null, "dataset_size": 51256657, "size_in_bytes": 65451235}}
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d4185db56411091e0247d7598cec73fe636ca36d6a0db710d1d9aade6e871687
|
3 |
+
size 51537
|
@@ -0,0 +1,210 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
2 |
+
#
|
3 |
+
# Licensed under the Apache License, Version 2.0 (the "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 |
+
"""TNE: Text-based NP Enrichment"""
|
15 |
+
|
16 |
+
import json
|
17 |
+
|
18 |
+
import datasets
|
19 |
+
|
20 |
+
|
21 |
+
# Find for instance the citation on arxiv or on the dataset repo/website
|
22 |
+
_CITATION = """\
|
23 |
+
@article{tne,
|
24 |
+
author = {Elazar, Yanai and Basmov, Victoria and Goldberg, Yoav and Tsarfaty, Reut},
|
25 |
+
title = "{Text-based NP Enrichment}",
|
26 |
+
journal = {Transactions of the Association for Computational Linguistics},
|
27 |
+
year = {2022},
|
28 |
+
}
|
29 |
+
"""
|
30 |
+
|
31 |
+
# You can copy an official description
|
32 |
+
_DESCRIPTION = """\
|
33 |
+
TNE is an NLU task, which focus on relations between noun phrases (NPs) that can be mediated via prepositions.
|
34 |
+
The dataset contains 5,497 documents, annotated exhaustively with all possible links between the NPs in each document.
|
35 |
+
"""
|
36 |
+
|
37 |
+
_HOMEPAGE = "https://yanaiela.github.io/TNE/"
|
38 |
+
|
39 |
+
_LICENSE = "MIT"
|
40 |
+
|
41 |
+
_VERSION = "v1.1"
|
42 |
+
|
43 |
+
# The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
|
44 |
+
# This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
|
45 |
+
_URL = "https://github.com/yanaiela/TNE/raw/main/data/"
|
46 |
+
_URLS = {
|
47 |
+
"train": _URL + f"train-{_VERSION}.jsonl.gz",
|
48 |
+
"dev": _URL + f"dev-{_VERSION}.jsonl.gz",
|
49 |
+
"test_unlabeled": _URL + f"test_unlabeled-{_VERSION}.jsonl.gz",
|
50 |
+
"ood_unlabeled": _URL + f"ood_unlabeled-{_VERSION}.jsonl.gz",
|
51 |
+
}
|
52 |
+
|
53 |
+
|
54 |
+
class TNEDataset(datasets.GeneratorBasedBuilder):
|
55 |
+
"""TNE: Text-based NP Enrichment"""
|
56 |
+
|
57 |
+
VERSION = datasets.Version("1.1.0")
|
58 |
+
|
59 |
+
def _info(self):
|
60 |
+
features = datasets.Features(
|
61 |
+
{
|
62 |
+
"id": datasets.Value("string"),
|
63 |
+
"text": datasets.Value("string"),
|
64 |
+
"tokens": datasets.Sequence(datasets.Value("string")),
|
65 |
+
"nps": [
|
66 |
+
{
|
67 |
+
"text": datasets.Value("string"),
|
68 |
+
"first_char": datasets.Value("int32"),
|
69 |
+
"last_char": datasets.Value("int32"),
|
70 |
+
"first_token": datasets.Value("int32"),
|
71 |
+
"last_token": datasets.Value("int32"),
|
72 |
+
"id": datasets.Value("string"),
|
73 |
+
}
|
74 |
+
],
|
75 |
+
"np_relations": [
|
76 |
+
{
|
77 |
+
"anchor": datasets.Value("string"),
|
78 |
+
"complement": datasets.Value("string"),
|
79 |
+
"preposition": datasets.features.ClassLabel(
|
80 |
+
names=[
|
81 |
+
"about",
|
82 |
+
"for",
|
83 |
+
"with",
|
84 |
+
"from",
|
85 |
+
"among",
|
86 |
+
"by",
|
87 |
+
"on",
|
88 |
+
"at",
|
89 |
+
"during",
|
90 |
+
"of",
|
91 |
+
"member(s) of",
|
92 |
+
"in",
|
93 |
+
"after",
|
94 |
+
"under",
|
95 |
+
"to",
|
96 |
+
"into",
|
97 |
+
"before",
|
98 |
+
"near",
|
99 |
+
"outside",
|
100 |
+
"around",
|
101 |
+
"between",
|
102 |
+
"against",
|
103 |
+
"over",
|
104 |
+
"inside",
|
105 |
+
]
|
106 |
+
),
|
107 |
+
"complement_coref_cluster_id": datasets.Value("string"),
|
108 |
+
}
|
109 |
+
],
|
110 |
+
"coref": [
|
111 |
+
{
|
112 |
+
"id": datasets.Value("string"),
|
113 |
+
"members": datasets.Sequence(datasets.Value("string")),
|
114 |
+
"np_type": datasets.features.ClassLabel(
|
115 |
+
names=[
|
116 |
+
"standard",
|
117 |
+
"time/date/measurement",
|
118 |
+
"idiomatic",
|
119 |
+
]
|
120 |
+
),
|
121 |
+
}
|
122 |
+
],
|
123 |
+
"metadata": {
|
124 |
+
"annotators": {
|
125 |
+
"coref_worker": datasets.Value("int32"),
|
126 |
+
"consolidator_worker": datasets.Value("int32"),
|
127 |
+
"np-relations_worker": datasets.Sequence(datasets.Value("int32")),
|
128 |
+
},
|
129 |
+
"url": datasets.Value("string"),
|
130 |
+
"source": datasets.Value("string"),
|
131 |
+
},
|
132 |
+
}
|
133 |
+
)
|
134 |
+
|
135 |
+
return datasets.DatasetInfo(
|
136 |
+
# This is the description that will appear on the datasets page.
|
137 |
+
description=_DESCRIPTION,
|
138 |
+
# This defines the different columns of the dataset and their types
|
139 |
+
features=features, # Here we define them above because they are different between the two configurations
|
140 |
+
# If there's a common (input, target) tuple from the features, uncomment supervised_keys line below and
|
141 |
+
# specify them. They'll be used if as_supervised=True in builder.as_dataset.
|
142 |
+
# supervised_keys=("sentence", "label"),
|
143 |
+
# Homepage of the dataset for documentation
|
144 |
+
homepage=_HOMEPAGE,
|
145 |
+
# License for the dataset if available
|
146 |
+
license=_LICENSE,
|
147 |
+
# Citation for the dataset
|
148 |
+
citation=_CITATION,
|
149 |
+
)
|
150 |
+
|
151 |
+
def _split_generators(self, dl_manager):
|
152 |
+
urls = _URLS
|
153 |
+
data_dir = dl_manager.download_and_extract(urls)
|
154 |
+
|
155 |
+
return [
|
156 |
+
datasets.SplitGenerator(
|
157 |
+
name=datasets.Split.TRAIN,
|
158 |
+
# These kwargs will be passed to _generate_examples
|
159 |
+
gen_kwargs={
|
160 |
+
"filepath": data_dir["train"],
|
161 |
+
"split": "train",
|
162 |
+
},
|
163 |
+
),
|
164 |
+
datasets.SplitGenerator(
|
165 |
+
name=datasets.Split.VALIDATION,
|
166 |
+
# These kwargs will be passed to _generate_examples
|
167 |
+
gen_kwargs={
|
168 |
+
"filepath": data_dir["dev"],
|
169 |
+
"split": "dev",
|
170 |
+
},
|
171 |
+
),
|
172 |
+
datasets.SplitGenerator(
|
173 |
+
name=datasets.Split.TEST,
|
174 |
+
# These kwargs will be passed to _generate_examples
|
175 |
+
gen_kwargs={"filepath": data_dir["test_unlabeled"], "split": "test_unlabeled"},
|
176 |
+
),
|
177 |
+
datasets.SplitGenerator(
|
178 |
+
name=datasets.Split("test_ood"),
|
179 |
+
# These kwargs will be passed to _generate_examples
|
180 |
+
gen_kwargs={"filepath": data_dir["ood_unlabeled"], "split": "ood_unlabeled"},
|
181 |
+
),
|
182 |
+
]
|
183 |
+
|
184 |
+
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
185 |
+
def _generate_examples(self, filepath, split):
|
186 |
+
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
|
187 |
+
with open(filepath, "r", encoding="utf-8") as f:
|
188 |
+
for key, row in enumerate(f):
|
189 |
+
data = json.loads(row)
|
190 |
+
|
191 |
+
ex_id = data["id"]
|
192 |
+
text = data["text"]
|
193 |
+
tokens = data["tokens"]
|
194 |
+
nps = data["nps"]
|
195 |
+
if split in ["test_unlabeled", "ood_unlabeled"]:
|
196 |
+
np_relations = []
|
197 |
+
else:
|
198 |
+
np_relations = data["np_relations"]
|
199 |
+
coref = data["coref"]
|
200 |
+
metadata = data["metadata"]
|
201 |
+
|
202 |
+
yield key, {
|
203 |
+
"id": ex_id,
|
204 |
+
"text": text,
|
205 |
+
"tokens": tokens,
|
206 |
+
"nps": nps,
|
207 |
+
"np_relations": np_relations,
|
208 |
+
"coref": coref,
|
209 |
+
"metadata": metadata,
|
210 |
+
}
|