Datasets:
Size:
10K - 100K
License:
File size: 7,912 Bytes
cfb895b 9ae8c82 cfb895b a5902de cfb895b fd87848 9ae8c82 fd87848 cfb895b a5902de a3aff80 a5902de cfb895b fd87848 cfb895b b08cf4a cfb895b a41cc07 fd87848 a5902de a3aff80 a5902de cfb895b a41cc07 cfb895b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
import datasets as ds
import pandas as pd
_CITATION = """\
@article{yanaka-mineshima-2022-compositional,
title = "Compositional Evaluation on {J}apanese Textual Entailment and Similarity",
author = "Yanaka, Hitomi and Mineshima, Koji",
journal = "Transactions of the Association for Computational Linguistics",
volume = "10",
year = "2022",
address = "Cambridge, MA",
publisher = "MIT Press",
url = "https://aclanthology.org/2022.tacl-1.73",
doi = "10.1162/tacl_a_00518",
pages = "1266--1284",
}
"""
_DESCRIPTION = """\
Japanese Sentences Involving Compositional Knowledge (JSICK) Dataset.
JSICK is the Japanese NLI and STS dataset by manually translating the English dataset SICK (Marelli et al., 2014) into Japanese.
We hope that our dataset will be useful in research for realizing more advanced models that are capable of appropriately performing multilingual compositional inference.
(from official website)
"""
_HOMEPAGE = "https://github.com/verypluming/JSICK"
_LICENSE = "CC BY-SA 4.0"
_URLS = {
"base": "https://raw.githubusercontent.com/verypluming/JSICK/main/jsick/jsick.tsv",
"stress": "https://raw.githubusercontent.com/verypluming/JSICK/main/jsick-stress/jsick-stress-all-annotations.tsv",
}
class JSICKDataset(ds.GeneratorBasedBuilder):
VERSION = ds.Version("1.0.0")
DEFAULT_CONFIG_NAME = "base"
BUILDER_CONFIGS = [
ds.BuilderConfig(
name="base",
version=VERSION,
description="hoge",
),
ds.BuilderConfig(
name="original",
version=VERSION,
description="hoge",
),
ds.BuilderConfig(
name="stress",
version=VERSION,
description="fuga",
),
ds.BuilderConfig(
name="stress-original",
version=VERSION,
description="fuga",
),
]
def _info(self) -> ds.DatasetInfo:
labels = ds.ClassLabel(names=["entailment", "neutral", "contradiction"])
if self.config.name == "base":
features = ds.Features(
{
"id": ds.Value("int32"),
"premise": ds.Value("string"),
"hypothesis": ds.Value("string"),
"label": labels,
"score": ds.Value("float32"),
"premise_en": ds.Value("string"),
"hypothesis_en": ds.Value("string"),
"label_en": labels,
"score_en": ds.Value("float32"),
"corr_entailment_labelAB_En": ds.Value("string"),
"corr_entailment_labelBA_En": ds.Value("string"),
"image_ID": ds.Value("string"),
"original_caption": ds.Value("string"),
"semtag_short": ds.Value("string"),
"semtag_long": ds.Value("string"),
}
)
elif self.config.name == "original":
features = ds.Features(
{
"pair_ID": ds.Value("int32"),
"sentence_A_Ja": ds.Value("string"),
"sentence_B_Ja": ds.Value("string"),
"entailment_label_Ja": labels,
"relatedness_score_Ja": ds.Value("float32"),
"sentence_A_En": ds.Value("string"),
"sentence_B_En": ds.Value("string"),
"entailment_label_En": labels,
"relatedness_score_En": ds.Value("float32"),
"corr_entailment_labelAB_En": ds.Value("string"),
"corr_entailment_labelBA_En": ds.Value("string"),
"image_ID": ds.Value("string"),
"original_caption": ds.Value("string"),
"semtag_short": ds.Value("string"),
"semtag_long": ds.Value("string"),
}
)
elif self.config.name == "stress":
features = ds.Features(
{
"id": ds.Value("string"),
"premise": ds.Value("string"),
"hypothesis": ds.Value("string"),
"label": labels,
"score": ds.Value("float32"),
"sentence_A_Ja_origin": ds.Value("string"),
"entailment_label_origin": labels,
"relatedness_score_Ja_origin": ds.Value("float32"),
"rephrase_type": ds.Value("string"),
"case_particles": ds.Value("string"),
}
)
elif self.config.name == "stress_original":
features = ds.Features(
{
"pair_ID": ds.Value("string"),
"sentence_A_Ja": ds.Value("string"),
"sentence_B_Ja": ds.Value("string"),
"entailment_label_Ja": labels,
"relatedness_score_Ja": ds.Value("float32"),
"sentence_A_Ja_origin": ds.Value("string"),
"entailment_label_origin": labels,
"relatedness_score_Ja_origin": ds.Value("float32"),
"rephrase_type": ds.Value("string"),
"case_particles": ds.Value("string"),
}
)
return ds.DatasetInfo(
description=_DESCRIPTION,
citation=_CITATION,
homepage=_HOMEPAGE,
license=_LICENSE,
features=features,
)
def _split_generators(self, dl_manager: ds.DownloadManager):
if self.config.name in ["base", "original"]:
url = _URLS["base"]
elif self.config.name in ["stress", "stress_original"]:
url = _URLS["stress"]
data_path = dl_manager.download_and_extract(url)
df: pd.DataFrame = pd.read_table(data_path, sep="\t", header=0)
if self.config.name in ["stress", "stress_original"]:
df = df[
[
"pair_ID",
"sentence_A_Ja",
"sentence_B_Ja",
"entailment_label_Ja",
"relatedness_score_Ja",
"sentence_A_Ja_origin",
"entailment_label_origin",
"relatedness_score_Ja_origin",
"rephrase_type",
"case_particles",
]
]
if self.config.name in ["base", "stress"]:
df = df.rename(
columns={
"pair_ID": "id",
"sentence_A_Ja": "premise",
"sentence_B_Ja": "hypothesis",
"entailment_label_Ja": "label",
"relatedness_score_Ja": "score",
"sentence_A_En": "premise_en",
"sentence_B_En": "hypothesis_en",
"entailment_label_En": "label_en",
"relatedness_score_En": "score_en",
}
)
if self.config.name in ["base", "original"]:
return [
ds.SplitGenerator(
name=ds.Split.TRAIN,
gen_kwargs={"df": df[df["data"] == "train"].drop("data", axis=1)},
),
ds.SplitGenerator(
name=ds.Split.TEST,
gen_kwargs={"df": df[df["data"] == "test"].drop("data", axis=1)},
),
]
elif self.config.name in ["stress", "stress_original"]:
return [
ds.SplitGenerator(
name=ds.Split.TEST,
gen_kwargs={"df": df},
),
]
def _generate_examples(self, df: pd.DataFrame):
for i, row in enumerate(df.to_dict("records")):
yield i, row
|