Datasets:
Tasks:
Multiple Choice
Sub-tasks:
multiple-choice-coreference-resolution
Languages:
English
Size:
n<1K
License:
Commit
•
a297ef1
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 +206 -0
- dataset_infos.json +1 -0
- dummy/wsc273/0.0.0/dummy_data.zip +3 -0
- dummy/wsc285/0.0.0/dummy_data.zip +3 -0
- winograd_wsc.py +134 -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,206 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
annotations_creators:
|
3 |
+
- expert-generated
|
4 |
+
language_creators:
|
5 |
+
- expert-generated
|
6 |
+
languages:
|
7 |
+
- en
|
8 |
+
licenses:
|
9 |
+
- cc-by-4-0
|
10 |
+
multilinguality:
|
11 |
+
- monolingual
|
12 |
+
size_categories:
|
13 |
+
- n<1K
|
14 |
+
source_datasets:
|
15 |
+
- original
|
16 |
+
task_categories:
|
17 |
+
- structure-prediction
|
18 |
+
task_ids:
|
19 |
+
- coreference-resolution
|
20 |
+
---
|
21 |
+
|
22 |
+
# Dataset Card for The Winograd Schema Challenge
|
23 |
+
|
24 |
+
## Table of Contents
|
25 |
+
- [Dataset Description](#dataset-description)
|
26 |
+
- [Dataset Summary](#dataset-summary)
|
27 |
+
- [Supported Tasks](#supported-tasks-and-leaderboards)
|
28 |
+
- [Languages](#languages)
|
29 |
+
- [Dataset Structure](#dataset-structure)
|
30 |
+
- [Data Instances](#data-instances)
|
31 |
+
- [Data Fields](#data-instances)
|
32 |
+
- [Data Splits](#data-instances)
|
33 |
+
- [Dataset Creation](#dataset-creation)
|
34 |
+
- [Curation Rationale](#curation-rationale)
|
35 |
+
- [Source Data](#source-data)
|
36 |
+
- [Annotations](#annotations)
|
37 |
+
- [Personal and Sensitive Information](#personal-and-sensitive-information)
|
38 |
+
- [Considerations for Using the Data](#considerations-for-using-the-data)
|
39 |
+
- [Social Impact of Dataset](#social-impact-of-dataset)
|
40 |
+
- [Discussion of Biases](#discussion-of-biases)
|
41 |
+
- [Other Known Limitations](#other-known-limitations)
|
42 |
+
- [Additional Information](#additional-information)
|
43 |
+
- [Dataset Curators](#dataset-curators)
|
44 |
+
- [Licensing Information](#licensing-information)
|
45 |
+
- [Citation Information](#citation-information)
|
46 |
+
|
47 |
+
## Dataset Description
|
48 |
+
|
49 |
+
- **Homepage:** https://cs.nyu.edu/faculty/davise/papers/WinogradSchemas/WS.html
|
50 |
+
- **Repository:**
|
51 |
+
- **Paper:** https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.729.9814&rep=rep1&type=pdf
|
52 |
+
- **Leaderboard:**
|
53 |
+
- **Point of Contact:**
|
54 |
+
|
55 |
+
### Dataset Summary
|
56 |
+
|
57 |
+
A Winograd schema is a pair of sentences that differ in only one or two words and that contain an ambiguity that is
|
58 |
+
resolved in opposite ways in the two sentences and requires the use of world knowledge and reasoning for its
|
59 |
+
resolution. The schema takes its name from a well-known example by Terry Winograd:
|
60 |
+
|
61 |
+
> The city councilmen refused the demonstrators a permit because they [feared/advocated] violence.
|
62 |
+
|
63 |
+
If the word is ``feared'', then ``they'' presumably refers to the city council; if it is ``advocated'' then ``they''
|
64 |
+
presumably refers to the demonstrators.
|
65 |
+
|
66 |
+
### Supported Tasks and Leaderboards
|
67 |
+
|
68 |
+
From the official webpage:
|
69 |
+
|
70 |
+
> A contest, entitled the Winograd Schema Challenge was run once, in 2016. At that time, there was a cash prize
|
71 |
+
offered for achieving human-level performance in the contest. Since then, the sponsor has withdrawn; therefore NO
|
72 |
+
CASH PRIZES CAN BE OFFERED OR WILL BE AWARDED FOR ANY KIND OF PERFORMANCE OR ACHIEVEMENT ON THIS CHALLENGE.
|
73 |
+
|
74 |
+
### Languages
|
75 |
+
|
76 |
+
The dataset is in English.
|
77 |
+
|
78 |
+
[Translation of 12 WSs into Chinese ](https://cs.nyu.edu/faculty/davise/papers/WinogradSchemas/WSChinese.html)(translated by Wei Xu).
|
79 |
+
|
80 |
+
Translations into Japanese, by Soichiro Tanaka, Rafal Rzepka, and Shiho Katajima\
|
81 |
+
**Translation changing English names to Japanese **[PDF ](https://cs.nyu.edu/faculty/davise/papers/WinogradSchemas/collection_ja.pdf) [HTML](http://arakilab.media.eng.hokudai.ac.jp/~kabura/collection_ja.html)\
|
82 |
+
**Translation preserving English names** [PDF ](https://cs.nyu.edu/faculty/davise/papers/WinogradSchemas/collection_katakana.pdf) [HTML](http://arakilab.media.eng.hokudai.ac.jp/~kabura/collection_katakana.html)
|
83 |
+
|
84 |
+
[Translation into French, ](http://www.llf.cnrs.fr/winograd-fr)by Pascal Amsili and Olga Seminck
|
85 |
+
|
86 |
+
[Winograd Schemas in Portuguese](https://sol.sbc.org.br/index.php/eniac/article/view/9334) by Gabriela Melo, Vinicius Imaizumi, and Fábio Cozman.
|
87 |
+
|
88 |
+
[Mandarinograd: A Chinese Collection of Winograd Schemas](https://www.aclweb.org/anthology/2020.lrec-1.3) by Timothée Bernard and Ting Han, LREC-2020.
|
89 |
+
|
90 |
+
## Dataset Structure
|
91 |
+
|
92 |
+
### Data Instances
|
93 |
+
|
94 |
+
Each instance contains a text passage with a designated pronoun and two possible answers indicating which entity in
|
95 |
+
the passage the pronoun represents. An example instance looks like the following:
|
96 |
+
|
97 |
+
```python
|
98 |
+
{
|
99 |
+
'label': 0,
|
100 |
+
'options': ['The city councilmen', 'The demonstrators'],
|
101 |
+
'pronoun': 'they',
|
102 |
+
'pronoun_loc': 63,
|
103 |
+
'quote': 'they feared violence',
|
104 |
+
'quote_loc': 63,
|
105 |
+
'source': '(Winograd 1972)',
|
106 |
+
'text': 'The city councilmen refused the demonstrators a permit because they feared violence.'
|
107 |
+
}
|
108 |
+
```
|
109 |
+
|
110 |
+
### Data Fields
|
111 |
+
|
112 |
+
- `text` (str): The text sequence
|
113 |
+
- `options` (list[str]): The two entity options that the pronoun may be referring to
|
114 |
+
- `label` (int): The index of the correct option in the `options` field
|
115 |
+
- `pronoun` (str): The pronoun in the sequence to be resolved
|
116 |
+
- `pronoun_loc` (int): The starting position of the pronoun in the sequence
|
117 |
+
- `quote` (str): The substr with the key action or context surrounding the pronoun
|
118 |
+
- `quote_loc` (int): The starting position of the quote in the sequence
|
119 |
+
- `source` (str): A description of the source who contributed the example
|
120 |
+
|
121 |
+
### Data Splits
|
122 |
+
|
123 |
+
Only a test split is included.
|
124 |
+
|
125 |
+
## Dataset Creation
|
126 |
+
|
127 |
+
### Curation Rationale
|
128 |
+
|
129 |
+
The Winograd Schema Challenge was proposed as an automated evaluation of an AI system's commonsense linguistic
|
130 |
+
understanding. From the webpage:
|
131 |
+
|
132 |
+
> The strengths of the challenge are that it is clear-cut, in that the answer to each schema is a binary choice;
|
133 |
+
vivid, in that it is obvious to non-experts that a program that fails to get the right answers clearly has serious
|
134 |
+
gaps in its understanding; and difficult, in that it is far beyond the current state of the art.
|
135 |
+
|
136 |
+
### Source Data
|
137 |
+
|
138 |
+
#### Initial Data Collection and Normalization
|
139 |
+
|
140 |
+
This data was manually written by experts such that the schemas are:
|
141 |
+
|
142 |
+
- easily disambiguated by the human reader (ideally, so easily that the reader does not even notice that there is an ambiguity);
|
143 |
+
|
144 |
+
- not solvable by simple techniques such as selectional restrictions;
|
145 |
+
|
146 |
+
- Google-proof; that is, there is no obvious statistical test over text corpora that will reliably disambiguate these correctly.
|
147 |
+
|
148 |
+
#### Who are the source language producers?
|
149 |
+
|
150 |
+
This dataset has grown over time, and so was produced by a variety of lingustic and AI researchers. See the `source`
|
151 |
+
field for the source of each instance.
|
152 |
+
|
153 |
+
### Annotations
|
154 |
+
|
155 |
+
#### Annotation process
|
156 |
+
|
157 |
+
Annotations are produced by the experts who construct the examples.
|
158 |
+
|
159 |
+
#### Who are the annotators?
|
160 |
+
|
161 |
+
See above.
|
162 |
+
|
163 |
+
### Personal and Sensitive Information
|
164 |
+
|
165 |
+
[More Information Needed]
|
166 |
+
|
167 |
+
## Considerations for Using the Data
|
168 |
+
|
169 |
+
### Social Impact of Dataset
|
170 |
+
|
171 |
+
[More Information Needed]
|
172 |
+
|
173 |
+
### Discussion of Biases
|
174 |
+
|
175 |
+
[More Information Needed]
|
176 |
+
|
177 |
+
### Other Known Limitations
|
178 |
+
|
179 |
+
[More Information Needed]
|
180 |
+
|
181 |
+
## Additional Information
|
182 |
+
|
183 |
+
### Dataset Curators
|
184 |
+
|
185 |
+
This dataset has grown over time, and so was produced by a variety of lingustic and AI researchers. See the `source`
|
186 |
+
field for the source of each instance.
|
187 |
+
|
188 |
+
### Licensing Information
|
189 |
+
|
190 |
+
This work is licensed under a [Creative Commons Attribution 4.0 International
|
191 |
+
License](https://creativecommons.org/licenses/by/4.0/).
|
192 |
+
|
193 |
+
### Citation Information
|
194 |
+
|
195 |
+
The Winograd Schema Challenge including many of the examples here was proposed by
|
196 |
+
[Levesque et al 2012](https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.729.9814&rep=rep1&type=pdf):
|
197 |
+
|
198 |
+
```
|
199 |
+
@inproceedings{levesque2012winograd,
|
200 |
+
title={The winograd schema challenge},
|
201 |
+
author={Levesque, Hector and Davis, Ernest and Morgenstern, Leora},
|
202 |
+
booktitle={Thirteenth International Conference on the Principles of Knowledge Representation and Reasoning},
|
203 |
+
year={2012},
|
204 |
+
organization={Citeseer}
|
205 |
+
}
|
206 |
+
```
|
dataset_infos.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"wsc285": {"description": "A Winograd schema is a pair of sentences that differ in only one or two words and that contain an ambiguity that is\nresolved in opposite ways in the two sentences and requires the use of world knowledge and reasoning for its\nresolution. The schema takes its name from a well-known example by Terry Winograd:\n\n> The city councilmen refused the demonstrators a permit because they [feared/advocated] violence.\n\nIf the word is ``feared'', then ``they'' presumably refers to the city council; if it is ``advocated'' then ``they''\npresumably refers to the demonstrators.\n", "citation": "@inproceedings{levesque2012winograd,\n title={The winograd schema challenge},\n author={Levesque, Hector and Davis, Ernest and Morgenstern, Leora},\n booktitle={Thirteenth International Conference on the Principles of Knowledge Representation and Reasoning},\n year={2012},\n organization={Citeseer}\n}\n", "homepage": "https://cs.nyu.edu/faculty/davise/papers/WinogradSchemas/WS.html", "license": "", "features": {"text": {"dtype": "string", "id": null, "_type": "Value"}, "pronoun": {"dtype": "string", "id": null, "_type": "Value"}, "pronoun_loc": {"dtype": "int32", "id": null, "_type": "Value"}, "quote": {"dtype": "string", "id": null, "_type": "Value"}, "quote_loc": {"dtype": "int32", "id": null, "_type": "Value"}, "options": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "label": {"num_classes": 2, "names": ["0", "1"], "names_file": null, "id": null, "_type": "ClassLabel"}, "source": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "builder_name": "winograd_wsc", "config_name": "wsc285", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"test": {"name": "test", "num_bytes": 52281, "num_examples": 285, "dataset_name": "winograd_wsc"}}, "download_checksums": {"https://cs.nyu.edu/faculty/davise/papers/WinogradSchemas/WSCollection.xml": {"num_bytes": 113235, "checksum": "98c845a5b33c109f2c49742e726fac592bbb1fdc3b3706b604de12f9c9f58c91"}}, "download_size": 113235, "post_processing_size": null, "dataset_size": 52281, "size_in_bytes": 165516}, "wsc273": {"description": "A Winograd schema is a pair of sentences that differ in only one or two words and that contain an ambiguity that is\nresolved in opposite ways in the two sentences and requires the use of world knowledge and reasoning for its\nresolution. The schema takes its name from a well-known example by Terry Winograd:\n\n> The city councilmen refused the demonstrators a permit because they [feared/advocated] violence.\n\nIf the word is ``feared'', then ``they'' presumably refers to the city council; if it is ``advocated'' then ``they''\npresumably refers to the demonstrators.\n", "citation": "@inproceedings{levesque2012winograd,\n title={The winograd schema challenge},\n author={Levesque, Hector and Davis, Ernest and Morgenstern, Leora},\n booktitle={Thirteenth International Conference on the Principles of Knowledge Representation and Reasoning},\n year={2012},\n organization={Citeseer}\n}\n", "homepage": "https://cs.nyu.edu/faculty/davise/papers/WinogradSchemas/WS.html", "license": "", "features": {"text": {"dtype": "string", "id": null, "_type": "Value"}, "pronoun": {"dtype": "string", "id": null, "_type": "Value"}, "pronoun_loc": {"dtype": "int32", "id": null, "_type": "Value"}, "quote": {"dtype": "string", "id": null, "_type": "Value"}, "quote_loc": {"dtype": "int32", "id": null, "_type": "Value"}, "options": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "label": {"num_classes": 2, "names": ["0", "1"], "names_file": null, "id": null, "_type": "ClassLabel"}, "source": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "builder_name": "winograd_wsc", "config_name": "wsc273", "version": "0.0.0", "splits": {"test": {"name": "test", "num_bytes": 49674, "num_examples": 273, "dataset_name": "winograd_wsc"}}, "download_checksums": {"https://cs.nyu.edu/faculty/davise/papers/WinogradSchemas/WSCollection.xml": {"num_bytes": 113235, "checksum": "98c845a5b33c109f2c49742e726fac592bbb1fdc3b3706b604de12f9c9f58c91"}}, "download_size": 113235, "post_processing_size": null, "dataset_size": 49674, "size_in_bytes": 162909}}
|
dummy/wsc273/0.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9dd8e89c220245d7d350de5c82695282b799125de469511d187f96a4784f3a5f
|
3 |
+
size 672
|
dummy/wsc285/0.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9dd8e89c220245d7d350de5c82695282b799125de469511d187f96a4784f3a5f
|
3 |
+
size 672
|
winograd_wsc.py
ADDED
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2020 The HuggingFace Datasets Authors.
|
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 Winograd Schema Challenge Dataset"""
|
16 |
+
|
17 |
+
import xml.etree.ElementTree as ET
|
18 |
+
|
19 |
+
import datasets
|
20 |
+
|
21 |
+
|
22 |
+
_DESCRIPTION = """\
|
23 |
+
A Winograd schema is a pair of sentences that differ in only one or two words and that contain an ambiguity that is
|
24 |
+
resolved in opposite ways in the two sentences and requires the use of world knowledge and reasoning for its
|
25 |
+
resolution. The schema takes its name from a well-known example by Terry Winograd:
|
26 |
+
|
27 |
+
> The city councilmen refused the demonstrators a permit because they [feared/advocated] violence.
|
28 |
+
|
29 |
+
If the word is ``feared'', then ``they'' presumably refers to the city council; if it is ``advocated'' then ``they''
|
30 |
+
presumably refers to the demonstrators.
|
31 |
+
"""
|
32 |
+
|
33 |
+
_CITATION = """\
|
34 |
+
@inproceedings{levesque2012winograd,
|
35 |
+
title={The winograd schema challenge},
|
36 |
+
author={Levesque, Hector and Davis, Ernest and Morgenstern, Leora},
|
37 |
+
booktitle={Thirteenth International Conference on the Principles of Knowledge Representation and Reasoning},
|
38 |
+
year={2012},
|
39 |
+
organization={Citeseer}
|
40 |
+
}
|
41 |
+
"""
|
42 |
+
|
43 |
+
_HOMPAGE = "https://cs.nyu.edu/faculty/davise/papers/WinogradSchemas/WS.html"
|
44 |
+
_DOWNLOAD_URL = "https://cs.nyu.edu/faculty/davise/papers/WinogradSchemas/WSCollection.xml"
|
45 |
+
|
46 |
+
|
47 |
+
class WinogradWSCConfig(datasets.BuilderConfig):
|
48 |
+
""" BuilderConfig for WinogradWSC. """
|
49 |
+
|
50 |
+
def __init__(self, *args, language=None, inds=None, **kwargs):
|
51 |
+
super().__init__(*args, **kwargs)
|
52 |
+
self.inds = set(inds) if inds is not None else None
|
53 |
+
|
54 |
+
def is_in_range(self, id):
|
55 |
+
""" Takes an index and tells you if it belongs to the configuration's subset """
|
56 |
+
return id in self.inds if self.inds is not None else True
|
57 |
+
|
58 |
+
|
59 |
+
class WinogradWSC(datasets.GeneratorBasedBuilder):
|
60 |
+
""" The Winograd Schema Challenge Dataset """
|
61 |
+
|
62 |
+
BUILDER_CONFIG_CLASS = WinogradWSCConfig
|
63 |
+
BUILDER_CONFIGS = [
|
64 |
+
WinogradWSCConfig(
|
65 |
+
name="wsc285",
|
66 |
+
description="Full set of winograd examples",
|
67 |
+
),
|
68 |
+
WinogradWSCConfig(
|
69 |
+
name="wsc273",
|
70 |
+
description="A commonly-used subset of examples. Identical to 'wsc285' but without the last 12 examples.",
|
71 |
+
inds=list(range(273)),
|
72 |
+
),
|
73 |
+
]
|
74 |
+
|
75 |
+
def _info(self):
|
76 |
+
return datasets.DatasetInfo(
|
77 |
+
description=_DESCRIPTION,
|
78 |
+
features=datasets.Features(
|
79 |
+
{
|
80 |
+
"text": datasets.Value("string"),
|
81 |
+
"pronoun": datasets.Value("string"),
|
82 |
+
"pronoun_loc": datasets.Value("int32"),
|
83 |
+
"quote": datasets.Value("string"),
|
84 |
+
"quote_loc": datasets.Value("int32"),
|
85 |
+
"options": datasets.Sequence(datasets.Value("string")),
|
86 |
+
"label": datasets.ClassLabel(num_classes=2),
|
87 |
+
"source": datasets.Value("string"),
|
88 |
+
}
|
89 |
+
),
|
90 |
+
homepage=_HOMPAGE,
|
91 |
+
citation=_CITATION,
|
92 |
+
)
|
93 |
+
|
94 |
+
def _split_generators(self, dl_manager):
|
95 |
+
path = dl_manager.download_and_extract(_DOWNLOAD_URL)
|
96 |
+
return [
|
97 |
+
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": path}),
|
98 |
+
]
|
99 |
+
|
100 |
+
def _cleanup_whitespace(self, text):
|
101 |
+
return " ".join(text.split())
|
102 |
+
|
103 |
+
def _generate_examples(self, filepath):
|
104 |
+
tree = ET.parse(filepath)
|
105 |
+
for id, schema in enumerate(tree.getroot()):
|
106 |
+
if not self.config.is_in_range(id):
|
107 |
+
continue
|
108 |
+
|
109 |
+
text_root = schema.find("text")
|
110 |
+
quote_root = schema.find("quote")
|
111 |
+
|
112 |
+
text_left = self._cleanup_whitespace(text_root.findtext("txt1", ""))
|
113 |
+
text_right = self._cleanup_whitespace(text_root.findtext("txt2", ""))
|
114 |
+
quote_left = self._cleanup_whitespace(quote_root.findtext("quote1", ""))
|
115 |
+
quote_right = self._cleanup_whitespace(quote_root.findtext("quote2", ""))
|
116 |
+
pronoun = self._cleanup_whitespace(text_root.findtext("pron"))
|
117 |
+
|
118 |
+
features = {}
|
119 |
+
features["text"] = " ".join([text_left, pronoun, text_right]).strip()
|
120 |
+
features["quote"] = " ".join([quote_left, pronoun, quote_right]).strip()
|
121 |
+
|
122 |
+
features["pronoun"] = pronoun
|
123 |
+
features["options"] = [
|
124 |
+
self._cleanup_whitespace(option.text) for option in schema.find("answers").findall("answer")
|
125 |
+
]
|
126 |
+
|
127 |
+
answer_txt = self._cleanup_whitespace(schema.findtext("correctAnswer"))
|
128 |
+
features["label"] = int("B" in answer_txt) # convert " A. " or " B " strings to a 0/1 index
|
129 |
+
|
130 |
+
features["pronoun_loc"] = len(text_left) + 1 if len(text_left) > 0 else 0
|
131 |
+
features["quote_loc"] = features["pronoun_loc"] - (len(quote_left) + 1 if len(quote_left) > 0 else 0)
|
132 |
+
features["source"] = self._cleanup_whitespace(schema.findtext("source"))
|
133 |
+
|
134 |
+
yield id, features
|