Datasets:
Tasks:
Text Classification
Modalities:
Text
Formats:
parquet
Sub-tasks:
acceptability-classification
Languages:
English
Size:
10K - 100K
ArXiv:
License:
Commit
·
505f37c
1
Parent(s):
e023ea5
Delete loading script
Browse files
blimp.py
DELETED
|
@@ -1,182 +0,0 @@
|
|
| 1 |
-
# coding=utf-8
|
| 2 |
-
# Copyright 2020 The TensorFlow Datasets Authors and 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 |
-
|
| 16 |
-
# Lint as: python3
|
| 17 |
-
"""BLiMP dataset with minimal pairs of grammatical phenomena in English."""
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
import json
|
| 21 |
-
|
| 22 |
-
import datasets
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
_CITATION = """
|
| 26 |
-
@article{warstadt2019blimp,
|
| 27 |
-
title={BLiMP: A Benchmark of Linguistic Minimal Pairs for English},
|
| 28 |
-
author={Warstadt, Alex and Parrish, Alicia and Liu, Haokun and Mohananey, Anhad and Peng, Wei, and Wang, Sheng-Fu and Bowman, Samuel R},
|
| 29 |
-
journal={arXiv preprint arXiv:1912.00582},
|
| 30 |
-
year={2019}
|
| 31 |
-
}
|
| 32 |
-
"""
|
| 33 |
-
|
| 34 |
-
_DESCRIPTION = """
|
| 35 |
-
BLiMP is a challenge set for evaluating what language models (LMs) know about
|
| 36 |
-
major grammatical phenomena in English. BLiMP consists of 67 sub-datasets, each
|
| 37 |
-
containing 1000 minimal pairs isolating specific contrasts in syntax,
|
| 38 |
-
morphology, or semantics. The data is automatically generated according to
|
| 39 |
-
expert-crafted grammars.
|
| 40 |
-
"""
|
| 41 |
-
|
| 42 |
-
_PROJECT_URL = "https://github.com/alexwarstadt/blimp/tree/master/"
|
| 43 |
-
_DOWNLOAD_URL = "https://raw.githubusercontent.com/alexwarstadt/blimp/master/"
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
class BlimpConfig(datasets.BuilderConfig):
|
| 47 |
-
"""BuilderConfig for Blimp."""
|
| 48 |
-
|
| 49 |
-
def __init__(self, name, version=datasets.Version("0.1.0"), **kwargs):
|
| 50 |
-
"""BuilderConfig for Blimp.
|
| 51 |
-
|
| 52 |
-
Args:
|
| 53 |
-
name (str): UID of the linguistic paradigm
|
| 54 |
-
**kwargs: keyword arguments forwarded to super.
|
| 55 |
-
"""
|
| 56 |
-
description = _DESCRIPTION
|
| 57 |
-
description += f"This configuration includes the paradigm {name}."
|
| 58 |
-
|
| 59 |
-
super().__init__(name=name, description=description, version=version, **kwargs)
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
class Blimp(datasets.GeneratorBasedBuilder):
|
| 63 |
-
"""Minimal grammatical and ungrammatical pairs of 67 linguistic paradigms."""
|
| 64 |
-
|
| 65 |
-
all_paradigms = [
|
| 66 |
-
"adjunct_island",
|
| 67 |
-
"anaphor_gender_agreement",
|
| 68 |
-
"anaphor_number_agreement",
|
| 69 |
-
"animate_subject_passive",
|
| 70 |
-
"animate_subject_trans",
|
| 71 |
-
"causative",
|
| 72 |
-
"complex_NP_island",
|
| 73 |
-
"coordinate_structure_constraint_complex_left_branch",
|
| 74 |
-
"coordinate_structure_constraint_object_extraction",
|
| 75 |
-
"determiner_noun_agreement_1",
|
| 76 |
-
"determiner_noun_agreement_2",
|
| 77 |
-
"determiner_noun_agreement_irregular_1",
|
| 78 |
-
"determiner_noun_agreement_irregular_2",
|
| 79 |
-
"determiner_noun_agreement_with_adj_2",
|
| 80 |
-
"determiner_noun_agreement_with_adj_irregular_1",
|
| 81 |
-
"determiner_noun_agreement_with_adj_irregular_2",
|
| 82 |
-
"determiner_noun_agreement_with_adjective_1",
|
| 83 |
-
"distractor_agreement_relational_noun",
|
| 84 |
-
"distractor_agreement_relative_clause",
|
| 85 |
-
"drop_argument",
|
| 86 |
-
"ellipsis_n_bar_1",
|
| 87 |
-
"ellipsis_n_bar_2",
|
| 88 |
-
"existential_there_object_raising",
|
| 89 |
-
"existential_there_quantifiers_1",
|
| 90 |
-
"existential_there_quantifiers_2",
|
| 91 |
-
"existential_there_subject_raising",
|
| 92 |
-
"expletive_it_object_raising",
|
| 93 |
-
"inchoative",
|
| 94 |
-
"intransitive",
|
| 95 |
-
"irregular_past_participle_adjectives",
|
| 96 |
-
"irregular_past_participle_verbs",
|
| 97 |
-
"irregular_plural_subject_verb_agreement_1",
|
| 98 |
-
"irregular_plural_subject_verb_agreement_2",
|
| 99 |
-
"left_branch_island_echo_question",
|
| 100 |
-
"left_branch_island_simple_question",
|
| 101 |
-
"matrix_question_npi_licensor_present",
|
| 102 |
-
"npi_present_1",
|
| 103 |
-
"npi_present_2",
|
| 104 |
-
"only_npi_licensor_present",
|
| 105 |
-
"only_npi_scope",
|
| 106 |
-
"passive_1",
|
| 107 |
-
"passive_2",
|
| 108 |
-
"principle_A_c_command",
|
| 109 |
-
"principle_A_case_1",
|
| 110 |
-
"principle_A_case_2",
|
| 111 |
-
"principle_A_domain_1",
|
| 112 |
-
"principle_A_domain_2",
|
| 113 |
-
"principle_A_domain_3",
|
| 114 |
-
"principle_A_reconstruction",
|
| 115 |
-
"regular_plural_subject_verb_agreement_1",
|
| 116 |
-
"regular_plural_subject_verb_agreement_2",
|
| 117 |
-
"sentential_negation_npi_licensor_present",
|
| 118 |
-
"sentential_negation_npi_scope",
|
| 119 |
-
"sentential_subject_island",
|
| 120 |
-
"superlative_quantifiers_1",
|
| 121 |
-
"superlative_quantifiers_2",
|
| 122 |
-
"tough_vs_raising_1",
|
| 123 |
-
"tough_vs_raising_2",
|
| 124 |
-
"transitive",
|
| 125 |
-
"wh_island",
|
| 126 |
-
"wh_questions_object_gap",
|
| 127 |
-
"wh_questions_subject_gap",
|
| 128 |
-
"wh_questions_subject_gap_long_distance",
|
| 129 |
-
"wh_vs_that_no_gap",
|
| 130 |
-
"wh_vs_that_no_gap_long_distance",
|
| 131 |
-
"wh_vs_that_with_gap",
|
| 132 |
-
"wh_vs_that_with_gap_long_distance",
|
| 133 |
-
]
|
| 134 |
-
|
| 135 |
-
BUILDER_CONFIGS = [BlimpConfig(paradigm) for paradigm in all_paradigms]
|
| 136 |
-
|
| 137 |
-
def _info(self):
|
| 138 |
-
return datasets.DatasetInfo(
|
| 139 |
-
description=_DESCRIPTION,
|
| 140 |
-
features=datasets.Features(
|
| 141 |
-
{
|
| 142 |
-
"sentence_good": datasets.Value("string"),
|
| 143 |
-
"sentence_bad": datasets.Value("string"),
|
| 144 |
-
"field": datasets.Value("string"),
|
| 145 |
-
"linguistics_term": datasets.Value("string"),
|
| 146 |
-
"UID": datasets.Value("string"),
|
| 147 |
-
"simple_LM_method": datasets.Value("bool"),
|
| 148 |
-
"one_prefix_method": datasets.Value("bool"),
|
| 149 |
-
"two_prefix_method": datasets.Value("bool"),
|
| 150 |
-
"lexically_identical": datasets.Value("bool"),
|
| 151 |
-
"pair_id": datasets.Value("int32"),
|
| 152 |
-
}
|
| 153 |
-
),
|
| 154 |
-
homepage=_PROJECT_URL,
|
| 155 |
-
citation=_CITATION,
|
| 156 |
-
)
|
| 157 |
-
|
| 158 |
-
def _split_generators(self, dl_manager):
|
| 159 |
-
"""Returns SplitGenerators."""
|
| 160 |
-
download_urls = _DOWNLOAD_URL + f"data/{self.config.name}.jsonl"
|
| 161 |
-
downloaded_file = dl_manager.download_and_extract(download_urls)
|
| 162 |
-
return [datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_file})]
|
| 163 |
-
|
| 164 |
-
def _generate_examples(self, filepath):
|
| 165 |
-
"""Yields examples."""
|
| 166 |
-
with open(filepath, "r", encoding="utf-8") as f:
|
| 167 |
-
for line in f:
|
| 168 |
-
line_dict = json.loads(line)
|
| 169 |
-
id_ = line_dict["UID"] + "_" + line_dict["pairID"]
|
| 170 |
-
feats = {
|
| 171 |
-
"sentence_good": line_dict["sentence_good"],
|
| 172 |
-
"sentence_bad": line_dict["sentence_bad"],
|
| 173 |
-
"field": line_dict["field"],
|
| 174 |
-
"linguistics_term": line_dict["linguistics_term"],
|
| 175 |
-
"UID": line_dict["UID"],
|
| 176 |
-
"simple_LM_method": line_dict["simple_LM_method"],
|
| 177 |
-
"one_prefix_method": line_dict["one_prefix_method"],
|
| 178 |
-
"two_prefix_method": line_dict["two_prefix_method"],
|
| 179 |
-
"lexically_identical": line_dict["lexically_identical"],
|
| 180 |
-
"pair_id": int(line_dict["pairID"]),
|
| 181 |
-
}
|
| 182 |
-
yield id_, feats
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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