Matej Klemen
commited on
Commit
•
7969f2f
1
Parent(s):
51f027c
Add first version of CoSimLex
Browse files- cosimlex.py +93 -0
- dataset_infos.json +1 -0
cosimlex.py
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""CoSimLex is a resource for evaluating graded word similarity in context."""
|
2 |
+
|
3 |
+
|
4 |
+
import csv
|
5 |
+
|
6 |
+
import datasets
|
7 |
+
|
8 |
+
|
9 |
+
_CITATION = """\
|
10 |
+
@inproceedings{armendariz-etal-2020-cosimlex,
|
11 |
+
title = "{C}o{S}im{L}ex: A Resource for Evaluating Graded Word Similarity in Context",
|
12 |
+
author = "Armendariz, Carlos Santos and
|
13 |
+
Purver, Matthew and
|
14 |
+
Ul{\v{c}}ar, Matej and
|
15 |
+
Pollak, Senja and
|
16 |
+
Ljube{\v{s}}i{\'c}, Nikola and
|
17 |
+
Granroth-Wilding, Mark",
|
18 |
+
booktitle = "Proceedings of the 12th Language Resources and Evaluation Conference",
|
19 |
+
month = may,
|
20 |
+
year = "2020",
|
21 |
+
url = "https://aclanthology.org/2020.lrec-1.720",
|
22 |
+
pages = "5878--5886"
|
23 |
+
}
|
24 |
+
"""
|
25 |
+
|
26 |
+
_DESCRIPTION = """\
|
27 |
+
The dataset contains human similarity ratings for pairs of words. The annotators were presented with contexts that
|
28 |
+
contained both of the words in the pair and the dataset features two different contexts per pair. The words were
|
29 |
+
sourced from the English, Croatian, Finnish and Slovenian versions of the original Simlex dataset.
|
30 |
+
"""
|
31 |
+
|
32 |
+
_HOMEPAGE = "http://hdl.handle.net/11356/1308"
|
33 |
+
|
34 |
+
_LICENSE = "GNU General Public Licence, version 3"
|
35 |
+
|
36 |
+
_URLS = {
|
37 |
+
"en": "https://www.clarin.si/repository/xmlui/bitstream/handle/11356/1308/cosimlex_en.csv",
|
38 |
+
"fi": "https://www.clarin.si/repository/xmlui/bitstream/handle/11356/1308/cosimlex_fi.csv",
|
39 |
+
"hr": "https://www.clarin.si/repository/xmlui/bitstream/handle/11356/1308/cosimlex_hr.csv",
|
40 |
+
"sl": "https://www.clarin.si/repository/xmlui/bitstream/handle/11356/1308/cosimlex_sl.csv"
|
41 |
+
}
|
42 |
+
|
43 |
+
|
44 |
+
class CoSimLex(datasets.GeneratorBasedBuilder):
|
45 |
+
"""CoSimLex is a resource for evaluating graded word similarity in context."""
|
46 |
+
|
47 |
+
VERSION = datasets.Version("1.0.0")
|
48 |
+
|
49 |
+
BUILDER_CONFIGS = [
|
50 |
+
datasets.BuilderConfig(name="en", version=VERSION, description="The English subset."),
|
51 |
+
datasets.BuilderConfig(name="fi", version=VERSION, description="The Finnish subset."),
|
52 |
+
datasets.BuilderConfig(name="hr", version=VERSION, description="The Croatian subset."),
|
53 |
+
datasets.BuilderConfig(name="sl", version=VERSION, description="The Slovenian subset."),
|
54 |
+
]
|
55 |
+
|
56 |
+
def _info(self):
|
57 |
+
features = datasets.Features(
|
58 |
+
{
|
59 |
+
"word1": datasets.Value("string"), "word2": datasets.Value("string"),
|
60 |
+
"context1": datasets.Value("string"), "context2": datasets.Value("string"),
|
61 |
+
"sim1": datasets.Value("float32"), "sim2": datasets.Value("float32"),
|
62 |
+
"stdev1": datasets.Value("float32"), "stdev2": datasets.Value("float32"),
|
63 |
+
"pvalue": datasets.Value("float32"),
|
64 |
+
"word1_context1": datasets.Value("string"), "word2_context1": datasets.Value("string"),
|
65 |
+
"word1_context2": datasets.Value("string"), "word2_context2": datasets.Value("string")
|
66 |
+
}
|
67 |
+
)
|
68 |
+
|
69 |
+
return datasets.DatasetInfo(
|
70 |
+
description=_DESCRIPTION,
|
71 |
+
features=features,
|
72 |
+
homepage=_HOMEPAGE,
|
73 |
+
license=_LICENSE,
|
74 |
+
citation=_CITATION,
|
75 |
+
)
|
76 |
+
|
77 |
+
def _split_generators(self, dl_manager):
|
78 |
+
urls = _URLS[self.config.name]
|
79 |
+
file_path = dl_manager.download_and_extract(urls)
|
80 |
+
return [
|
81 |
+
datasets.SplitGenerator(
|
82 |
+
name=datasets.Split.TRAIN,
|
83 |
+
gen_kwargs={"file_path": file_path}
|
84 |
+
)
|
85 |
+
]
|
86 |
+
|
87 |
+
def _generate_examples(self, file_path):
|
88 |
+
with open(file_path, encoding="utf-8") as f:
|
89 |
+
reader = csv.reader(f, delimiter="\t", quotechar='"')
|
90 |
+
header = next(reader)
|
91 |
+
|
92 |
+
for i, row in enumerate(reader):
|
93 |
+
yield i, {attr: value for attr, value in zip(header, row)}
|
dataset_infos.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"en": {"description": "The dataset contains human similarity ratings for pairs of words. The annotators were presented with contexts that \ncontained both of the words in the pair and the dataset features two different contexts per pair. The words were \nsourced from the English, Croatian, Finnish and Slovenian versions of the original Simlex dataset.\n", "citation": "@inproceedings{armendariz-etal-2020-cosimlex,\n title = \"{C}o{S}im{L}ex: A Resource for Evaluating Graded Word Similarity in Context\",\n author = \"Armendariz, Carlos Santos and\n Purver, Matthew and\n Ul{\u000b{c}}ar, Matej and\n Pollak, Senja and\n Ljube{\u000b{s}}i{'c}, Nikola and\n Granroth-Wilding, Mark\",\n booktitle = \"Proceedings of the 12th Language Resources and Evaluation Conference\",\n month = may,\n year = \"2020\",\n url = \"https://aclanthology.org/2020.lrec-1.720\",\n pages = \"5878--5886\"\n}\n", "homepage": "http://hdl.handle.net/11356/1308", "license": "GNU General Public Licence, version 3", "features": {"word1": {"dtype": "string", "id": null, "_type": "Value"}, "word2": {"dtype": "string", "id": null, "_type": "Value"}, "context1": {"dtype": "string", "id": null, "_type": "Value"}, "context2": {"dtype": "string", "id": null, "_type": "Value"}, "sim1": {"dtype": "float32", "id": null, "_type": "Value"}, "sim2": {"dtype": "float32", "id": null, "_type": "Value"}, "stdev1": {"dtype": "float32", "id": null, "_type": "Value"}, "stdev2": {"dtype": "float32", "id": null, "_type": "Value"}, "pvalue": {"dtype": "float32", "id": null, "_type": "Value"}, "word1_context1": {"dtype": "string", "id": null, "_type": "Value"}, "word2_context1": {"dtype": "string", "id": null, "_type": "Value"}, "word1_context2": {"dtype": "string", "id": null, "_type": "Value"}, "word2_context2": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "cosimlex", "config_name": "en", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 297568, "num_examples": 340, "dataset_name": "cosimlex"}}, "download_checksums": {"https://www.clarin.si/repository/xmlui/bitstream/handle/11356/1308/cosimlex_en.csv": {"num_bytes": 291788, "checksum": "6ea7d38f092b54dcb1b3373e96b33e487851dfe5052d6c5daae6a9905c34a717"}}, "download_size": 291788, "post_processing_size": null, "dataset_size": 297568, "size_in_bytes": 589356}, "fi": {"description": "The dataset contains human similarity ratings for pairs of words. The annotators were presented with contexts that \ncontained both of the words in the pair and the dataset features two different contexts per pair. The words were \nsourced from the English, Croatian, Finnish and Slovenian versions of the original Simlex dataset.\n", "citation": "@inproceedings{armendariz-etal-2020-cosimlex,\n title = \"{C}o{S}im{L}ex: A Resource for Evaluating Graded Word Similarity in Context\",\n author = \"Armendariz, Carlos Santos and\n Purver, Matthew and\n Ul{\u000b{c}}ar, Matej and\n Pollak, Senja and\n Ljube{\u000b{s}}i{'c}, Nikola and\n Granroth-Wilding, Mark\",\n booktitle = \"Proceedings of the 12th Language Resources and Evaluation Conference\",\n month = may,\n year = \"2020\",\n url = \"https://aclanthology.org/2020.lrec-1.720\",\n pages = \"5878--5886\"\n}\n", "homepage": "http://hdl.handle.net/11356/1308", "license": "GNU General Public Licence, version 3", "features": {"word1": {"dtype": "string", "id": null, "_type": "Value"}, "word2": {"dtype": "string", "id": null, "_type": "Value"}, "context1": {"dtype": "string", "id": null, "_type": "Value"}, "context2": {"dtype": "string", "id": null, "_type": "Value"}, "sim1": {"dtype": "float32", "id": null, "_type": "Value"}, "sim2": {"dtype": "float32", "id": null, "_type": "Value"}, "stdev1": {"dtype": "float32", "id": null, "_type": "Value"}, "stdev2": {"dtype": "float32", "id": null, "_type": "Value"}, "pvalue": {"dtype": "float32", "id": null, "_type": "Value"}, "word1_context1": {"dtype": "string", "id": null, "_type": "Value"}, "word2_context1": {"dtype": "string", "id": null, "_type": "Value"}, "word1_context2": {"dtype": "string", "id": null, "_type": "Value"}, "word2_context2": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "cosimlex", "config_name": "fi", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 20841, "num_examples": 24, "dataset_name": "cosimlex"}}, "download_checksums": {"https://www.clarin.si/repository/xmlui/bitstream/handle/11356/1308/cosimlex_fi.csv": {"num_bytes": 20456, "checksum": "4683190a98a6704425e3284ec9053d6ade62fda370a90530d338468b246f1683"}}, "download_size": 20456, "post_processing_size": null, "dataset_size": 20841, "size_in_bytes": 41297}, "hr": {"description": "The dataset contains human similarity ratings for pairs of words. The annotators were presented with contexts that \ncontained both of the words in the pair and the dataset features two different contexts per pair. The words were \nsourced from the English, Croatian, Finnish and Slovenian versions of the original Simlex dataset.\n", "citation": "@inproceedings{armendariz-etal-2020-cosimlex,\n title = \"{C}o{S}im{L}ex: A Resource for Evaluating Graded Word Similarity in Context\",\n author = \"Armendariz, Carlos Santos and\n Purver, Matthew and\n Ul{\u000b{c}}ar, Matej and\n Pollak, Senja and\n Ljube{\u000b{s}}i{'c}, Nikola and\n Granroth-Wilding, Mark\",\n booktitle = \"Proceedings of the 12th Language Resources and Evaluation Conference\",\n month = may,\n year = \"2020\",\n url = \"https://aclanthology.org/2020.lrec-1.720\",\n pages = \"5878--5886\"\n}\n", "homepage": "http://hdl.handle.net/11356/1308", "license": "GNU General Public Licence, version 3", "features": {"word1": {"dtype": "string", "id": null, "_type": "Value"}, "word2": {"dtype": "string", "id": null, "_type": "Value"}, "context1": {"dtype": "string", "id": null, "_type": "Value"}, "context2": {"dtype": "string", "id": null, "_type": "Value"}, "sim1": {"dtype": "float32", "id": null, "_type": "Value"}, "sim2": {"dtype": "float32", "id": null, "_type": "Value"}, "stdev1": {"dtype": "float32", "id": null, "_type": "Value"}, "stdev2": {"dtype": "float32", "id": null, "_type": "Value"}, "pvalue": {"dtype": "float32", "id": null, "_type": "Value"}, "word1_context1": {"dtype": "string", "id": null, "_type": "Value"}, "word2_context1": {"dtype": "string", "id": null, "_type": "Value"}, "word1_context2": {"dtype": "string", "id": null, "_type": "Value"}, "word2_context2": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "cosimlex", "config_name": "hr", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 96645, "num_examples": 112, "dataset_name": "cosimlex"}}, "download_checksums": {"https://www.clarin.si/repository/xmlui/bitstream/handle/11356/1308/cosimlex_hr.csv": {"num_bytes": 94674, "checksum": "bb9c5887390c9e34979eb17df8b5120f79623db0035ad7b1d9a31d837f5accdc"}}, "download_size": 94674, "post_processing_size": null, "dataset_size": 96645, "size_in_bytes": 191319}, "sl": {"description": "The dataset contains human similarity ratings for pairs of words. The annotators were presented with contexts that \ncontained both of the words in the pair and the dataset features two different contexts per pair. The words were \nsourced from the English, Croatian, Finnish and Slovenian versions of the original Simlex dataset.\n", "citation": "@inproceedings{armendariz-etal-2020-cosimlex,\n title = \"{C}o{S}im{L}ex: A Resource for Evaluating Graded Word Similarity in Context\",\n author = \"Armendariz, Carlos Santos and\n Purver, Matthew and\n Ul{\u000b{c}}ar, Matej and\n Pollak, Senja and\n Ljube{\u000b{s}}i{'c}, Nikola and\n Granroth-Wilding, Mark\",\n booktitle = \"Proceedings of the 12th Language Resources and Evaluation Conference\",\n month = may,\n year = \"2020\",\n url = \"https://aclanthology.org/2020.lrec-1.720\",\n pages = \"5878--5886\"\n}\n", "homepage": "http://hdl.handle.net/11356/1308", "license": "GNU General Public Licence, version 3", "features": {"word1": {"dtype": "string", "id": null, "_type": "Value"}, "word2": {"dtype": "string", "id": null, "_type": "Value"}, "context1": {"dtype": "string", "id": null, "_type": "Value"}, "context2": {"dtype": "string", "id": null, "_type": "Value"}, "sim1": {"dtype": "float32", "id": null, "_type": "Value"}, "sim2": {"dtype": "float32", "id": null, "_type": "Value"}, "stdev1": {"dtype": "float32", "id": null, "_type": "Value"}, "stdev2": {"dtype": "float32", "id": null, "_type": "Value"}, "pvalue": {"dtype": "float32", "id": null, "_type": "Value"}, "word1_context1": {"dtype": "string", "id": null, "_type": "Value"}, "word2_context1": {"dtype": "string", "id": null, "_type": "Value"}, "word1_context2": {"dtype": "string", "id": null, "_type": "Value"}, "word2_context2": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "cosimlex", "config_name": "sl", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 89452, "num_examples": 111, "dataset_name": "cosimlex"}}, "download_checksums": {"https://www.clarin.si/repository/xmlui/bitstream/handle/11356/1308/cosimlex_sl.csv": {"num_bytes": 87467, "checksum": "4b07ea726237de3ce2e6ba4f35a86f9f64c4d038cbeabca9ade72c111abb78ad"}}, "download_size": 87467, "post_processing_size": null, "dataset_size": 89452, "size_in_bytes": 176919}}
|