Datasets:
Size:
10K - 100K
License:
:sparkles: Add jsick.py
Browse files- jsick.py +137 -0
- poetry.lock +0 -0
- pyproject.toml +23 -0
jsick.py
ADDED
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import datasets as ds
|
2 |
+
import pandas as pd
|
3 |
+
|
4 |
+
_CITATION = """\
|
5 |
+
@article{yanaka-mineshima-2022-compositional,
|
6 |
+
title = "Compositional Evaluation on {J}apanese Textual Entailment and Similarity",
|
7 |
+
author = "Yanaka, Hitomi and Mineshima, Koji",
|
8 |
+
journal = "Transactions of the Association for Computational Linguistics",
|
9 |
+
volume = "10",
|
10 |
+
year = "2022",
|
11 |
+
address = "Cambridge, MA",
|
12 |
+
publisher = "MIT Press",
|
13 |
+
url = "https://aclanthology.org/2022.tacl-1.73",
|
14 |
+
doi = "10.1162/tacl_a_00518",
|
15 |
+
pages = "1266--1284",
|
16 |
+
}
|
17 |
+
"""
|
18 |
+
|
19 |
+
_DESCRIPTION = """\
|
20 |
+
|
21 |
+
"""
|
22 |
+
|
23 |
+
_HOMEPAGE = "https://github.com/verypluming/JSICK"
|
24 |
+
|
25 |
+
_LICENSE = "CC BY-SA 4.0"
|
26 |
+
|
27 |
+
_URLS = {
|
28 |
+
"base": "https://raw.githubusercontent.com/verypluming/JSICK/main/jsick/jsick.tsv",
|
29 |
+
"stress": "https://raw.githubusercontent.com/verypluming/JSICK/main/jsick-stress/jsick-stress-all-annotations.tsv",
|
30 |
+
}
|
31 |
+
|
32 |
+
|
33 |
+
class JSICKDataset(ds.GeneratorBasedBuilder):
|
34 |
+
VERSION = ds.Version("1.0.0")
|
35 |
+
DEFAULT_CONFIG_NAME = "base"
|
36 |
+
|
37 |
+
BUILDER_CONFIGS = [
|
38 |
+
ds.BuilderConfig(
|
39 |
+
name="base",
|
40 |
+
version=VERSION,
|
41 |
+
description="hoge",
|
42 |
+
),
|
43 |
+
ds.BuilderConfig(
|
44 |
+
name="stress",
|
45 |
+
version=VERSION,
|
46 |
+
description="fuga",
|
47 |
+
),
|
48 |
+
]
|
49 |
+
|
50 |
+
def _info(self) -> ds.DatasetInfo:
|
51 |
+
labels = ds.ClassLabel(names=["entailment", "neutral", "contradiction"])
|
52 |
+
if self.config.name == "base":
|
53 |
+
features = ds.Features(
|
54 |
+
{
|
55 |
+
"pair_ID": ds.Value("int32"),
|
56 |
+
"sentence_A_Ja": ds.Value("string"),
|
57 |
+
"sentence_B_Ja": ds.Value("string"),
|
58 |
+
"entailment_label_Ja": labels,
|
59 |
+
"relatedness_score_Ja": ds.Value("float32"),
|
60 |
+
"sentence_A_En": ds.Value("string"),
|
61 |
+
"sentence_B_En": ds.Value("string"),
|
62 |
+
"entailment_label_En": labels,
|
63 |
+
"relatedness_score_En": ds.Value("float32"),
|
64 |
+
"corr_entailment_labelAB_En": ds.Value("string"),
|
65 |
+
"corr_entailment_labelBA_En": ds.Value("string"),
|
66 |
+
"image_ID": ds.Value("string"),
|
67 |
+
"original_caption": ds.Value("string"),
|
68 |
+
"semtag_short": ds.Value("string"),
|
69 |
+
"semtag_long": ds.Value("string"),
|
70 |
+
}
|
71 |
+
)
|
72 |
+
|
73 |
+
elif self.config.name == "stress":
|
74 |
+
features = ds.Features(
|
75 |
+
{
|
76 |
+
"pair_ID": ds.Value("string"),
|
77 |
+
"sentence_A_Ja": ds.Value("string"),
|
78 |
+
"sentence_B_Ja": ds.Value("string"),
|
79 |
+
"entailment_label_Ja": labels,
|
80 |
+
"relatedness_score_Ja": ds.Value("float32"),
|
81 |
+
"sentence_A_Ja_origin": ds.Value("string"),
|
82 |
+
"entailment_label_origin": labels,
|
83 |
+
"relatedness_score_Ja_origin": ds.Value("float32"),
|
84 |
+
"rephrase_type": ds.Value("string"),
|
85 |
+
"case_particles": ds.Value("string"),
|
86 |
+
}
|
87 |
+
)
|
88 |
+
|
89 |
+
return ds.DatasetInfo(
|
90 |
+
description=_DESCRIPTION,
|
91 |
+
citation=_CITATION,
|
92 |
+
homepage=_HOMEPAGE,
|
93 |
+
license=_LICENSE,
|
94 |
+
features=features,
|
95 |
+
)
|
96 |
+
|
97 |
+
def _split_generators(self, dl_manager: ds.DownloadManager):
|
98 |
+
data_path = dl_manager.download_and_extract(_URLS[self.config.name])
|
99 |
+
df: pd.DataFrame = pd.read_table(data_path, sep="\t", header=0)
|
100 |
+
|
101 |
+
if self.config.name == "base":
|
102 |
+
return [
|
103 |
+
ds.SplitGenerator(
|
104 |
+
name=ds.Split.TRAIN,
|
105 |
+
gen_kwargs={"df": df[df["data"] == "train"].drop("data", axis=1)},
|
106 |
+
),
|
107 |
+
ds.SplitGenerator(
|
108 |
+
name=ds.Split.TEST,
|
109 |
+
gen_kwargs={"df": df[df["data"] == "test"].drop("data", axis=1)},
|
110 |
+
),
|
111 |
+
]
|
112 |
+
|
113 |
+
elif self.config.name == "stress":
|
114 |
+
df = df[
|
115 |
+
[
|
116 |
+
"pair_ID",
|
117 |
+
"sentence_A_Ja",
|
118 |
+
"sentence_B_Ja",
|
119 |
+
"entailment_label_Ja",
|
120 |
+
"relatedness_score_Ja",
|
121 |
+
"sentence_A_Ja_origin",
|
122 |
+
"entailment_label_origin",
|
123 |
+
"relatedness_score_Ja_origin",
|
124 |
+
"rephrase_type",
|
125 |
+
"case_particles",
|
126 |
+
]
|
127 |
+
]
|
128 |
+
return [
|
129 |
+
ds.SplitGenerator(
|
130 |
+
name=ds.Split.TEST,
|
131 |
+
gen_kwargs={"df": df},
|
132 |
+
),
|
133 |
+
]
|
134 |
+
|
135 |
+
def _generate_examples(self, df: pd.DataFrame):
|
136 |
+
for i, row in enumerate(df.to_dict("records")):
|
137 |
+
yield i, row
|
poetry.lock
ADDED
The diff for this file is too large to render.
See raw diff
|
|
pyproject.toml
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[tool.poetry]
|
2 |
+
name = "datasets-jsick"
|
3 |
+
version = "0.1.0"
|
4 |
+
description = ""
|
5 |
+
authors = ["hppRC <hpp.ricecake@gmail.com>"]
|
6 |
+
readme = "README.md"
|
7 |
+
packages = []
|
8 |
+
|
9 |
+
[tool.poetry.dependencies]
|
10 |
+
python = "^3.8.1"
|
11 |
+
datasets = "^2.11.0"
|
12 |
+
|
13 |
+
|
14 |
+
[tool.poetry.group.dev.dependencies]
|
15 |
+
black = "^22.12.0"
|
16 |
+
isort = "^5.11.4"
|
17 |
+
flake8 = "^6.0.0"
|
18 |
+
mypy = "^0.991"
|
19 |
+
pytest = "^7.2.0"
|
20 |
+
|
21 |
+
[build-system]
|
22 |
+
requires = ["poetry-core"]
|
23 |
+
build-backend = "poetry.core.masonry.api"
|