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
|
|
13177
|
use 5.006; |
|
1
|
|
|
|
|
3
|
|
85
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
17
|
|
86
|
1
|
|
|
1
|
|
3
|
use warnings FATAL => 'all'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
41
|
|
87
|
|
|
|
|
|
|
|
88
|
1
|
|
|
1
|
|
342
|
use MetaMap::DataStructures::Utterance; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
89
|
1
|
|
|
1
|
|
386
|
use MetaMap::DataStructures::Citation; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
90
|
1
|
|
|
1
|
|
4
|
use MetaMap::DataStructures::Concept; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
536
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
my $debug = 0; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
my %citations = (); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# -------------------- Class methods start here -------------------- |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# method to create a new MetaMap::DataStructures object |
103
|
|
|
|
|
|
|
# input : $params <- reference to hash containing the parameters |
104
|
|
|
|
|
|
|
# output: $self <- a DataStructures object |
105
|
|
|
|
|
|
|
sub new { |
106
|
1
|
|
|
1
|
0
|
10
|
my $self = {}; |
107
|
|
|
|
|
|
|
|
108
|
1
|
|
|
|
|
2
|
my $className = shift; |
109
|
1
|
50
|
|
|
|
3
|
return undef if(ref $className); |
110
|
|
|
|
|
|
|
|
111
|
1
|
|
|
|
|
1
|
my $params = shift; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
# Bless object, initialize it and return it. |
114
|
1
|
|
|
|
|
1
|
bless($self, $className); |
115
|
|
|
|
|
|
|
|
116
|
1
|
|
|
|
|
4
|
$self->_initialize($params); |
117
|
|
|
|
|
|
|
|
118
|
1
|
|
|
|
|
2
|
return $self; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
# method to initialize the MetaMap::DataStructures object. |
121
|
|
|
|
|
|
|
# input : $parameters <- reference to a hash |
122
|
|
|
|
|
|
|
# output: - |
123
|
|
|
|
|
|
|
sub _initialize { |
124
|
1
|
|
|
1
|
|
1
|
my $self = shift; |
125
|
1
|
|
|
|
|
1
|
my $params = shift; |
126
|
|
|
|
|
|
|
|
127
|
1
|
50
|
|
|
|
3
|
$params = {} if(!defined $params); |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
# get some of the parameters |
130
|
1
|
|
|
|
|
2
|
my $debugoption = $params->{'debug'}; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
|
133
|
1
|
50
|
|
|
|
2
|
if(defined $debugoption) { |
134
|
0
|
|
|
|
|
0
|
$debug = 1; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
# print out the function name to standard error |
139
|
|
|
|
|
|
|
# input : $function <- string containing function name |
140
|
|
|
|
|
|
|
# output: - |
141
|
|
|
|
|
|
|
sub _debug { |
142
|
8
|
|
|
8
|
|
9
|
my $function = shift; |
143
|
8
|
50
|
|
|
|
23
|
if($debug) { print STDERR "In MetaMap::DataStructures::$function\n"; } |
|
0
|
|
|
|
|
0
|
|
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head3 getCitations |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
description: |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
returns a hash table of Citations of this DataStrucures object |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
input: |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
None |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
output: |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
hashtable reference with Citation IDs as keys and Citation object references |
159
|
|
|
|
|
|
|
as values |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
example: |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
use MetaMap::DataStructures; |
164
|
|
|
|
|
|
|
my $datastructures = MetaMap::DataStructures->new(); |
165
|
|
|
|
|
|
|
my $citations = $datastructures->getCitations(); |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=cut |
168
|
|
|
|
|
|
|
sub getCitations { |
169
|
1
|
|
|
1
|
1
|
7
|
my $self = shift; |
170
|
|
|
|
|
|
|
|
171
|
1
|
|
|
|
|
2
|
my $function = "getCitations"; |
172
|
1
|
|
|
|
|
3
|
&_debug($function); |
173
|
|
|
|
|
|
|
|
174
|
1
|
|
|
|
|
2
|
return \%citations; |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head3 getOrderedUtterances |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
description: |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
returns an ordered list of Utterances contained by the Citation. Utterances |
182
|
|
|
|
|
|
|
are ordered by title, abstract, then number in ascending order |
183
|
|
|
|
|
|
|
(e.g. ti.000.1, ti.000.2, ab.000.1, ab.000.2, ab.000.3) |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
input: |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
a reference to a Citation object |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
output: |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
array reference containing references to Utterance objects |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
example: |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
use MetaMap::DataStructures; |
196
|
|
|
|
|
|
|
my $datastructures = MetaMap::DataStructures->new(); |
197
|
|
|
|
|
|
|
my $citation = $dataStructures->getCitationWithID('01234567'); |
198
|
|
|
|
|
|
|
my $orderedUtterances = $dataStructures->getOrderedUtterances($citation); |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=cut |
201
|
|
|
|
|
|
|
sub getOrderedUtterances { |
202
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
203
|
0
|
|
|
|
|
0
|
my $citation = shift; |
204
|
|
|
|
|
|
|
|
205
|
0
|
|
|
|
|
0
|
return $citation->getOrderedUtterances(); |
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=head3 getOrderedTokens |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
description: |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
returns a list of ordered Tokens within a Citation. Tokens are ordered by |
213
|
|
|
|
|
|
|
their appearance within the input text, with titles preceding abstracts |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
input: |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
a reference to a Citation object |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
output: |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
array reference containing references to Token objects |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
example: |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
use MetaMap::DataStructures; |
226
|
|
|
|
|
|
|
my $datastructures = MetaMap::DataStructures->new(); |
227
|
|
|
|
|
|
|
my $citation = $dataStructures->getCitationWithID('01234567'); |
228
|
|
|
|
|
|
|
my $orderedTokens = $dataStructures->getOrderedTokens($citation); |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=cut |
231
|
|
|
|
|
|
|
sub getOrderedTokens { |
232
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
233
|
0
|
|
|
|
|
0
|
my $citation = shift; |
234
|
|
|
|
|
|
|
|
235
|
0
|
|
|
|
|
0
|
return $citation->getOrderedTokens(); |
236
|
|
|
|
|
|
|
} |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=head3 getOrderedConcepts |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
description: |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
returns a list of ordered sub-arrays containing Concepts within a Citation. |
243
|
|
|
|
|
|
|
Each sub-array contains one or more reference to Concept objects. Where |
244
|
|
|
|
|
|
|
multiple concept objects exist is because of ambiguities. The sub-arrays are |
245
|
|
|
|
|
|
|
ordered by their Concept's appearance within the input text, with titles |
246
|
|
|
|
|
|
|
preceding abstracts. Think of this as sequentical CUIs where the second |
247
|
|
|
|
|
|
|
dimension is for when multiple CUIS map to the same Tokens due to ambiguity. |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
input: |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
a reference to a Citation object |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
output: |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
array reference containing references arrays containing references to Concept |
256
|
|
|
|
|
|
|
objects |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
example: |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
use MetaMap::DataStructures; |
261
|
|
|
|
|
|
|
my $datastructures = MetaMap::DataStructures->new(); |
262
|
|
|
|
|
|
|
my $citation = $dataStructures->getCitationWithID('01234567'); |
263
|
|
|
|
|
|
|
my $orderedConcepts = $dataStructures->getOrderedConcepts($citation); |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=cut |
266
|
|
|
|
|
|
|
sub getOrderedConcepts { |
267
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
268
|
0
|
|
|
|
|
0
|
my $citation = shift; |
269
|
|
|
|
|
|
|
|
270
|
0
|
|
|
|
|
0
|
return $citation->getOrderedConcepts(); |
271
|
|
|
|
|
|
|
} |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
=head3 getUniqueConcepts |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
description: |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
returns a hash table containing all unique Concepts with unique CUIs |
278
|
|
|
|
|
|
|
within a citation. |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
input: |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
a reference to a Citation object |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
output: |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
hashtable reference with keys of CUI codes, and values of references to Concept |
287
|
|
|
|
|
|
|
objects. Where multiple concepts of the same CUI exist, the reference is to |
288
|
|
|
|
|
|
|
the last seen Concept object |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
example: |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
use MetaMap::DataStructures; |
293
|
|
|
|
|
|
|
my $datastructures = MetaMap::DataStructures->new(); |
294
|
|
|
|
|
|
|
my $citation = $dataStructures->getCitationWithID('01234567'); |
295
|
|
|
|
|
|
|
my $uniqueConcepts = $dataStructures->getUniqueConcepts($citation); |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
=cut |
299
|
|
|
|
|
|
|
sub getUniqueConcepts { |
300
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
301
|
0
|
|
|
|
|
0
|
my $citation = shift; |
302
|
|
|
|
|
|
|
|
303
|
0
|
|
|
|
|
0
|
return $citation->getUniqueConcepts(); |
304
|
|
|
|
|
|
|
} |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
=head3 getCitationWithId |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
description: |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
returns a Citation with the specified ID |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
input: |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
string of the Citation ID |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
output: |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
reference to a Citation object |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
example: |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
use MetaMap::DataStructures; |
323
|
|
|
|
|
|
|
my $datastructures = MetaMap::DataStructures->new(); |
324
|
|
|
|
|
|
|
my $citation = $dataStructures->getCitationWithId('01234567'); |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
=cut |
327
|
|
|
|
|
|
|
sub getCitationWithId { |
328
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
329
|
0
|
|
|
|
|
0
|
my $id = shift; |
330
|
|
|
|
|
|
|
|
331
|
0
|
|
|
|
|
0
|
my $function = "getCitationsWithId"; |
332
|
0
|
|
|
|
|
0
|
&_debug($function); |
333
|
|
|
|
|
|
|
|
334
|
0
|
|
|
|
|
0
|
return $citations{$id}; |
335
|
|
|
|
|
|
|
} |
336
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
=head3 getOrderedMappings |
340
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
description: |
342
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
returns a list of ordered Mappings within a Citation. Mappings are ordered by |
344
|
|
|
|
|
|
|
their appearance within the input text, with titles preceding abstracts |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
input: |
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
a reference to a Citation object |
349
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
output: |
351
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
array reference containing references to Mapping objects |
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
example: |
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
use MetaMap::DataStructures; |
357
|
|
|
|
|
|
|
my $datastructures = MetaMap::DataStructures->new(); |
358
|
|
|
|
|
|
|
my $citation = $dataStructures->getCitationWithId('01234567'); |
359
|
|
|
|
|
|
|
my $orderedMappings = $dataStructures->getOrderedMappings($citation); |
360
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
=cut |
362
|
|
|
|
|
|
|
sub getOrderedMappings { |
363
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
364
|
0
|
|
|
|
|
0
|
my $citation = shift; |
365
|
|
|
|
|
|
|
|
366
|
0
|
|
|
|
|
0
|
return $citation->getOrderedMappings(); |
367
|
|
|
|
|
|
|
} |
368
|
|
|
|
|
|
|
|
369
|
|
|
|
|
|
|
=head3 hasTitle |
370
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
description: |
372
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
returns 1 if a Citation contains a title Utterance (ID contains 'ti') |
374
|
|
|
|
|
|
|
else 0 |
375
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
input: |
377
|
|
|
|
|
|
|
|
378
|
|
|
|
|
|
|
a reference to a Citation object |
379
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
output: |
381
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
boolean |
383
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
example: |
385
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
use MetaMap::DataStructures; |
387
|
|
|
|
|
|
|
my $datastructures = MetaMap::DataStructures->new(); |
388
|
|
|
|
|
|
|
my $citation = $dataStructures->getCitationWithId('01234567'); |
389
|
|
|
|
|
|
|
my $hasTitle = $dataStructures->hasTitle($citation); |
390
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
=cut |
392
|
|
|
|
|
|
|
sub hasTitle { |
393
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
394
|
0
|
|
|
|
|
0
|
my $citation = shift; |
395
|
|
|
|
|
|
|
|
396
|
0
|
|
|
|
|
0
|
return $citation->hasTitle(); |
397
|
|
|
|
|
|
|
} |
398
|
|
|
|
|
|
|
|
399
|
|
|
|
|
|
|
=head3 hasAbstract |
400
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
description: |
402
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
returns 1 if a Citation contains an abstract Utterance (ID contains 'ab') |
404
|
|
|
|
|
|
|
else 0 |
405
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
input: |
407
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
a reference to a Citation object |
409
|
|
|
|
|
|
|
|
410
|
|
|
|
|
|
|
output: |
411
|
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
boolean |
413
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
example: |
415
|
|
|
|
|
|
|
|
416
|
|
|
|
|
|
|
use MetaMap::DataStructures; |
417
|
|
|
|
|
|
|
my $datastructures = MetaMap::DataStructures->new(); |
418
|
|
|
|
|
|
|
my $citation = $dataStructures->getCitationWithId('01234567'); |
419
|
|
|
|
|
|
|
my $hasAbstract = $dataStructures->hasAbstract($citation); |
420
|
|
|
|
|
|
|
|
421
|
|
|
|
|
|
|
=cut |
422
|
|
|
|
|
|
|
sub hasAbstract { |
423
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
424
|
0
|
|
|
|
|
0
|
my $citation = shift; |
425
|
|
|
|
|
|
|
|
426
|
0
|
|
|
|
|
0
|
return $citation->hasAbstract(); |
427
|
|
|
|
|
|
|
} |
428
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
|
430
|
|
|
|
|
|
|
=head3 createFromText |
431
|
|
|
|
|
|
|
|
432
|
|
|
|
|
|
|
description: |
433
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
updates MetaMap Data structures with the text of the input string |
435
|
|
|
|
|
|
|
|
436
|
|
|
|
|
|
|
input: |
437
|
|
|
|
|
|
|
|
438
|
|
|
|
|
|
|
string of MetaMap Prolg Output containing an utterance, or list of utterances |
439
|
|
|
|
|
|
|
|
440
|
|
|
|
|
|
|
output: |
441
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
None |
443
|
|
|
|
|
|
|
|
444
|
|
|
|
|
|
|
example: |
445
|
|
|
|
|
|
|
|
446
|
|
|
|
|
|
|
use MetaMap::DataStructures; |
447
|
|
|
|
|
|
|
my $datastructures = MetaMap::DataStructures->new(); |
448
|
|
|
|
|
|
|
$datastructures->createFromText($text); |
449
|
|
|
|
|
|
|
|
450
|
|
|
|
|
|
|
=cut |
451
|
|
|
|
|
|
|
sub createFromText { |
452
|
7
|
|
|
7
|
1
|
1049
|
my $self = shift; |
453
|
7
|
|
|
|
|
281
|
my $input = shift; |
454
|
|
|
|
|
|
|
|
455
|
7
|
|
|
|
|
10
|
my $function = "createFromText"; |
456
|
7
|
|
|
|
|
19
|
&_debug($function); |
457
|
|
|
|
|
|
|
|
458
|
|
|
|
|
|
|
#create the new utterance |
459
|
7
|
|
|
|
|
24
|
my $newUtterance = |
460
|
|
|
|
|
|
|
MetaMap::DataStructures::Utterance->createFromText($input); |
461
|
|
|
|
|
|
|
|
462
|
|
|
|
|
|
|
#add to a citation |
463
|
7
|
|
|
|
|
33
|
$input =~ /utterance\('([\d]+)\./; |
464
|
7
|
|
|
|
|
13
|
my $pmid = $1; |
465
|
|
|
|
|
|
|
|
466
|
7
|
50
|
|
|
|
16
|
if($debug) { print STDERR " Processing $pmid\n"; } |
|
0
|
|
|
|
|
0
|
|
467
|
|
|
|
|
|
|
|
468
|
|
|
|
|
|
|
#create a new citation (if needed) |
469
|
7
|
100
|
|
|
|
22
|
if (!(exists $citations{$pmid})) { |
470
|
1
|
|
|
|
|
11
|
$citations{$pmid} = MetaMap::DataStructures::Citation->new($pmid); |
471
|
1
|
50
|
|
|
|
2
|
if($debug) { |
472
|
0
|
|
|
|
|
0
|
print STDERR " Additing Citation: $pmid\n"; |
473
|
|
|
|
|
|
|
} |
474
|
|
|
|
|
|
|
} |
475
|
|
|
|
|
|
|
#add utterance to the citations |
476
|
7
|
|
|
|
|
39
|
$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 $citations{$id})) { |
518
|
0
|
|
|
|
|
|
$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
|
|
|
|
|
|
$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 |