File size: 6,389 Bytes
4a36b2b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62496cc
4a36b2b
 
 
 
 
62496cc
4a36b2b
 
 
 
 
 
6f5614c
4a36b2b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f83460a
62496cc
4a36b2b
 
 
 
 
f83460a
 
62496cc
4a36b2b
 
 
 
 
f83460a
 
62496cc
4a36b2b
 
 
 
 
f83460a
 
62496cc
4a36b2b
 
 
 
f83460a
 
 
 
4a36b2b
 
 
 
6f5614c
cdf7e9e
 
4a36b2b
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# 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']),
            }