SaylorTwift HF Staff commited on
Commit
5df8523
·
verified ·
1 Parent(s): 5d9774a

Convert dataset to Parquet (#1)

Browse files

- Convert dataset to Parquet (dede54fde0e0d2c51697a0dfc66556f27acc71d3)
- Add 'wsc273' config data files (16a88d0c8bee6f44eee3f255081d70c40f7c1277)
- Delete loading script (47a428443845068fcd66d01fd06b274c2627bba7)

README.md CHANGED
@@ -20,7 +20,7 @@ task_ids:
20
  paperswithcode_id: wsc
21
  pretty_name: Winograd Schema Challenge
22
  dataset_info:
23
- - config_name: wsc285
24
  features:
25
  - name: text
26
  dtype: string
@@ -44,11 +44,11 @@ dataset_info:
44
  dtype: string
45
  splits:
46
  - name: test
47
- num_bytes: 52281
48
- num_examples: 285
49
- download_size: 113235
50
- dataset_size: 52281
51
- - config_name: wsc273
52
  features:
53
  - name: text
54
  dtype: string
@@ -72,10 +72,19 @@ dataset_info:
72
  dtype: string
73
  splits:
74
  - name: test
75
- num_bytes: 49674
76
- num_examples: 273
77
- download_size: 113235
78
- dataset_size: 49674
 
 
 
 
 
 
 
 
 
79
  ---
80
 
81
  # Dataset Card for The Winograd Schema Challenge
 
20
  paperswithcode_id: wsc
21
  pretty_name: Winograd Schema Challenge
22
  dataset_info:
23
+ - config_name: wsc273
24
  features:
25
  - name: text
26
  dtype: string
 
44
  dtype: string
45
  splits:
46
  - name: test
47
+ num_bytes: 49650
48
+ num_examples: 273
49
+ download_size: 22842
50
+ dataset_size: 49650
51
+ - config_name: wsc285
52
  features:
53
  - name: text
54
  dtype: string
 
72
  dtype: string
73
  splits:
74
  - name: test
75
+ num_bytes: 52257
76
+ num_examples: 285
77
+ download_size: 23879
78
+ dataset_size: 52257
79
+ configs:
80
+ - config_name: wsc273
81
+ data_files:
82
+ - split: test
83
+ path: wsc273/test-*
84
+ - config_name: wsc285
85
+ data_files:
86
+ - split: test
87
+ path: wsc285/test-*
88
  ---
89
 
90
  # Dataset Card for The Winograd Schema Challenge
winograd_wsc.py DELETED
@@ -1,134 +0,0 @@
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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wsc273/test-00000-of-00001.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f70b91a16b6125d56092b41e78fc585aa29e83a54fbe03877899a48599dbb6ad
3
+ size 22842
wsc285/test-00000-of-00001.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:857c76b70e9fe18fb5ed60d97da5dd543c162b85527df767bc47290e49ee557a
3
+ size 23879