qanastek commited on
Commit
4a36b2b
1 Parent(s): fd587c0

Upload Biosses-BLUE.py

Browse files
Files changed (1) hide show
  1. Biosses-BLUE.py +128 -0
Biosses-BLUE.py ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+
3
+ """BIOSSES: a semantic sentence similarity estimation system for the biomedical domain"""
4
+
5
+ import datasets
6
+ from pathlib import Path
7
+
8
+ import pandas as pd
9
+
10
+ logger = datasets.logging.get_logger(__name__)
11
+
12
+ _CITATION = """
13
+ @article{10.1093/bioinformatics/btx238,
14
+ author = {Soğancıoğlu, Gizem and Öztürk, Hakime and Özgür, Arzucan},
15
+ title = "{BIOSSES: a semantic sentence similarity estimation system for the biomedical domain}",
16
+ journal = {Bioinformatics},
17
+ volume = {33},
18
+ number = {14},
19
+ pages = {i49-i58},
20
+ year = {2017},
21
+ month = {07},
22
+ 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/.}",
23
+ issn = {1367-4803},
24
+ doi = {10.1093/bioinformatics/btx238},
25
+ url = {https://doi.org/10.1093/bioinformatics/btx238},
26
+ eprint = {https://academic.oup.com/bioinformatics/article-pdf/33/14/i49/25157316/btx238.pdf},
27
+ }
28
+ """
29
+
30
+ _LICENSE = """
31
+ GNU General Public License v3.0
32
+ """
33
+
34
+ _DESCRIPTION = """
35
+ BIOSSES is a benchmark dataset for biomedical sentence similarity estimation.
36
+ The dataset comprises 100 sentence pairs, in which each sentence was selected
37
+ from the TAC (Text Analysis Conference) Biomedical Summarization Track Training
38
+ Dataset containing articles from the biomedical domain. The sentence pairs in
39
+ BIOSSES were selected from citing sentences, i.e. sentences that have a citation
40
+ to a reference article.
41
+
42
+ The sentence pairs were evaluated by five different human experts that judged
43
+ their similarity and gave scores ranging from 0 (no relation) to 4 (equivalent).
44
+ In the original paper the mean of the scores assigned by the five human annotators
45
+ was taken as the gold standard. The Pearson correlation between the gold standard
46
+ scores and the scores estimated by the models was used as the evaluation metric.
47
+ The strength of correlation can be assessed by the general guideline proposed by
48
+ Evans (1996) as follows:
49
+
50
+ very strong: 0.80–1.00
51
+ strong: 0.60–0.79
52
+ moderate: 0.40–0.59
53
+ weak: 0.20–0.39
54
+ very weak: 0.00–0.19
55
+ """
56
+
57
+ _HOMEPAGE = "https://tabilab.cmpe.boun.edu.tr/BIOSSES/"
58
+
59
+ _URL = "https://github.com/ncbi-nlp/BLUE_Benchmark/releases/download/0.1/data_v0.2.zip"
60
+
61
+ class Biosses(datasets.GeneratorBasedBuilder):
62
+ """BIOSSES: a semantic sentence similarity estimation system for the biomedical domain"""
63
+
64
+ BUILDER_CONFIGS = [
65
+ datasets.BuilderConfig(
66
+ name = "default",
67
+ version = datasets.Version("0.2.0"),
68
+ description = f"The Biosses corpora",
69
+ )
70
+ ]
71
+
72
+ DEFAULT_CONFIG_NAME = "default"
73
+
74
+ def _info(self):
75
+ return datasets.DatasetInfo(
76
+ description=_DESCRIPTION,
77
+ features=datasets.Features(
78
+ {
79
+ "id": datasets.Value("string"),
80
+ "sentence1": datasets.Value("string"),
81
+ "sentence2": datasets.Value("string"),
82
+ "score": datasets.Value("float"),
83
+ },
84
+ ),
85
+ supervised_keys=None,
86
+ homepage=_HOMEPAGE,
87
+ citation=_CITATION,
88
+ license=_LICENSE,
89
+ )
90
+
91
+
92
+ def _split_generators(self, dl_manager):
93
+ """Returns SplitGenerators."""
94
+
95
+ data_dir = dl_manager.download_and_extract(_URL)
96
+
97
+ return [
98
+ datasets.SplitGenerator(
99
+ name=datasets.Split.TRAIN,
100
+ gen_kwargs={
101
+ "corpus_path": Path(data_dir) / "data/BIOSSES/train.tsv",
102
+ },
103
+ ),
104
+ datasets.SplitGenerator(
105
+ name=datasets.Split.VALIDATION,
106
+ gen_kwargs={
107
+ "corpus_path": Path(data_dir) / "data/BIOSSES/dev.tsv",
108
+ },
109
+ ),
110
+ datasets.SplitGenerator(
111
+ name=datasets.Split.TEST,
112
+ gen_kwargs={
113
+ "corpus_path": Path(data_dir) / "data/BIOSSES/test.tsv",
114
+ },
115
+ ),
116
+ ]
117
+ def _generate_examples(self, corpus_path: Path):
118
+
119
+ df = pd.read_csv(corpus_path, sep="\t")
120
+
121
+ for index, r in df.iterrows():
122
+
123
+ yield int(r['index']), {
124
+ "id": int(r['index']),
125
+ "sentence1": r['sentence1'],
126
+ "sentence2": r['sentence2'],
127
+ "score": float(r['score']),
128
+ }