Delete sts-ca.py
Browse files
sts-ca.py
DELETED
|
@@ -1,95 +0,0 @@
|
|
| 1 |
-
# Loading script for the Semantic Textual Similarity Ca dataset.
|
| 2 |
-
import datasets
|
| 3 |
-
|
| 4 |
-
logger = datasets.logging.get_logger(__name__)
|
| 5 |
-
|
| 6 |
-
_CITATION = """
|
| 7 |
-
Rodriguez-Penagos, Carlos Gerardo, Armentano-Oller, Carme, Gonzalez-Agirre, Aitor, & Gibert Bonet, Ona. (2021).
|
| 8 |
-
Semantic Textual Similarity in Catalan (Version 1.0.1) [Data set].
|
| 9 |
-
Zenodo. http://doi.org/10.5281/zenodo.4761434
|
| 10 |
-
"""
|
| 11 |
-
|
| 12 |
-
_DESCRIPTION = """
|
| 13 |
-
Semantic Textual Similarity in Catalan.
|
| 14 |
-
STS corpus is a benchmark for evaluating Semantic Text Similarity in Catalan.
|
| 15 |
-
It consists of more than 3000 sentence pairs, annotated with the semantic similarity between them,
|
| 16 |
-
using a scale from 0 (no similarity at all) to 5 (semantic equivalence).
|
| 17 |
-
It is done manually by 4 different annotators following our guidelines based on previous work from the SemEval challenges (https://www.aclweb.org/anthology/S13-1004.pdf).
|
| 18 |
-
The source data are scraped sentences from the Catalan Textual Corpus (https://doi.org/10.5281/zenodo.4519349), used under CC-by-SA-4.0 licence (https://creativecommons.org/licenses/by-sa/4.0/). The dataset is released under the same licence.
|
| 19 |
-
This dataset was developed by BSC TeMU as part of the AINA project, and to enrich the Catalan Language Understanding Benchmark (CLUB).
|
| 20 |
-
This is the version 1.0.2 of the dataset with the complete human and automatic annotations and the analysis scripts. It also has a more accurate license.
|
| 21 |
-
This dataset can be used to build and score semantic similiarity models.
|
| 22 |
-
"""
|
| 23 |
-
|
| 24 |
-
_HOMEPAGE = """https://zenodo.org/record/4761434"""
|
| 25 |
-
|
| 26 |
-
# TODO: upload datasets to github
|
| 27 |
-
_URL = "https://huggingface.co/datasets/projecte-aina/sts-ca/resolve/main/"
|
| 28 |
-
_TRAINING_FILE = "train.tsv"
|
| 29 |
-
_DEV_FILE = "dev.tsv"
|
| 30 |
-
_TEST_FILE = "test.tsv"
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
class StsCaConfig(datasets.BuilderConfig):
|
| 34 |
-
""" Builder config for the Semantic Textual Similarity Ca dataset """
|
| 35 |
-
|
| 36 |
-
def __init__(self, **kwargs):
|
| 37 |
-
"""BuilderConfig for StsCa.
|
| 38 |
-
Args:
|
| 39 |
-
**kwargs: keyword arguments forwarded to super.
|
| 40 |
-
"""
|
| 41 |
-
super(StsCaConfig, self).__init__(**kwargs)
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
class StsCa(datasets.GeneratorBasedBuilder):
|
| 45 |
-
"""Semantic Textual Similarity Ca dataset."""
|
| 46 |
-
|
| 47 |
-
BUILDER_CONFIGS = [
|
| 48 |
-
StsCaConfig(
|
| 49 |
-
name="StsCa",
|
| 50 |
-
version=datasets.Version("1.0.2"),
|
| 51 |
-
description="Semantic Textual Similarity in catalan dataset"
|
| 52 |
-
),
|
| 53 |
-
]
|
| 54 |
-
|
| 55 |
-
def _info(self):
|
| 56 |
-
return datasets.DatasetInfo(
|
| 57 |
-
description=_DESCRIPTION,
|
| 58 |
-
features=datasets.Features(
|
| 59 |
-
{
|
| 60 |
-
"sentence1": datasets.Value("string"),
|
| 61 |
-
"sentence2": datasets.Value("string"),
|
| 62 |
-
"label": datasets.Value("float"),
|
| 63 |
-
}
|
| 64 |
-
),
|
| 65 |
-
supervised_keys=None,
|
| 66 |
-
homepage=_HOMEPAGE,
|
| 67 |
-
citation=_CITATION,
|
| 68 |
-
)
|
| 69 |
-
|
| 70 |
-
def _split_generators(self, dl_manager):
|
| 71 |
-
"""Returns SplitGenerators."""
|
| 72 |
-
urls_to_download = {
|
| 73 |
-
"train": f"{_URL}{_TRAINING_FILE}",
|
| 74 |
-
"dev": f"{_URL}{_DEV_FILE}",
|
| 75 |
-
"test": f"{_URL}{_TEST_FILE}",
|
| 76 |
-
}
|
| 77 |
-
downloaded_files = dl_manager.download_and_extract(urls_to_download)
|
| 78 |
-
|
| 79 |
-
return [
|
| 80 |
-
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
|
| 81 |
-
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["dev"]}),
|
| 82 |
-
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files["test"]}),
|
| 83 |
-
]
|
| 84 |
-
|
| 85 |
-
def _generate_examples(self, filepath):
|
| 86 |
-
""" Returns the examples in the raw text form """
|
| 87 |
-
logger.info("⏳ Generating examples from = %s", filepath)
|
| 88 |
-
with open(filepath, encoding="utf-8") as f:
|
| 89 |
-
for id_, row in enumerate(f):
|
| 90 |
-
ref, sentence1, sentence2, score = row.split('\t')
|
| 91 |
-
yield id_, {
|
| 92 |
-
"sentence1": sentence1,
|
| 93 |
-
"sentence2": sentence2,
|
| 94 |
-
"label": score,
|
| 95 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|