Datasets:
Commit
•
9b2942b
0
Parent(s):
Update files from the datasets library (from 1.2.0)
Browse filesRelease notes: https://github.com/huggingface/datasets/releases/tag/1.2.0
- .gitattributes +27 -0
- README.md +191 -0
- dataset_infos.json +1 -0
- dummy/identification/0.0.0/dummy_data.zip +3 -0
- dummy/resolution/0.0.0/dummy_data.zip +3 -0
- numeric_fused_head.py +141 -0
.gitattributes
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
20 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
26 |
+
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,191 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
annotations_creators:
|
3 |
+
identification:
|
4 |
+
- expert-generated
|
5 |
+
- machine-generated
|
6 |
+
resolution:
|
7 |
+
- crowdsourced
|
8 |
+
language_creators:
|
9 |
+
- found
|
10 |
+
languages:
|
11 |
+
- en
|
12 |
+
licenses:
|
13 |
+
- mit
|
14 |
+
multilinguality:
|
15 |
+
- monolingual
|
16 |
+
size_categories:
|
17 |
+
identification:
|
18 |
+
- 100K<n<1M
|
19 |
+
resolution:
|
20 |
+
- 1K<n<10K
|
21 |
+
source_datasets:
|
22 |
+
- original
|
23 |
+
task_categories:
|
24 |
+
- structure-prediction
|
25 |
+
task_ids:
|
26 |
+
- structure-prediction-other-fused-head-identification
|
27 |
+
---
|
28 |
+
|
29 |
+
# Dataset Card for Numeric Fused Heads
|
30 |
+
|
31 |
+
## Table of Contents
|
32 |
+
- [Dataset Description](#dataset-description)
|
33 |
+
- [Dataset Summary](#dataset-summary)
|
34 |
+
- [Supported Tasks](#supported-tasks-and-leaderboards)
|
35 |
+
- [Languages](#languages)
|
36 |
+
- [Dataset Structure](#dataset-structure)
|
37 |
+
- [Data Instances](#data-instances)
|
38 |
+
- [Data Fields](#data-instances)
|
39 |
+
- [Data Splits](#data-instances)
|
40 |
+
- [Dataset Creation](#dataset-creation)
|
41 |
+
- [Curation Rationale](#curation-rationale)
|
42 |
+
- [Source Data](#source-data)
|
43 |
+
- [Annotations](#annotations)
|
44 |
+
- [Personal and Sensitive Information](#personal-and-sensitive-information)
|
45 |
+
- [Considerations for Using the Data](#considerations-for-using-the-data)
|
46 |
+
- [Social Impact of Dataset](#social-impact-of-dataset)
|
47 |
+
- [Discussion of Biases](#discussion-of-biases)
|
48 |
+
- [Other Known Limitations](#other-known-limitations)
|
49 |
+
- [Additional Information](#additional-information)
|
50 |
+
- [Dataset Curators](#dataset-curators)
|
51 |
+
- [Licensing Information](#licensing-information)
|
52 |
+
- [Citation Information](#citation-information)
|
53 |
+
|
54 |
+
## Dataset Description
|
55 |
+
|
56 |
+
- **Homepage:** [The Numeric Fused-Head demo](https://nlp.biu.ac.il/~lazary/fh/)
|
57 |
+
- **Repository:** [Github Repo](https://github.com/yanaiela/num_fh)
|
58 |
+
- **Paper:** [Where’s My Head? Definition, Dataset and Models for Numeric Fused-Heads Identification and Resolution](https://www.mitpressjournals.org/doi/full/10.1162/tacl_a_00280)
|
59 |
+
- **Leaderboard:** [NLP Progress](http://nlpprogress.com/english/missing_elements.html)
|
60 |
+
- **Point of Contact:** [Yanai Elazar](https://yanaiela.github.io), [Yoav Goldberg](https://www.cs.bgu.ac.il/~yoavg/uni/)
|
61 |
+
|
62 |
+
### Dataset Summary
|
63 |
+
|
64 |
+
[More Information Needed]
|
65 |
+
|
66 |
+
### Supported Tasks and Leaderboards
|
67 |
+
|
68 |
+
- Numeric Fused Head Identification
|
69 |
+
- Numeric Fused Head Resolution
|
70 |
+
|
71 |
+
### Languages
|
72 |
+
|
73 |
+
English
|
74 |
+
|
75 |
+
## Dataset Structure
|
76 |
+
|
77 |
+
### Data Instances
|
78 |
+
|
79 |
+
## Identification
|
80 |
+
|
81 |
+
```
|
82 |
+
{
|
83 |
+
"tokens": ["It", "’s", "a", "curious", "thing", ",", "the", "death", "of", "a", "loved", "one", "."]
|
84 |
+
"start_index": 11
|
85 |
+
"end_index": 12
|
86 |
+
"label": 1
|
87 |
+
}
|
88 |
+
```
|
89 |
+
|
90 |
+
## Resolution
|
91 |
+
|
92 |
+
```
|
93 |
+
{
|
94 |
+
"tokens": ["I", "'m", "eighty", "tomorrow", ".", "Are", "you", "sure", "?"],
|
95 |
+
"line_indices": [0, 0, 0, 0, 0, 1, 1, 1, 1],
|
96 |
+
"head": ["AGE"],
|
97 |
+
"speakers": ["John Doe", "John Doe", "John Doe", "John Doe", "John Doe", "Joe Bloggs", "Joe Bloggs", "Joe Bloggs", "Joe Bloggs"],
|
98 |
+
"anchors_indices": [2]
|
99 |
+
}
|
100 |
+
```
|
101 |
+
|
102 |
+
### Data Fields
|
103 |
+
|
104 |
+
## Identification
|
105 |
+
|
106 |
+
- `tokens` - List of token strings as tokenized with [Spacy](spacy.io).
|
107 |
+
- `start_index` - Start index of the anchor.
|
108 |
+
- `end_index` - End index of the anchor.
|
109 |
+
- `label` - "pos" or "neg" depending on whether this example contains a numeric fused head.
|
110 |
+
|
111 |
+
## Resolution
|
112 |
+
|
113 |
+
- `tokens` - List of token strings as tokenized with [Spacy](spacy.io)
|
114 |
+
- `line_indices` - List of indices indicating line number (one for each token)
|
115 |
+
- `head` - Reference to the missing head. If the head exists elsewhere in the sentence this is given as a token index.
|
116 |
+
- `speakers` - List of speaker names (one for each token)
|
117 |
+
- `anchors_indices` - Index to indicate which token is the anchor (the visible number)
|
118 |
+
|
119 |
+
### Data Splits
|
120 |
+
|
121 |
+
Train, Test, Dev
|
122 |
+
|
123 |
+
[More Information Needed]
|
124 |
+
|
125 |
+
## Dataset Creation
|
126 |
+
|
127 |
+
### Curation Rationale
|
128 |
+
|
129 |
+
[More Information Needed]
|
130 |
+
|
131 |
+
### Source Data
|
132 |
+
|
133 |
+
#### Initial Data Collection and Normalization
|
134 |
+
|
135 |
+
[More Information Needed]
|
136 |
+
|
137 |
+
#### Who are the source language producers?
|
138 |
+
|
139 |
+
[More Information Needed]
|
140 |
+
|
141 |
+
### Annotations
|
142 |
+
|
143 |
+
#### Annotation process
|
144 |
+
|
145 |
+
[More Information Needed]
|
146 |
+
|
147 |
+
#### Who are the annotators?
|
148 |
+
|
149 |
+
[More Information Needed]
|
150 |
+
|
151 |
+
### Personal and Sensitive Information
|
152 |
+
|
153 |
+
[More Information Needed]
|
154 |
+
|
155 |
+
## Considerations for Using the Data
|
156 |
+
|
157 |
+
### Social Impact of Dataset
|
158 |
+
|
159 |
+
[More Information Needed]
|
160 |
+
|
161 |
+
### Discussion of Biases
|
162 |
+
|
163 |
+
[More Information Needed]
|
164 |
+
|
165 |
+
### Other Known Limitations
|
166 |
+
|
167 |
+
[More Information Needed]
|
168 |
+
|
169 |
+
## Additional Information
|
170 |
+
|
171 |
+
### Dataset Curators
|
172 |
+
|
173 |
+
[More Information Needed]
|
174 |
+
|
175 |
+
### Licensing Information
|
176 |
+
|
177 |
+
MIT License
|
178 |
+
|
179 |
+
### Citation Information
|
180 |
+
```
|
181 |
+
@article{doi:10.1162/tacl\_a\_00280,
|
182 |
+
author = {Elazar, Yanai and Goldberg, Yoav},
|
183 |
+
title = {Where’s My Head? Definition, Data Set, and Models for Numeric Fused-Head Identification and Resolution},
|
184 |
+
journal = {Transactions of the Association for Computational Linguistics},
|
185 |
+
volume = {7},
|
186 |
+
number = {},
|
187 |
+
pages = {519-535},
|
188 |
+
year = {2019},
|
189 |
+
doi = {10.1162/tacl\_a\_00280},
|
190 |
+
}
|
191 |
+
```
|
dataset_infos.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"identification": {"description": "Fused Head constructions are noun phrases in which the head noun is missing and is said to be \"fused\" with its dependent modifier. This missing information is implicit and is important for sentence understanding.The missing heads are easily filled in by humans, but pose a challenge for computational models.\n\nFor example, in the sentence: \"I bought 5 apples but got only 4.\", 4 is a Fused-Head, and the missing head is apples, which appear earlier in the sentence.\n\nThis is a crowd-sourced dataset of 10k numerical fused head examples (1M tokens).\n", "citation": "@article{elazar_head,\n author = {Elazar, Yanai and Goldberg, Yoav},\n title = {Where\u2019s My Head? Definition, Data Set, and Models for Numeric Fused-Head Identification and Resolution},\n journal = {Transactions of the Association for Computational Linguistics},\n volume = {7},\n number = {},\n pages = {519-535},\n year = {2019},\n doi = {10.1162/tacl\\_a\\_00280},\n URL = {https://doi.org/10.1162/tacl_a_00280},\n}\n", "homepage": "https://nlp.biu.ac.il/~lazary/fh/", "license": "MIT", "features": {"tokens": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "start_index": {"dtype": "int32", "id": null, "_type": "Value"}, "end_index": {"dtype": "int32", "id": null, "_type": "Value"}, "label": {"num_classes": 2, "names": ["neg", "pos"], "names_file": null, "id": null, "_type": "ClassLabel"}}, "post_processed": null, "supervised_keys": null, "builder_name": "numeric_fused_head", "config_name": "identification", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 22290345, "num_examples": 165606, "dataset_name": "numeric_fused_head"}, "test": {"name": "test", "num_bytes": 68282, "num_examples": 500, "dataset_name": "numeric_fused_head"}, "validation": {"name": "validation", "num_bytes": 2474528, "num_examples": 18401, "dataset_name": "numeric_fused_head"}}, "download_checksums": {"https://raw.githubusercontent.com/yanaiela/num_fh/master/data/identification/processed/train.tsv": {"num_bytes": 21908366, "checksum": "5534fbfdfa2d7b1a370e4a303fcc5ea324f8aae4d5ad0b2601961225c38f19eb"}, "https://raw.githubusercontent.com/yanaiela/num_fh/master/data/identification/processed/test.tsv": {"num_bytes": 67315, "checksum": "4d0f3b3b103ad592b8ad0a3e6d24c28bff6afb684e8bc08d22da8070f0e73c13"}, "https://raw.githubusercontent.com/yanaiela/num_fh/master/data/identification/processed/dev.tsv": {"num_bytes": 2431839, "checksum": "457ebe4342f5c6d53a04c8b49a50bcdee47b3d156aab3e37f8e79ff55823f02a"}}, "download_size": 24407520, "post_processing_size": null, "dataset_size": 24833155, "size_in_bytes": 49240675}, "resolution": {"description": "Fused Head constructions are noun phrases in which the head noun is missing and is said to be \"fused\" with its dependent modifier. This missing information is implicit and is important for sentence understanding.The missing heads are easily filled in by humans, but pose a challenge for computational models.\n\nFor example, in the sentence: \"I bought 5 apples but got only 4.\", 4 is a Fused-Head, and the missing head is apples, which appear earlier in the sentence.\n\nThis is a crowd-sourced dataset of 10k numerical fused head examples (1M tokens).\n", "citation": "@article{elazar_head,\n author = {Elazar, Yanai and Goldberg, Yoav},\n title = {Where\u2019s My Head? Definition, Data Set, and Models for Numeric Fused-Head Identification and Resolution},\n journal = {Transactions of the Association for Computational Linguistics},\n volume = {7},\n number = {},\n pages = {519-535},\n year = {2019},\n doi = {10.1162/tacl\\_a\\_00280},\n URL = {https://doi.org/10.1162/tacl_a_00280},\n}\n", "homepage": "https://nlp.biu.ac.il/~lazary/fh/", "license": "MIT", "features": {"tokens": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "line_indices": {"feature": {"dtype": "int32", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "head": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "speakers": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "anchors_indices": {"feature": {"dtype": "int32", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "builder_name": "numeric_fused_head", "config_name": "resolution", "version": "0.0.0", "splits": {"train": {"name": "train", "num_bytes": 19766437, "num_examples": 7412, "dataset_name": "numeric_fused_head"}, "test": {"name": "test", "num_bytes": 2743071, "num_examples": 1000, "dataset_name": "numeric_fused_head"}, "validation": {"name": "validation", "num_bytes": 2633549, "num_examples": 1000, "dataset_name": "numeric_fused_head"}}, "download_checksums": {"https://raw.githubusercontent.com/yanaiela/num_fh/master/data/resolution/processed/nfh_train.jsonl": {"num_bytes": 19589828, "checksum": "9391e454c4dbfe2db27f4fe8fb0d1af320e27306e1e6735553d348407cea2b2e"}, "https://raw.githubusercontent.com/yanaiela/num_fh/master/data/resolution/processed/nfh_test.jsonl": {"num_bytes": 2723429, "checksum": "8962497910531544fd162cd212533e590b41165759490d781063b1a67d4caded"}, "https://raw.githubusercontent.com/yanaiela/num_fh/master/data/resolution/processed/nfh_dev.jsonl": {"num_bytes": 2610146, "checksum": "967174c741cb69cb98ac7a091e620f26e766c4a766fb679c45743933a144e095"}}, "download_size": 24923403, "post_processing_size": null, "dataset_size": 25143057, "size_in_bytes": 50066460}}
|
dummy/identification/0.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7cd4eb5b2dc4d6b2d778736a8dcdc68adb2ba1b9b2cab453841bb8f1ff3c5803
|
3 |
+
size 1132
|
dummy/resolution/0.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:442f9ffc54cc139ee40f118036eefbe1319bac12c0ce9ebaf0a35aa27538222a
|
3 |
+
size 3635
|
numeric_fused_head.py
ADDED
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
"""NFH: Numeric Fused-Heads."""
|
16 |
+
|
17 |
+
from __future__ import absolute_import, division, print_function
|
18 |
+
|
19 |
+
import csv
|
20 |
+
import json
|
21 |
+
|
22 |
+
import datasets
|
23 |
+
|
24 |
+
|
25 |
+
_CITATION = """\
|
26 |
+
@article{elazar_head,
|
27 |
+
author = {Elazar, Yanai and Goldberg, Yoav},
|
28 |
+
title = {Where’s My Head? Definition, Data Set, and Models for Numeric Fused-Head Identification and Resolution},
|
29 |
+
journal = {Transactions of the Association for Computational Linguistics},
|
30 |
+
volume = {7},
|
31 |
+
number = {},
|
32 |
+
pages = {519-535},
|
33 |
+
year = {2019},
|
34 |
+
doi = {10.1162/tacl\\_a\\_00280},
|
35 |
+
URL = {https://doi.org/10.1162/tacl_a_00280},
|
36 |
+
}
|
37 |
+
"""
|
38 |
+
|
39 |
+
_DESCRIPTION = """\
|
40 |
+
Fused Head constructions are noun phrases in which the head noun is \
|
41 |
+
missing and is said to be "fused" with its dependent modifier. This \
|
42 |
+
missing information is implicit and is important for sentence understanding.\
|
43 |
+
The missing heads are easily filled in by humans, but pose a challenge for \
|
44 |
+
computational models.
|
45 |
+
|
46 |
+
For example, in the sentence: "I bought 5 apples but got only 4.", 4 is a \
|
47 |
+
Fused-Head, and the missing head is apples, which appear earlier in the sentence.
|
48 |
+
|
49 |
+
This is a crowd-sourced dataset of 10k numerical fused head examples (1M tokens).
|
50 |
+
"""
|
51 |
+
|
52 |
+
_HOMEPAGE = "https://nlp.biu.ac.il/~lazary/fh/"
|
53 |
+
|
54 |
+
_LICENSE = "MIT"
|
55 |
+
|
56 |
+
_URLs = {
|
57 |
+
"identification": {
|
58 |
+
"train": "https://raw.githubusercontent.com/yanaiela/num_fh/master/data/identification/processed/train.tsv",
|
59 |
+
"test": "https://raw.githubusercontent.com/yanaiela/num_fh/master/data/identification/processed/test.tsv",
|
60 |
+
"dev": "https://raw.githubusercontent.com/yanaiela/num_fh/master/data/identification/processed/dev.tsv",
|
61 |
+
},
|
62 |
+
"resolution": {
|
63 |
+
"train": "https://raw.githubusercontent.com/yanaiela/num_fh/master/data/resolution/processed/nfh_train.jsonl",
|
64 |
+
"test": "https://raw.githubusercontent.com/yanaiela/num_fh/master/data/resolution/processed/nfh_test.jsonl",
|
65 |
+
"dev": "https://raw.githubusercontent.com/yanaiela/num_fh/master/data/resolution/processed/nfh_dev.jsonl",
|
66 |
+
},
|
67 |
+
}
|
68 |
+
|
69 |
+
|
70 |
+
class NumericFusedHead(datasets.GeneratorBasedBuilder):
|
71 |
+
"""NFH: Numeric Fused-Heads"""
|
72 |
+
|
73 |
+
VERSION = datasets.Version("1.0.0")
|
74 |
+
|
75 |
+
BUILDER_CONFIGS = [
|
76 |
+
datasets.BuilderConfig(name="identification", description="Identify NFH anchors in a sentence"),
|
77 |
+
datasets.BuilderConfig(name="resolution", description="Identify the head for the numeric anchor"),
|
78 |
+
]
|
79 |
+
|
80 |
+
def _info(self):
|
81 |
+
if self.config.name == "identification":
|
82 |
+
features = datasets.Features(
|
83 |
+
{
|
84 |
+
"tokens": datasets.Sequence(datasets.Value("string")),
|
85 |
+
"start_index": datasets.Value("int32"),
|
86 |
+
"end_index": datasets.Value("int32"),
|
87 |
+
"label": datasets.features.ClassLabel(names=["neg", "pos"]),
|
88 |
+
}
|
89 |
+
)
|
90 |
+
else:
|
91 |
+
features = datasets.Features(
|
92 |
+
{
|
93 |
+
"tokens": datasets.Sequence(datasets.Value("string")),
|
94 |
+
"line_indices": datasets.Sequence(datasets.Value("int32")),
|
95 |
+
"head": datasets.Sequence(datasets.Value("string")),
|
96 |
+
"speakers": datasets.Sequence(datasets.Value("string")),
|
97 |
+
"anchors_indices": datasets.Sequence(datasets.Value("int32")),
|
98 |
+
}
|
99 |
+
)
|
100 |
+
|
101 |
+
return datasets.DatasetInfo(
|
102 |
+
description=_DESCRIPTION,
|
103 |
+
features=features,
|
104 |
+
supervised_keys=None,
|
105 |
+
homepage=_HOMEPAGE,
|
106 |
+
license=_LICENSE,
|
107 |
+
citation=_CITATION,
|
108 |
+
)
|
109 |
+
|
110 |
+
def _split_generators(self, dl_manager):
|
111 |
+
"""Returns SplitGenerators."""
|
112 |
+
data_files = dl_manager.download_and_extract(_URLs[self.config.name])
|
113 |
+
return [
|
114 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": data_files["train"]}),
|
115 |
+
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": data_files["test"]}),
|
116 |
+
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": data_files["dev"]}),
|
117 |
+
]
|
118 |
+
|
119 |
+
def _generate_examples(self, filepath):
|
120 |
+
""" Yields examples. """
|
121 |
+
with open(filepath, encoding="utf-8") as f:
|
122 |
+
if self.config.name == "identification":
|
123 |
+
r = csv.DictReader(f, delimiter="\t")
|
124 |
+
for id_, row in enumerate(r):
|
125 |
+
data = {
|
126 |
+
"tokens": row["text"].split("_SEP_"),
|
127 |
+
"start_index": row["ind_s"],
|
128 |
+
"end_index": row["ind_e"],
|
129 |
+
"label": "neg" if row["y"] == "0" else "pos",
|
130 |
+
}
|
131 |
+
yield id_, data
|
132 |
+
else:
|
133 |
+
for id_, row in enumerate(f):
|
134 |
+
data = json.loads(row)
|
135 |
+
yield id_, {
|
136 |
+
"tokens": data["tokens"],
|
137 |
+
"line_indices": data["line_indices"],
|
138 |
+
"head": [str(s) for s in data["head"]],
|
139 |
+
"speakers": [str(s) for s in data["speakers"]],
|
140 |
+
"anchors_indices": data["anchors_indices"],
|
141 |
+
}
|