line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# MetaMap::DataStructures |
2
|
|
|
|
|
|
|
# (Last Updated $Id: DataStructures.pm,v 1.147 2016/01/07 22:49:33 btmcinnes Exp $) |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# Perl module that provides a container for machine readable |
5
|
|
|
|
|
|
|
# MetaMap mapped text |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# Copyright (c) 2016 |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# Sam Henry, Virginia Commonwealth University |
10
|
|
|
|
|
|
|
# henryst at vcu.edu |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
# Bridget T. McInnes, Virginia Commonwealth University |
13
|
|
|
|
|
|
|
# btmcinnes at vcu.edu |
14
|
|
|
|
|
|
|
# |
15
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or |
16
|
|
|
|
|
|
|
# modify it under the terms of the GNU General Public License |
17
|
|
|
|
|
|
|
# as published by the Free Software Foundation; either version 2 |
18
|
|
|
|
|
|
|
# of the License, or (at your option) any later version. |
19
|
|
|
|
|
|
|
# |
20
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful, |
21
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
22
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23
|
|
|
|
|
|
|
# GNU General Public License for more details. |
24
|
|
|
|
|
|
|
# |
25
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License |
26
|
|
|
|
|
|
|
# along with this program; if not, write to |
27
|
|
|
|
|
|
|
# |
28
|
|
|
|
|
|
|
# The Free Software Foundation, Inc., |
29
|
|
|
|
|
|
|
# 59 Temple Place - Suite 330, |
30
|
|
|
|
|
|
|
# Boston, MA 02111-1307, USA. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 NAME |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
MetaMap::DataStructure - provides a container for the information |
35
|
|
|
|
|
|
|
extracted from machine readable MetaMap mapped text. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 DESCRIPTION |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
This package provides a container for the information extracted |
40
|
|
|
|
|
|
|
from machine readable MetaMap mapped text. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
For more information please see the MetaMap::DataStructure.pm documentation. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 SYNOPSIS |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
add synopsis |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 ABSTRACT |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
This package provides a Perl container package to for information extracted |
51
|
|
|
|
|
|
|
from MetaMap mapped text. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 INSTALL |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
To install the module, run the following magic commands: |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
perl Makefile.PL |
58
|
|
|
|
|
|
|
make |
59
|
|
|
|
|
|
|
make test |
60
|
|
|
|
|
|
|
make install |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
This will install the module in the standard location. You will, most |
63
|
|
|
|
|
|
|
probably, require root privileges to install in standard system |
64
|
|
|
|
|
|
|
directories. To install in a non-standard directory, specify a prefix |
65
|
|
|
|
|
|
|
during the 'perl Makefile.PL' stage as: |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
perl Makefile.PL PREFIX=/home/sam |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
It is possible to modify other parameters during installation. The |
70
|
|
|
|
|
|
|
details of these can be found in the ExtUtils::MakeMaker |
71
|
|
|
|
|
|
|
documentation. However, it is highly recommended not messing around |
72
|
|
|
|
|
|
|
with other parameters, unless you know what you're doing. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 DESCRIPTION |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
This package provides a Perl containers for information |
77
|
|
|
|
|
|
|
extracted from MetaMap mapped text. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 FUNCTION DESCRIPTIONS |
80
|
|
|
|
|
|
|
=cut |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
package MetaMap::DataStructures; |
83
|
|
|
|
|
|
|
|
84
|
1
|
|
|
1
|
|
12900
|
use 5.006; |
|
1
|
|
|
|
|
2
|
|
85
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
19
|
|
86
|
1
|
|
|
1
|
|
3
|
use warnings FATAL => 'all'; |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
40
|
|
87
|
|
|
|
|
|
|
|
88
|
1
|
|
|
1
|
|
344
|
use MetaMap::DataStructures::Utterance; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
89
|
1
|
|
|
1
|
|
356
|
use MetaMap::DataStructures::Citation; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
90
|
1
|
|
|
1
|
|
4
|
use MetaMap::DataStructures::Concept; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
564
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
my $debug = 0; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# -------------------- Class methods start here -------------------- |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# method to create a new MetaMap::DataStructures object |
101
|
|
|
|
|
|
|
# input : $params <- reference to hash containing the parameters |
102
|
|
|
|
|
|
|
# output: $self <- a DataStructures object |
103
|
|
|
|
|
|
|
sub new { |
104
|
1
|
|
|
1
|
0
|
10
|
my $self = {}; |
105
|
|
|
|
|
|
|
|
106
|
1
|
|
|
|
|
1
|
my $className = shift; |
107
|
1
|
50
|
|
|
|
3
|
return undef if(ref $className); |
108
|
|
|
|
|
|
|
|
109
|
1
|
|
|
|
|
1
|
my $params = shift; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
# Bless object, initialize it and return it. |
112
|
1
|
|
|
|
|
2
|
bless($self, $className); |
113
|
|
|
|
|
|
|
|
114
|
1
|
|
|
|
|
4
|
$self->_initialize($params); |
115
|
|
|
|
|
|
|
|
116
|
1
|
|
|
|
|
2
|
return $self; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
# method to initialize the MetaMap::DataStructures object. |
119
|
|
|
|
|
|
|
# input : $parameters <- reference to a hash |
120
|
|
|
|
|
|
|
# output: - |
121
|
|
|
|
|
|
|
sub _initialize { |
122
|
1
|
|
|
1
|
|
1
|
my $self = shift; |
123
|
1
|
|
|
|
|
1
|
my $params = shift; |
124
|
|
|
|
|
|
|
|
125
|
1
|
50
|
|
|
|
2
|
$params = {} if(!defined $params); |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
# get some of the parameters |
128
|
1
|
|
|
|
|
2
|
my $debugoption = $params->{'debug'}; |
129
|
|
|
|
|
|
|
|
130
|
1
|
|
|
|
|
3
|
$self->{citations} = {}; |
131
|
|
|
|
|
|
|
|
132
|
1
|
50
|
|
|
|
3
|
if(defined $debugoption) { |
133
|
0
|
|
|
|
|
0
|
$debug = 1; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
# print out the function name to standard error |
138
|
|
|
|
|
|
|
# input : $function <- string containing function name |
139
|
|
|
|
|
|
|
# output: - |
140
|
|
|
|
|
|
|
sub _debug { |
141
|
8
|
|
|
8
|
|
11
|
my $function = shift; |
142
|
8
|
50
|
|
|
|
22
|
if($debug) { print STDERR "In MetaMap::DataStructures::$function\n"; } |
|
0
|
|
|
|
|
0
|
|
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head3 getCitations |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
description: |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
returns a hash table of Citations of this DataStrucures object |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
input: |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
None |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
output: |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
hashtable reference with Citation IDs as keys and Citation object references |
158
|
|
|
|
|
|
|
as values |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
example: |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
use MetaMap::DataStructures; |
163
|
|
|
|
|
|
|
my $datastructures = MetaMap::DataStructures->new(); |
164
|
|
|
|
|
|
|
my $citations = $datastructures->getCitations(); |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=cut |
167
|
|
|
|
|
|
|
sub getCitations { |
168
|
1
|
|
|
1
|
1
|
10
|
my $self = shift; |
169
|
|
|
|
|
|
|
|
170
|
1
|
|
|
|
|
3
|
my $function = "getCitations"; |
171
|
1
|
|
|
|
|
3
|
&_debug($function); |
172
|
|
|
|
|
|
|
|
173
|
1
|
|
|
|
|
4
|
return $self->{citations}; |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head3 getOrderedUtterances |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
description: |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
returns an ordered list of Utterances contained by the Citation. Utterances |
181
|
|
|
|
|
|
|
are ordered by title, abstract, then number in ascending order |
182
|
|
|
|
|
|
|
(e.g. ti.000.1, ti.000.2, ab.000.1, ab.000.2, ab.000.3) |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
input: |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
a reference to a Citation object |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
output: |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
array reference containing references to Utterance objects |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
example: |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
use MetaMap::DataStructures; |
195
|
|
|
|
|
|
|
my $datastructures = MetaMap::DataStructures->new(); |
196
|
|
|
|
|
|
|
my $citation = $dataStructures->getCitationWithID('01234567'); |
197
|
|
|
|
|
|
|
my $orderedUtterances = $dataStructures->getOrderedUtterances($citation); |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=cut |
200
|
|
|
|
|
|
|
sub getOrderedUtterances { |
201
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
202
|
0
|
|
|
|
|
0
|
my $citation = shift; |
203
|
|
|
|
|
|
|
|
204
|
0
|
|
|
|
|
0
|
return $citation->getOrderedUtterances(); |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=head3 getOrderedTokens |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
description: |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
returns a list of ordered Tokens within a Citation. Tokens are ordered by |
212
|
|
|
|
|
|
|
their appearance within the input text, with titles preceding abstracts |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
input: |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
a reference to a Citation object |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
output: |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
array reference containing references to Token objects |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
example: |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
use MetaMap::DataStructures; |
225
|
|
|
|
|
|
|
my $datastructures = MetaMap::DataStructures->new(); |
226
|
|
|
|
|
|
|
my $citation = $dataStructures->getCitationWithID('01234567'); |
227
|
|
|
|
|
|
|
my $orderedTokens = $dataStructures->getOrderedTokens($citation); |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=cut |
230
|
|
|
|
|
|
|
sub getOrderedTokens { |
231
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
232
|
0
|
|
|
|
|
0
|
my $citation = shift; |
233
|
|
|
|
|
|
|
|
234
|
0
|
|
|
|
|
0
|
return $citation->getOrderedTokens(); |
235
|
|
|
|
|
|
|
} |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=head3 getOrderedConcepts |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
description: |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
returns a list of ordered sub-arrays containing Concepts within a Citation. |
242
|
|
|
|
|
|
|
Each sub-array contains one or more reference to Concept objects. Where |
243
|
|
|
|
|
|
|
multiple concept objects exist is because of ambiguities. The sub-arrays are |
244
|
|
|
|
|
|
|
ordered by their Concept's appearance within the input text, with titles |
245
|
|
|
|
|
|
|
preceding abstracts. Think of this as sequentical CUIs where the second |
246
|
|
|
|
|
|
|
dimension is for when multiple CUIS map to the same Tokens due to ambiguity. |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
input: |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
a reference to a Citation object |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
output: |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
array reference containing references arrays containing references to Concept |
255
|
|
|
|
|
|
|
objects |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
example: |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
use MetaMap::DataStructures; |
260
|
|
|
|
|
|
|
my $datastructures = MetaMap::DataStructures->new(); |
261
|
|
|
|
|
|
|
my $citation = $dataStructures->getCitationWithID('01234567'); |
262
|
|
|
|
|
|
|
my $orderedConcepts = $dataStructures->getOrderedConcepts($citation); |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
=cut |
265
|
|
|
|
|
|
|
sub getOrderedConcepts { |
266
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
267
|
0
|
|
|
|
|
0
|
my $citation = shift; |
268
|
|
|
|
|
|
|
|
269
|
0
|
|
|
|
|
0
|
return $citation->getOrderedConcepts(); |
270
|
|
|
|
|
|
|
} |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=head3 getUniqueConcepts |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
description: |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
returns a hash table containing all unique Concepts with unique CUIs |
277
|
|
|
|
|
|
|
within a citation. |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
input: |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
a reference to a Citation object |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
output: |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
hashtable reference with keys of CUI codes, and values of references to Concept |
286
|
|
|
|
|
|
|
objects. Where multiple concepts of the same CUI exist, the reference is to |
287
|
|
|
|
|
|
|
the last seen Concept object |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
example: |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
use MetaMap::DataStructures; |
292
|
|
|
|
|
|
|
my $datastructures = MetaMap::DataStructures->new(); |
293
|
|
|
|
|
|
|
my $citation = $dataStructures->getCitationWithID('01234567'); |
294
|
|
|
|
|
|
|
my $uniqueConcepts = $dataStructures->getUniqueConcepts($citation); |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
=cut |
298
|
|
|
|
|
|
|
sub getUniqueConcepts { |
299
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
300
|
0
|
|
|
|
|
0
|
my $citation = shift; |
301
|
|
|
|
|
|
|
|
302
|
0
|
|
|
|
|
0
|
return $citation->getUniqueConcepts(); |
303
|
|
|
|
|
|
|
} |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
=head3 getCitationWithId |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
description: |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
returns a Citation with the specified ID |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
input: |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
string of the Citation ID |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
output: |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
reference to a Citation object |
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
example: |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
use MetaMap::DataStructures; |
322
|
|
|
|
|
|
|
my $datastructures = MetaMap::DataStructures->new(); |
323
|
|
|
|
|
|
|
my $citation = $dataStructures->getCitationWithId('01234567'); |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
=cut |
326
|
|
|
|
|
|
|
sub getCitationWithId { |
327
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
328
|
0
|
|
|
|
|
0
|
my $id = shift; |
329
|
|
|
|
|
|
|
|
330
|
0
|
|
|
|
|
0
|
my $function = "getCitationsWithId"; |
331
|
0
|
|
|
|
|
0
|
&_debug($function); |
332
|
|
|
|
|
|
|
|
333
|
0
|
|
|
|
|
0
|
return $self->{citations}{$id}; |
334
|
|
|
|
|
|
|
} |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
=head3 getOrderedMappings |
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
description: |
341
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
returns a list of ordered Mappings within a Citation. Mappings are ordered by |
343
|
|
|
|
|
|
|
their appearance within the input text, with titles preceding abstracts |
344
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
input: |
346
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
a reference to a Citation object |
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
output: |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
array reference containing references to Mapping objects |
352
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
example: |
354
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
use MetaMap::DataStructures; |
356
|
|
|
|
|
|
|
my $datastructures = MetaMap::DataStructures->new(); |
357
|
|
|
|
|
|
|
my $citation = $dataStructures->getCitationWithId('01234567'); |
358
|
|
|
|
|
|
|
my $orderedMappings = $dataStructures->getOrderedMappings($citation); |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
=cut |
361
|
|
|
|
|
|
|
sub getOrderedMappings { |
362
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
363
|
0
|
|
|
|
|
0
|
my $citation = shift; |
364
|
|
|
|
|
|
|
|
365
|
0
|
|
|
|
|
0
|
return $citation->getOrderedMappings(); |
366
|
|
|
|
|
|
|
} |
367
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
=head3 hasTitle |
369
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
description: |
371
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
returns 1 if a Citation contains a title Utterance (ID contains 'ti') |
373
|
|
|
|
|
|
|
else 0 |
374
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
input: |
376
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
a reference to a Citation object |
378
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
output: |
380
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
boolean |
382
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
example: |
384
|
|
|
|
|
|
|
|
385
|
|
|
|
|
|
|
use MetaMap::DataStructures; |
386
|
|
|
|
|
|
|
my $datastructures = MetaMap::DataStructures->new(); |
387
|
|
|
|
|
|
|
my $citation = $dataStructures->getCitationWithId('01234567'); |
388
|
|
|
|
|
|
|
my $hasTitle = $dataStructures->hasTitle($citation); |
389
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
=cut |
391
|
|
|
|
|
|
|
sub hasTitle { |
392
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
393
|
0
|
|
|
|
|
0
|
my $citation = shift; |
394
|
|
|
|
|
|
|
|
395
|
0
|
|
|
|
|
0
|
return $citation->hasTitle(); |
396
|
|
|
|
|
|
|
} |
397
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
=head3 hasAbstract |
399
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
description: |
401
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
returns 1 if a Citation contains an abstract Utterance (ID contains 'ab') |
403
|
|
|
|
|
|
|
else 0 |
404
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
input: |
406
|
|
|
|
|
|
|
|
407
|
|
|
|
|
|
|
a reference to a Citation object |
408
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
output: |
410
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
boolean |
412
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
example: |
414
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
use MetaMap::DataStructures; |
416
|
|
|
|
|
|
|
my $datastructures = MetaMap::DataStructures->new(); |
417
|
|
|
|
|
|
|
my $citation = $dataStructures->getCitationWithId('01234567'); |
418
|
|
|
|
|
|
|
my $hasAbstract = $dataStructures->hasAbstract($citation); |
419
|
|
|
|
|
|
|
|
420
|
|
|
|
|
|
|
=cut |
421
|
|
|
|
|
|
|
sub hasAbstract { |
422
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
423
|
0
|
|
|
|
|
0
|
my $citation = shift; |
424
|
|
|
|
|
|
|
|
425
|
0
|
|
|
|
|
0
|
return $citation->hasAbstract(); |
426
|
|
|
|
|
|
|
} |
427
|
|
|
|
|
|
|
|
428
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
=head3 createFromText |
430
|
|
|
|
|
|
|
|
431
|
|
|
|
|
|
|
description: |
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
updates MetaMap Data structures with the text of the input string |
434
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
input: |
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
string of MetaMap Prolg Output containing an utterance, or list of utterances |
438
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
output: |
440
|
|
|
|
|
|
|
|
441
|
|
|
|
|
|
|
None |
442
|
|
|
|
|
|
|
|
443
|
|
|
|
|
|
|
example: |
444
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
use MetaMap::DataStructures; |
446
|
|
|
|
|
|
|
my $datastructures = MetaMap::DataStructures->new(); |
447
|
|
|
|
|
|
|
$datastructures->createFromText($text); |
448
|
|
|
|
|
|
|
|
449
|
|
|
|
|
|
|
=cut |
450
|
|
|
|
|
|
|
sub createFromText { |
451
|
7
|
|
|
7
|
1
|
1065
|
my $self = shift; |
452
|
7
|
|
|
|
|
354
|
my $input = shift; |
453
|
|
|
|
|
|
|
|
454
|
7
|
|
|
|
|
11
|
my $function = "createFromText"; |
455
|
7
|
|
|
|
|
22
|
&_debug($function); |
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
#create the new utterance |
458
|
7
|
|
|
|
|
30
|
my $newUtterance = |
459
|
|
|
|
|
|
|
MetaMap::DataStructures::Utterance->createFromText($input); |
460
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
#add to a citation |
462
|
7
|
|
|
|
|
45
|
$input =~ /utterance\('([\d]+)\./; |
463
|
7
|
|
|
|
|
11
|
my $pmid = $1; |
464
|
|
|
|
|
|
|
|
465
|
7
|
50
|
|
|
|
17
|
if($debug) { print STDERR " Processing $pmid\n"; } |
|
0
|
|
|
|
|
0
|
|
466
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
#create a new citation (if needed) |
468
|
7
|
100
|
|
|
|
30
|
if (!(exists $self->{citations}{$pmid})) { |
469
|
1
|
|
|
|
|
13
|
$self->{citations}{$pmid} = |
470
|
|
|
|
|
|
|
MetaMap::DataStructures::Citation->new($pmid); |
471
|
1
|
50
|
|
|
|
3
|
if($debug) { |
472
|
0
|
|
|
|
|
0
|
print STDERR " Additing Citation: $pmid\n"; |
473
|
|
|
|
|
|
|
} |
474
|
|
|
|
|
|
|
} |
475
|
|
|
|
|
|
|
#add utterance to the citations |
476
|
7
|
|
|
|
|
46
|
$self->{citations}{$pmid}->addUtterance($newUtterance); |
477
|
|
|
|
|
|
|
} |
478
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
=head3 createFromTextWithId |
480
|
|
|
|
|
|
|
|
481
|
|
|
|
|
|
|
description: |
482
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
updates MetaMap Data structures with the text of the input string, and gives |
484
|
|
|
|
|
|
|
the addition the ID provided |
485
|
|
|
|
|
|
|
|
486
|
|
|
|
|
|
|
input: |
487
|
|
|
|
|
|
|
|
488
|
|
|
|
|
|
|
string of MetaMap Prolg Output containing an utterance, or list of utterances |
489
|
|
|
|
|
|
|
string ID of the utterance or list of utterances to add |
490
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
output: |
492
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
None |
494
|
|
|
|
|
|
|
|
495
|
|
|
|
|
|
|
example: |
496
|
|
|
|
|
|
|
|
497
|
|
|
|
|
|
|
use MetaMap::DataStructures; |
498
|
|
|
|
|
|
|
my $datastructures = MetaMap::DataStructures->new(); |
499
|
|
|
|
|
|
|
$datastructures->createFromTextWithID($text,'01234567'); |
500
|
|
|
|
|
|
|
|
501
|
|
|
|
|
|
|
=cut |
502
|
|
|
|
|
|
|
sub createFromTextWithId { |
503
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
504
|
0
|
|
|
|
|
|
my $input = shift; |
505
|
0
|
|
|
|
|
|
my $id = shift; |
506
|
|
|
|
|
|
|
|
507
|
0
|
|
|
|
|
|
my $function = "createFromTextWithId"; |
508
|
0
|
|
|
|
|
|
&_debug($function); |
509
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
#create the new utterance |
511
|
0
|
|
|
|
|
|
my $newUtterance = |
512
|
|
|
|
|
|
|
MetaMap::DataStructures::Utterance->createFromTextWithId($input, $id); |
513
|
|
|
|
|
|
|
|
514
|
0
|
0
|
|
|
|
|
if($debug) { print STDERR " Processing $id\n"; } |
|
0
|
|
|
|
|
|
|
515
|
|
|
|
|
|
|
|
516
|
|
|
|
|
|
|
#create a new citation (if needed) |
517
|
0
|
0
|
|
|
|
|
if (!(exists $self->{citations}{$id})) { |
518
|
0
|
|
|
|
|
|
$self->{citations}{$id} = MetaMap::DataStructures::Citation->new($id); |
519
|
0
|
0
|
|
|
|
|
if($debug) { |
520
|
0
|
|
|
|
|
|
print STDERR " Additing Citation: $id\n"; |
521
|
|
|
|
|
|
|
} |
522
|
|
|
|
|
|
|
} |
523
|
|
|
|
|
|
|
#add utterance to the citations |
524
|
0
|
|
|
|
|
|
$self->{citations}{$id}->addUtterance($newUtterance); |
525
|
|
|
|
|
|
|
} |
526
|
|
|
|
|
|
|
|
527
|
|
|
|
|
|
|
1; |
528
|
|
|
|
|
|
|
|
529
|
|
|
|
|
|
|
|
530
|
|
|
|
|
|
|
=head1 SEE ALSO |
531
|
|
|
|
|
|
|
|
532
|
|
|
|
|
|
|
=head1 AUTHOR |
533
|
|
|
|
|
|
|
|
534
|
|
|
|
|
|
|
Sam Henry |
535
|
|
|
|
|
|
|
Bridget T McInnes |
536
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
=head1 COPYRIGHT |
538
|
|
|
|
|
|
|
|
539
|
|
|
|
|
|
|
Copyright (c) 2016 |
540
|
|
|
|
|
|
|
Sam Henry, Virginia Commonwealth University |
541
|
|
|
|
|
|
|
henryst at vcu.edu |
542
|
|
|
|
|
|
|
|
543
|
|
|
|
|
|
|
Bridget T. McInnes, Virginia Commonwealth University |
544
|
|
|
|
|
|
|
btmcinnes at vcu.edu |
545
|
|
|
|
|
|
|
|
546
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under |
547
|
|
|
|
|
|
|
the terms of the GNU General Public License as published by the Free Software |
548
|
|
|
|
|
|
|
Foundation; either version 2 of the License, or (at your option) any later |
549
|
|
|
|
|
|
|
version. |
550
|
|
|
|
|
|
|
|
551
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT |
552
|
|
|
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
553
|
|
|
|
|
|
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
554
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with |
556
|
|
|
|
|
|
|
this program; if not, write to |
557
|
|
|
|
|
|
|
|
558
|
|
|
|
|
|
|
The Free Software Foundation, Inc., |
559
|
|
|
|
|
|
|
59 Temple Place - Suite 330, |
560
|
|
|
|
|
|
|
Boston, MA 02111-1307, USA. |
561
|
|
|
|
|
|
|
|
562
|
|
|
|
|
|
|
=cut |