Datasets:
Commit
•
e095b32
1
Parent(s):
a1f70da
Delete loading script
Browse files
assin2.py
DELETED
@@ -1,125 +0,0 @@
|
|
1 |
-
# coding=utf-8
|
2 |
-
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
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 |
-
"""ASSIN 2 dataset."""
|
16 |
-
|
17 |
-
|
18 |
-
import xml.etree.ElementTree as ET
|
19 |
-
|
20 |
-
import datasets
|
21 |
-
|
22 |
-
|
23 |
-
_CITATION = """
|
24 |
-
@inproceedings{real2020assin,
|
25 |
-
title={The assin 2 shared task: a quick overview},
|
26 |
-
author={Real, Livy and Fonseca, Erick and Oliveira, Hugo Goncalo},
|
27 |
-
booktitle={International Conference on Computational Processing of the Portuguese Language},
|
28 |
-
pages={406--412},
|
29 |
-
year={2020},
|
30 |
-
organization={Springer}
|
31 |
-
}
|
32 |
-
"""
|
33 |
-
|
34 |
-
_DESCRIPTION = """
|
35 |
-
The ASSIN 2 corpus is composed of rather simple sentences. Following the procedures of SemEval 2014 Task 1.
|
36 |
-
The training and validation data are composed, respectively, of 6,500 and 500 sentence pairs in Brazilian Portuguese,
|
37 |
-
annotated for entailment and semantic similarity. Semantic similarity values range from 1 to 5, and text entailment
|
38 |
-
classes are either entailment or none. The test data are composed of approximately 3,000 sentence pairs with the same
|
39 |
-
annotation. All data were manually annotated.
|
40 |
-
"""
|
41 |
-
|
42 |
-
_HOMEPAGE = "https://sites.google.com/view/assin2"
|
43 |
-
|
44 |
-
_LICENSE = ""
|
45 |
-
|
46 |
-
_URLS = {
|
47 |
-
"train": "https://github.com/ruanchaves/assin/raw/master/sources/assin2-train-only.xml",
|
48 |
-
"dev": "https://github.com/ruanchaves/assin/raw/master/sources/assin2-dev.xml",
|
49 |
-
"test": "https://github.com/ruanchaves/assin/raw/master/sources/assin2-test.xml",
|
50 |
-
}
|
51 |
-
|
52 |
-
|
53 |
-
class Assin2(datasets.GeneratorBasedBuilder):
|
54 |
-
"""ASSIN 2 dataset."""
|
55 |
-
|
56 |
-
VERSION = datasets.Version("1.0.0")
|
57 |
-
|
58 |
-
def _info(self):
|
59 |
-
features = datasets.Features(
|
60 |
-
{
|
61 |
-
"sentence_pair_id": datasets.Value("int64"),
|
62 |
-
"premise": datasets.Value("string"),
|
63 |
-
"hypothesis": datasets.Value("string"),
|
64 |
-
"relatedness_score": datasets.Value("float32"),
|
65 |
-
"entailment_judgment": datasets.features.ClassLabel(names=["NONE", "ENTAILMENT"]),
|
66 |
-
}
|
67 |
-
)
|
68 |
-
return datasets.DatasetInfo(
|
69 |
-
description=_DESCRIPTION,
|
70 |
-
features=features,
|
71 |
-
supervised_keys=None,
|
72 |
-
homepage=_HOMEPAGE,
|
73 |
-
license=_LICENSE,
|
74 |
-
citation=_CITATION,
|
75 |
-
)
|
76 |
-
|
77 |
-
def _split_generators(self, dl_manager):
|
78 |
-
"""Returns SplitGenerators."""
|
79 |
-
data_dir = dl_manager.download(_URLS)
|
80 |
-
|
81 |
-
return [
|
82 |
-
datasets.SplitGenerator(
|
83 |
-
name=datasets.Split.TRAIN,
|
84 |
-
gen_kwargs={
|
85 |
-
"filepath": data_dir["train"],
|
86 |
-
"split": "train",
|
87 |
-
},
|
88 |
-
),
|
89 |
-
datasets.SplitGenerator(
|
90 |
-
name=datasets.Split.TEST,
|
91 |
-
gen_kwargs={
|
92 |
-
"filepath": data_dir["test"],
|
93 |
-
"split": "test",
|
94 |
-
},
|
95 |
-
),
|
96 |
-
datasets.SplitGenerator(
|
97 |
-
name=datasets.Split.VALIDATION,
|
98 |
-
gen_kwargs={
|
99 |
-
"filepath": data_dir["dev"],
|
100 |
-
"split": "dev",
|
101 |
-
},
|
102 |
-
),
|
103 |
-
]
|
104 |
-
|
105 |
-
def _generate_examples(self, filepath, split):
|
106 |
-
"""Yields examples."""
|
107 |
-
|
108 |
-
id_ = 0
|
109 |
-
|
110 |
-
with open(filepath, "rb") as f:
|
111 |
-
|
112 |
-
tree = ET.parse(f)
|
113 |
-
root = tree.getroot()
|
114 |
-
|
115 |
-
for pair in root:
|
116 |
-
|
117 |
-
yield id_, {
|
118 |
-
"sentence_pair_id": int(pair.attrib.get("id")),
|
119 |
-
"premise": pair.find(".//t").text,
|
120 |
-
"hypothesis": pair.find(".//h").text,
|
121 |
-
"relatedness_score": float(pair.attrib.get("similarity")),
|
122 |
-
"entailment_judgment": pair.attrib.get("entailment").upper(),
|
123 |
-
}
|
124 |
-
|
125 |
-
id_ += 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|