# coding=utf-8 """BIOSSES: a semantic sentence similarity estimation system for the biomedical domain""" import datasets from pathlib import Path import pandas as pd logger = datasets.logging.get_logger(__name__) _CITATION = """ @article{10.1093/bioinformatics/btx238, author = {Soğancıoğlu, Gizem and Öztürk, Hakime and Özgür, Arzucan}, title = "{BIOSSES: a semantic sentence similarity estimation system for the biomedical domain}", journal = {Bioinformatics}, volume = {33}, number = {14}, pages = {i49-i58}, year = {2017}, month = {07}, abstract = "{The amount of information available in textual format is rapidly increasing in the biomedical domain. Therefore, natural language processing (NLP) applications are becoming increasingly important to facilitate the retrieval and analysis of these data. Computing the semantic similarity between sentences is an important component in many NLP tasks including text retrieval and summarization. A number of approaches have been proposed for semantic sentence similarity estimation for generic English. However, our experiments showed that such approaches do not effectively cover biomedical knowledge and produce poor results for biomedical text.We propose several approaches for sentence-level semantic similarity computation in the biomedical domain, including string similarity measures and measures based on the distributed vector representations of sentences learned in an unsupervised manner from a large biomedical corpus. In addition, ontology-based approaches are presented that utilize general and domain-specific ontologies. Finally, a supervised regression based model is developed that effectively combines the different similarity computation metrics. A benchmark data set consisting of 100 sentence pairs from the biomedical literature is manually annotated by five human experts and used for evaluating the proposed methods.The experiments showed that the supervised semantic sentence similarity computation approach obtained the best performance (0.836 correlation with gold standard human annotations) and improved over the state-of-the-art domain-independent systems up to 42.6\\% in terms of the Pearson correlation metric.A web-based system for biomedical semantic sentence similarity computation, the source code, and the annotated benchmark data set are available at: http://tabilab.cmpe.boun.edu.tr/BIOSSES/.}", issn = {1367-4803}, doi = {10.1093/bioinformatics/btx238}, url = {https://doi.org/10.1093/bioinformatics/btx238}, eprint = {https://academic.oup.com/bioinformatics/article-pdf/33/14/i49/25157316/btx238.pdf}, } """ _LICENSE = """ GNU General Public License v3.0 """ _DESCRIPTION = """ BIOSSES is a benchmark dataset for biomedical sentence similarity estimation. The dataset comprises 100 sentence pairs, in which each sentence was selected from the TAC (Text Analysis Conference) Biomedical Summarization Track Training Dataset containing articles from the biomedical domain. The sentence pairs in BIOSSES were selected from citing sentences, i.e. sentences that have a citation to a reference article. The sentence pairs were evaluated by five different human experts that judged their similarity and gave scores ranging from 0 (no relation) to 4 (equivalent). In the original paper the mean of the scores assigned by the five human annotators was taken as the gold standard. The Pearson correlation between the gold standard scores and the scores estimated by the models was used as the evaluation metric. The strength of correlation can be assessed by the general guideline proposed by Evans (1996) as follows: very strong: 0.80–1.00 strong: 0.60–0.79 moderate: 0.40–0.59 weak: 0.20–0.39 very weak: 0.00–0.19 """ _HOMEPAGE = "https://tabilab.cmpe.boun.edu.tr/BIOSSES/" _URL = "https://github.com/ncbi-nlp/BLUE_Benchmark/releases/download/0.1/data_v0.2.zip" class Biosses(datasets.GeneratorBasedBuilder): """BIOSSES: a semantic sentence similarity estimation system for the biomedical domain""" BUILDER_CONFIGS = [ datasets.BuilderConfig( name = "biosses", version = datasets.Version("0.2.0"), description = f"The Biosses corpora", ) ] DEFAULT_CONFIG_NAME = "biosses" def _info(self): return datasets.DatasetInfo( description=_DESCRIPTION, features=datasets.Features( { "id": datasets.Value("string"), "sentence1": datasets.Value("string"), "sentence2": datasets.Value("string"), "score": datasets.Value("float"), }, ), supervised_keys=None, homepage=_HOMEPAGE, citation=_CITATION, license=_LICENSE, ) def _split_generators(self, dl_manager): """Returns SplitGenerators.""" # archive = dl_manager.download(_URL) archive = dl_manager.download_and_extract(_URL) return [ datasets.SplitGenerator( name=datasets.Split.TRAIN, gen_kwargs={ # "files": dl_manager.iter_archive(archive), "path": archive, "split": "train", }, ), datasets.SplitGenerator( name=datasets.Split.VALIDATION, gen_kwargs={ # "files": dl_manager.iter_archive(archive), "path": archive, "split": "dev", }, ), datasets.SplitGenerator( name=datasets.Split.TEST, gen_kwargs={ # "files": dl_manager.iter_archive(archive), "path": archive, "split": "test", }, ), ] # def _generate_examples(self, files, split: str): def _generate_examples(self, path: Path, split: str): df = pd.read_csv(f"{path}/data/BIOSSES/{split}.tsv", sep="\t") for index, r in df.iterrows(): yield int(r['index']), { "id": str(r['index']), "sentence1": str(r['sentence1']), "sentence2": str(r['sentence2']), "score": float(r['score']), }