enoriega commited on
Commit
eb3fbac
1 Parent(s): f175016

Initial commit

Browse files
Files changed (2) hide show
  1. bc2geneMention.zip +3 -0
  2. biocreative_gene_mention.py +166 -0
bc2geneMention.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7f84a08b08710955a65407bd570ea3921b2ef46f2ded3cacc293576a3189615f
3
+ size 4286918
biocreative_gene_mention.py ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import csv
2
+ import os
3
+ from collections import defaultdict
4
+
5
+ import datasets
6
+ from datasets import Sequence, Value
7
+
8
+ # Find for instance the citation on arxiv or on the dataset repo/website
9
+ _CITATION = """\
10
+ @article{cite-key,
11
+ Abstract = {Nineteen teams presented results for the Gene Mention Task at the BioCreative II Workshop. In this task participants designed systems to identify substrings in sentences corresponding to gene name mentions. A variety of different methods were used and the results varied with a highest achieved F1 score of 0.8721. Here we present brief descriptions of all the methods used and a statistical analysis of the results. We also demonstrate that, by combining the results from all submissions, an F score of 0.9066 is feasible, and furthermore that the best result makes use of the lowest scoring submissions.},
12
+ Author = {Smith, Larry and Tanabe, Lorraine K. and Ando, Rie Johnson nee and Kuo, Cheng-Ju and Chung, I-Fang and Hsu, Chun-Nan and Lin, Yu-Shi and Klinger, Roman and Friedrich, Christoph M. and Ganchev, Kuzman and Torii, Manabu and Liu, Hongfang and Haddow, Barry and Struble, Craig A. and Povinelli, Richard J. and Vlachos, Andreas and Baumgartner, William A. and Hunter, Lawrence and Carpenter, Bob and Tsai, Richard Tzong-Han and Dai, Hong-Jie and Liu, Feng and Chen, Yifei and Sun, Chengjie and Katrenko, Sophia and Adriaans, Pieter and Blaschke, Christian and Torres, Rafael and Neves, Mariana and Nakov, Preslav and Divoli, Anna and Ma{\~n}a-L{\'o}pez, Manuel and Mata, Jacinto and Wilbur, W. John},
13
+ Da = {2008/09/01},
14
+ Date-Added = {2022-04-15 17:35:45 -0700},
15
+ Date-Modified = {2022-04-15 17:35:45 -0700},
16
+ Doi = {10.1186/gb-2008-9-s2-s2},
17
+ Id = {Smith2008},
18
+ Isbn = {1474-760X},
19
+ Journal = {Genome Biology},
20
+ Number = {2},
21
+ Pages = {S2},
22
+ Title = {Overview of BioCreative II gene mention recognition},
23
+ Ty = {JOUR},
24
+ Url = {https://doi.org/10.1186/gb-2008-9-s2-s2},
25
+ Volume = {9},
26
+ Year = {2008},
27
+ Bdsk-Url-1 = {https://doi.org/10.1186/gb-2008-9-s2-s2}}
28
+ """
29
+
30
+ # You can copy an official description
31
+ _DESCRIPTION = """\
32
+ Training and validation datasets for the BioCreative II gene mention task.
33
+ The data has been tokenized with [processors](https://github.com/clulab/processors)
34
+ ## Features:
35
+ - __tokens__: Input token sequence
36
+ - __folded_tokens__: Same as tokens, but case-folded
37
+ - __tags__: POS tags of the input sequence tokens
38
+ - __labels__: BIO sequence tags
39
+ """
40
+
41
+ _HOMEPAGE = "https://biocreative.bioinformatics.udel.edu/resources/corpora/biocreative-ii-corpus/"
42
+
43
+
44
+ class BioCreativeBIODataset(datasets.GeneratorBasedBuilder):
45
+ """
46
+ BioCreative dataset processed to BIO tags
47
+ """
48
+
49
+ VERSION = datasets.Version("1.1.0")
50
+
51
+ def _info(self):
52
+ features = datasets.Features(
53
+ {
54
+ 'tokens': Sequence(Value('string')),
55
+ 'folded_tokens': Sequence(Value('string')),
56
+ 'tags': Sequence(datasets.features.ClassLabel(
57
+ names=['WRB',
58
+ 'WP',
59
+ 'DT',
60
+ "''",
61
+ '#',
62
+ 'JJS',
63
+ " '' ",
64
+ 'NN',
65
+ 'JJ',
66
+ 'VBZ',
67
+ 'VBP',
68
+ 'FW',
69
+ 'RBR',
70
+ 'MD',
71
+ 'VBG',
72
+ '.',
73
+ ',',
74
+ 'PRP$',
75
+ 'PRP',
76
+ ' `` ',
77
+ 'IN',
78
+ 'VBD',
79
+ 'VB',
80
+ 'WP$',
81
+ 'TO',
82
+ 'RP',
83
+ 'RB',
84
+ 'NNPS',
85
+ 'VBN',
86
+ 'LS',
87
+ 'CC',
88
+ 'RBS',
89
+ 'PDT',
90
+ 'WDT',
91
+ 'POS',
92
+ 'NNS',
93
+ 'NNP',
94
+ 'EX',
95
+ 'SYM',
96
+ 'CD',
97
+ ':',
98
+ 'JJR',
99
+ '$']
100
+ )),
101
+
102
+ 'labels': Sequence(
103
+ datasets.features.ClassLabel(
104
+ names=['B-Gene_or_gene_product', 'I-Gene_or_gene_product', 'O']
105
+ )
106
+ )
107
+ }
108
+ )
109
+ return datasets.DatasetInfo(
110
+ # This is the description that will appear on the datasets page.
111
+ description=_DESCRIPTION,
112
+ # This defines the different columns of the dataset and their types
113
+ features=features, # Here we define them above because they are different between the two configurations
114
+ # Homepage of the dataset for documentation
115
+ homepage=_HOMEPAGE,
116
+ # # License for the dataset if available
117
+ # license=_LICENSE,
118
+ # # Citation for the dataset
119
+ citation=_CITATION,
120
+ )
121
+
122
+ def _split_generators(self, dl_manager):
123
+ data_dir = dl_manager.download_and_extract("bc2geneMention.zip")
124
+
125
+ return [
126
+ datasets.SplitGenerator(
127
+ name=datasets.Split.TRAIN,
128
+ # These kwargs will be passed to _generate_examples
129
+ gen_kwargs={
130
+ "filepath": os.path.join(data_dir, "bc2geneMention", "IOB", "train.iob.txt"),
131
+ "split": "train",
132
+ },
133
+ ),
134
+
135
+ datasets.SplitGenerator(
136
+ name=datasets.Split.VALIDATION,
137
+ # These kwargs will be passed to _generate_examples
138
+ gen_kwargs={
139
+ "filepath": os.path.join(data_dir, "bc2geneMention", "IOB", "dev.iob.txt"),
140
+ "split": "dev",
141
+ },
142
+ ),
143
+ ]
144
+
145
+ # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
146
+ def _generate_examples(self, filepath, split, ipdb=None):
147
+ current = defaultdict(list)
148
+ col_names = "tokens tags folded_tokens labels".split()
149
+ key = 0
150
+
151
+ # Parse the file contents
152
+ with open(filepath) as f:
153
+ reader = csv.reader(f, delimiter=' ')
154
+ for row in reader:
155
+ if len(row) == 0:
156
+ yield key, current
157
+ key += 1
158
+ current = defaultdict(list)
159
+ else:
160
+ if len(row) == 2:
161
+ row = [row[0], row[0], row[0], row[1]]
162
+ for k, v in zip(col_names, row):
163
+ current[k].append(v)
164
+ # Corner case
165
+ if len(row) > 0:
166
+ yield key, current