"""CoSimLex is a resource for evaluating graded word similarity in context.""" import csv import datasets _CITATION = """\ @inproceedings{armendariz-etal-2020-cosimlex, title = "{C}o{S}im{L}ex: A Resource for Evaluating Graded Word Similarity in Context", author = "Armendariz, Carlos Santos and Purver, Matthew and Ul{\v{c}}ar, Matej and Pollak, Senja and Ljube{\v{s}}i{\'c}, Nikola and Granroth-Wilding, Mark", booktitle = "Proceedings of the 12th Language Resources and Evaluation Conference", month = may, year = "2020", url = "https://aclanthology.org/2020.lrec-1.720", pages = "5878--5886" } """ _DESCRIPTION = """\ The dataset contains human similarity ratings for pairs of words. The annotators were presented with contexts that contained both of the words in the pair and the dataset features two different contexts per pair. The words were sourced from the English, Croatian, Finnish and Slovenian versions of the original Simlex dataset. """ _HOMEPAGE = "http://hdl.handle.net/11356/1308" _LICENSE = "GNU General Public Licence, version 3" _URLS = { "en": "https://www.clarin.si/repository/xmlui/bitstream/handle/11356/1308/cosimlex_en.csv", "fi": "https://www.clarin.si/repository/xmlui/bitstream/handle/11356/1308/cosimlex_fi.csv", "hr": "https://www.clarin.si/repository/xmlui/bitstream/handle/11356/1308/cosimlex_hr.csv", "sl": "https://www.clarin.si/repository/xmlui/bitstream/handle/11356/1308/cosimlex_sl.csv" } class CoSimLex(datasets.GeneratorBasedBuilder): """CoSimLex is a resource for evaluating graded word similarity in context.""" VERSION = datasets.Version("1.0.0") BUILDER_CONFIGS = [ datasets.BuilderConfig(name="en", version=VERSION, description="The English subset."), datasets.BuilderConfig(name="fi", version=VERSION, description="The Finnish subset."), datasets.BuilderConfig(name="hr", version=VERSION, description="The Croatian subset."), datasets.BuilderConfig(name="sl", version=VERSION, description="The Slovenian subset."), ] def _info(self): features = datasets.Features( { "word1": datasets.Value("string"), "word2": datasets.Value("string"), "context1": datasets.Value("string"), "context2": datasets.Value("string"), "sim1": datasets.Value("float32"), "sim2": datasets.Value("float32"), "stdev1": datasets.Value("float32"), "stdev2": datasets.Value("float32"), "pvalue": datasets.Value("float32"), "word1_context1": datasets.Value("string"), "word2_context1": datasets.Value("string"), "word1_context2": datasets.Value("string"), "word2_context2": datasets.Value("string") } ) return datasets.DatasetInfo( description=_DESCRIPTION, features=features, homepage=_HOMEPAGE, license=_LICENSE, citation=_CITATION, ) def _split_generators(self, dl_manager): urls = _URLS[self.config.name] file_path = dl_manager.download_and_extract(urls) return [ datasets.SplitGenerator( name=datasets.Split.TRAIN, gen_kwargs={"file_path": file_path} ) ] def _generate_examples(self, file_path): with open(file_path, encoding="utf-8") as f: reader = csv.reader(f, delimiter="\t", quotechar='"') header = next(reader) for i, row in enumerate(reader): yield i, {attr: value for attr, value in zip(header, row)}