line
stmt
bran
cond
sub
pod
time
code
1
############################################################
2
#
3
# Bib::CrossRef - Uses crossref to robustly parse bibliometric references.
4
#
5
############################################################
6
7
package Bib::CrossRef;
8
9
1
1
54320
use 5.8.8;
1
10
10
1
1
4
use strict;
1
1
1
17
11
1
1
4
use warnings;
1
1
1
39
12
1
1
4
no warnings 'uninitialized';
1
2
1
37
13
14
require Exporter;
15
1
1
555
use LWP::UserAgent;
1
39432
1
33
16
1
1
611
use JSON qw/decode_json/;
1
8010
1
4
17
1
1
141
use URI::Escape qw(uri_escape_utf8 uri_unescape);
1
2
1
54
18
1
1
382
use HTML::Entities qw(decode_entities encode_entities);
1
4395
1
62
19
1
1
685
use XML::Simple;
1
7491
1
7
20
1
1
71
use vars qw($VERSION @EXPORT @EXPORT_OK %EXPORT_TAGS @ISA);
1
2
1
1060
21
22
#use Data::Dumper;
23
24
$VERSION = '0.11';
25
@ISA = qw(Exporter);
26
@EXPORT = qw();
27
@EXPORT_OK = qw(
28
sethtml clearhtml parse_text parse_doi print printheader printfooter
29
doi score date atitle jtitle volume issue genre spage epage authcount auth query
30
);
31
%EXPORT_TAGS = (all => \@EXPORT_OK);
32
# disable SSL cert checking
33
$ENV{'PERL_LWP_SSL_VERIFY_HOSTNAME'} = 0;
34
35
sub new {
36
2
2
1
530
my $self;
37
2
5
$self->{html} = 0; # use html for error messages ?
38
2
5
$self->{ref} = {}; # the reference itself
39
2
3
bless $self;
40
2
4
return $self;
41
}
42
43
sub sethtml {
44
1
1
1
922
$_[0]->{html} = 1;
45
}
46
47
sub clearhtml {
48
0
0
1
0
$_[0]->{html} = 0;
49
}
50
51
sub _err {
52
1
1
14
my ($self, $str) = @_;
53
1
50
4
if ($self->{html}) {
54
0
0
print "",$str,"
";
55
} else {
56
1
70
print $str,"\n";
57
}
58
}
59
60
sub doi {
61
3
3
1
6
my $self = shift @_;
62
3
7
return $self->{ref}->{'doi'};
63
}
64
65
sub _setdoi {
66
1
1
412
my $self = shift @_;
67
1
11
my $val = shift @_;
68
1
4
$self->{ref}->{'doi'}=$val;
69
}
70
71
sub url {
72
1
1
1
2
my $self = shift @_;
73
1
4
return $self->{ref}->{'url'};
74
}
75
76
sub _seturl {
77
0
0
0
my $self = shift @_;
78
0
0
my $val = shift @_;
79
0
0
$self->{ref}->{'url'}=$val;
80
}
81
82
sub score {
83
2
2
1
4
my $self = shift @_;
84
2
6
return $self->{ref}->{'score'};
85
}
86
87
sub _setscore {
88
1
1
2
my $self = shift @_;
89
1
2
my $val = shift @_;
90
1
3
$self->{ref}->{'score'}=$val;
91
}
92
93
sub atitle {
94
2
2
1
4
my $self = shift @_;
95
2
6
return $self->{ref}->{'atitle'};
96
}
97
98
sub _setatitle {
99
1
1
2
my $self = shift @_;
100
1
2
my $val = shift @_;
101
1
3
$self->{ref}->{'atitle'}=$val;
102
}
103
104
sub jtitle {
105
2
2
1
3
my $self = shift @_;
106
2
8
return $self->{ref}->{'jtitle'};
107
}
108
109
sub _setjtitle {
110
1
1
2
my $self = shift @_;
111
1
2
my $val = shift @_;
112
1
3
$self->{ref}->{'jtitle'}=$val;
113
}
114
115
sub volume {
116
3
3
1
3
my $self = shift @_;
117
3
9
return $self->{ref}->{'volume'};
118
}
119
120
sub _setvolume {
121
1
1
3
my $self = shift @_;
122
1
2
my $val = shift @_;
123
1
2
$self->{ref}->{'volume'}=$val;
124
}
125
126
sub issue {
127
3
3
1
4
my $self = shift @_;
128
3
7
return $self->{ref}->{'issue'};
129
}
130
131
sub _setissue {
132
1
1
2
my $self = shift @_;
133
1
2
my $val = shift @_;
134
1
3
$self->{ref}->{'issue'}=$val;
135
}
136
137
sub date {
138
2
2
1
4
my $self = shift @_;
139
2
12
return $self->{ref}->{'date'};
140
}
141
142
sub _setdate {
143
1
1
2
my $self = shift @_;
144
1
2
my $val = shift @_;
145
1
3
$self->{ref}->{'date'}=$val;
146
}
147
148
sub genre {
149
2
2
1
3
my $self = shift @_;
150
2
6
return $self->{ref}->{'genre'};
151
}
152
153
sub _setgenre {
154
1
1
2
my $self = shift @_;
155
1
3
my $val = shift @_;
156
1
3
$self->{ref}->{'genre'}=$val;
157
}
158
159
sub spage {
160
3
3
1
4
my $self = shift @_;
161
3
10
return $self->{ref}->{'spage'};
162
}
163
164
sub _setspage {
165
1
1
2
my $self = shift @_;
166
1
3
my $val = shift @_;
167
1
2
$self->{ref}->{'spage'}=$val;
168
}
169
170
sub epage {
171
3
3
1
5
my $self = shift @_;
172
3
11
return $self->{ref}->{'epage'};
173
}
174
175
sub _setepage {
176
1
1
2
my $self = shift @_;
177
1
2
my $val = shift @_;
178
1
3
$self->{ref}->{'epage'}=$val;
179
}
180
181
sub authcount {
182
4
4
1
5
my $self = shift @_;
183
4
11
return $self->{ref}->{'authcount'};
184
}
185
186
sub _setauthcount {
187
1
1
2
my $self = shift @_;
188
1
2
my $val = shift @_;
189
1
3
$self->{ref}->{'authcount'}=$val;
190
}
191
192
sub auth {
193
4
4
1
8
my ($self, $num) = @_;
194
4
14
return $self->{ref}->{'au'.$num};
195
}
196
197
sub _setauth {
198
2
2
4
my $self = shift @_;
199
2
3
my $i = shift @_;
200
2
3
my $val = shift @_;
201
2
5
$self->{ref}->{'au'.$i}=$val;
202
}
203
204
sub query {
205
1
1
1
1
my $self = shift @_;
206
1
4
return $self->{ref}->{'query'};
207
}
208
209
sub _setquery {
210
0
0
0
my $self = shift @_;
211
0
0
my $val = shift @_;
212
0
0
$self->{ref}->{'query'}=$val;
213
}
214
215
sub parse_text {
216
# given free format text, use crossref.org to try to convert into a paper reference and doi
217
1
1
1
301
my ($self, $cites) = @_;
218
219
1
2
my $cites_clean = $cites;
220
# tidy up string, escape nasty characters etc.
221
1
11
$cites_clean =~ s/\s+/+/g; #$cites_clean = uri_escape_utf8($cites_clean);
222
# crossref like us to give a mailto email when making request so they can get in touch if the script is generating errors,
223
# feel free to change the email address here to something more appropriate
224
# change to using /works API instead of /dois API
225
1
9
my $req = HTTP::Request->new(GET => 'https://api.crossref.org/works?mailto=doug@leith.ie&rows=1&query='.$cites_clean);
226
1
6667
my $ua = LWP::UserAgent->new;
227
1
2317
my $res = $ua->request($req);
228
1
50
1533
if ($res->is_success) {
229
# extract json response
230
0
0
my $json = decode_json($res->decoded_content);
231
1
1
544
use Data::Dumper;
1
5529
1
2020
232
#print Dumper($json->{'message'}{'items'});
233
0
0
my $ref={};
234
# keep a record of the query string we used
235
0
0
$ref->{'query'} = $cites;
236
0
0
my $response = $json->{'message'}{'items'}[0];
237
#print Dumper($response);
238
# extract doi and matching score
239
0
0
$ref->{'doi'} = $response->{'DOI'};
240
0
0
$ref->{'doi'} =~ s/http:\/\/dx.doi.org\///; # remove any http header
241
0
0
$ref->{'url'} = $response->{'URL'};
242
0
0
$ref->{'score'} = $response->{'score'}; #$json->[0]{'normalizedScore'};
243
0
0
$ref->{'issue'} = $response->{'journal-issue'}{'issue'};
244
0
0
$ref->{'genre'} = $response->{'type'};
245
0
0
0
if ($ref->{'genre'} eq 'journal-article') { $ref->{'genre'}='article';} # for backward compatibility
0
0
246
0
0
$ref->{'jtitle'} = $response->{'container-title'}[0];
247
0
0
$ref->{'atitle'} = $response->{'title'}[0];
248
0
0
$ref->{'volume'} = $response->{'volume'};
249
0
0
my @bits = split /-/, $response->{'page'};
250
0
0
$ref->{'spage'} = $bits[0];
251
0
0
$ref->{'epage'} = $bits[1];
252
0
0
$ref->{'date'} = $response->{'issued'}{'date-parts'}[0][0];
253
0
0
$ref->{'authcount'}=0;
254
0
0
while (defined $response->{'author'}[$ref->{'authcount'}]) {
255
0
0
my $val = $response->{'author'}[$ref->{'authcount'}];
256
#print Dumper($val);
257
0
0
$ref->{'authcount'}++;
258
0
0
$ref->{'au'.$ref->{'authcount'}} = $val->{'given'}.' '.$val->{'family'};
259
}
260
261
0
0
$self->{ref} = $ref;
262
} else {
263
1
13
$self->_err("Problem with search.crossref.org: ".$res->status_line);
264
}
265
}
266
267
sub parse_doi {
268
# given a DOI, use unixref interface to convert into a full citation
269
0
0
1
0
my ($self, $doi) = @_;
270
271
0
0
my $req = HTTP::Request->new(GET =>'http://dx.doi.org/'.$doi,['Accept' =>'application/vnd.crossref.unixsd+xml']);
272
0
0
my $ua = LWP::UserAgent->new;
273
0
0
my $res = $ua->request($req);
274
0
0
0
if ($res->is_success) {
275
# now parse the xml
276
0
0
my $xs = XML::Simple->new();
277
0
0
my $data = $xs->XMLin($res->decoded_content);
278
0
0
my $cite = $data->{'query_result'}->{'body'}->{'query'}->{'doi_record'}->{'crossref'};
279
0
0
my $cc = undef;
280
0
0
0
if (exists($cite->{'conference'})) {
0
0
281
0
0
$self->_setgenre('proceeding');
282
0
0
0
if (exists($cite->{'conference'}->{'proceedings_metadata'})) {
283
0
0
$self->_setjtitle($cite->{'conference'}->{'proceedings_metadata'}->{'proceedings_title'});
284
0
0
0
if (exists $cite->{'conference'}->{'proceedings_metadata'}->{'publication_date'}) {$self->_setdate($cite->{'conference'}->{'proceedings_metadata'}->{'publication_date'}->{'year'});}
0
0
285
} else {
286
0
0
$self->_setjtitle($cite->{'conference'}->{'proceedings_series_metadata'}->{'series_metadata'}->{'proceedings_title'});
287
0
0
$self->_setvolume($cite->{'conference'}->{'proceedings_series_metadata'}->{'series_metadata'}->{'volume'});
288
0
0
0
if (exists $cite->{'conference'}->{'proceedings_series_metadata'}->{'publication_date'}) {$self->_setdate($cite->{'conference'}->{'proceedings_series_metadata'}->{'publication_date'}->{'year'});}
0
0
289
}
290
0
0
$cc = $cite->{'conference'}->{'conference_paper'};
291
} elsif (exists($cite->{'journal'})) {
292
0
0
$self->_setgenre('article');
293
0
0
$self->_setjtitle($cite->{'journal'}->{'journal_metadata'}->{'full_title'});
294
0
0
$cc = $cite->{'journal'}->{'journal_issue'};
295
0
0
0
if (exists($cc->{'journal_volume'})) {$self->_setvolume($cc->{'journal_volume'}->{'volume'});}
0
0
296
0
0
0
if (exists($cc->{'issue'})) {$self->_setissue($cc->{'issue'});}
0
0
297
0
0
$cc = $cite->{'journal'}->{'journal_article'};
298
} elsif (exists($cite->{'book'})) {
299
0
0
0
if ($cite->{'book'}->{'book_type'} ne 'other' ) {
300
0
0
$self->_setgenre('book');
301
} else {
302
0
0
$self->_setgenre('bookitem');
303
}
304
0
0
my $jtitle = '';
305
0
0
0
if (exists($cite->{'book'}->{'book_series_metadata'})) {
0
306
0
0
0
if (exists($cite->{'book'}->{'book_series_metadata'}->{'titles'}->{'title'})) {
307
0
0
$jtitle .= $cite->{'book'}->{'book_series_metadata'}->{'titles'}->{'title'}.': ';
308
}
309
0
0
$jtitle .= $cite->{'book'}->{'book_series_metadata'}->{'series_metadata'}->{'titles'}->{'title'};
310
0
0
$self->_setvolume($cite->{'book'}->{'book_series_metadata'}->{'volume'});
311
0
0
0
if (exists $cite->{'book'}->{'book_series_metadata'}->{'publication_date'}) {$self->_setdate($cite->{'book'}->{'book_series_metadata'}->{'publication_date'}->{'year'});}
0
0
312
} elsif (exists($cite->{'book'}->{'book_metadata'})) {
313
0
0
$jtitle .= $cite->{'book'}->{'book_metadata'}->{'titles'}->{'title'};
314
0
0
0
if (exists($cite->{'book'}->{'book_metadata'}->{'series_metadata'}->{'titles'}->{'title'})) {
315
0
0
$jtitle .= ": ".$cite->{'book'}->{'book_metadata'}->{'series_metadata'}->{'titles'}->{'title'};
316
0
0
0
if (exists $cite->{'book'}->{'book_metadata'}->{'series_metadata'}->{'volume'}) {$self->_setvolume($cite->{'book'}->{'book_metadata'}->{'series_metadata'}->{'volume'});}
0
0
317
}
318
0
0
0
if (exists $cite->{'book'}->{'book_metadata'}->{'volume'}) {$self->_setvolume($cite->{'book'}->{'book_metadata'}->{'volume'});}
0
0
319
0
0
0
if (exists $cite->{'book'}->{'book_metadata'}->{'publication_date'}) {$self->_setdate($cite->{'book'}->{'book_metadata'}->{'publication_date'}->{'year'});}
0
0
320
} else {
321
0
0
0
if (exists($cite->{'book'}->{'book_set_metadata'}->{'titles'}->{'title'})) {
322
0
0
$jtitle .= $cite->{'book'}->{'book_set_metadata'}->{'titles'}->{'title'}.': ';
323
}
324
0
0
$jtitle .= $cite->{'book'}->{'book_set_metadata'}->{'set_metadata'}->{'titles'}->{'title'};
325
}
326
0
0
$self->_setjtitle($jtitle);
327
0
0
$cc = $cite->{'book'}->{'content_item'};
328
} else {
329
# something else -- might be dissertation, report-paper, standard, sa-component, database
330
# fall back to alternative interface for now
331
0
0
$self->parse_text($doi);
332
0
0
return; # stop here
333
}
334
0
0
$self->_setscore(1);
335
0
0
$self->_setquery($doi);
336
0
0
$self->_setdoi($doi);
337
0
0
0
if (!defined $cc) {
338
# seems like an incomplete entry
339
0
0
return;
340
}
341
#$self->_setatitle($cc->{'titles'}->{'title'});
342
0
0
my $title;
343
0
0
0
if (ref $cc->{titles} ne "HASH") {
344
0
0
$title = $cc->{titles}->[0];
345
} else {
346
0
0
$title = $cc->{'titles'}->{'title'};
347
}
348
0
0
$self->_setatitle($title);
349
0
0
$self->_setdoi($cc->{'doi_data'}->{'doi'});
350
0
0
0
if (ref($cc->{'publication_date'}) eq "HASH") {
351
0
0
$self->_setdate($cc->{'publication_date'}->{'year'});
352
} else { # we have multiple dates, lets try and pick put the print date
353
0
0
my $found = 0; my $count=0;
0
0
354
0
0
foreach my $d (@{$cc->{'publication_date'}}) {
0
0
355
0
0
0
if ($d->{'media_type'} eq 'print') {
356
0
0
$self->_setdate($d->{'year'}); $found = 1;
0
0
357
}
358
0
0
$count++;
359
}
360
0
0
0
0
if ((!$found) && ($count>0)) {$self->_setdate(${$cc->{'publication_date'}}[0]->{'year'});}
0
0
0
0
361
}
362
0
0
0
if (exists(${$cc}{'pages'})) {
0
0
363
0
0
0
if (exists(${$cc->{'pages'}}{'first_page'})) {$self->_setspage($cc->{'pages'}->{'first_page'});}
0
0
0
0
364
0
0
0
if (exists(${$cc->{'pages'}}{'last_page'})) {$self->_setepage($cc->{'pages'}->{'last_page'});}
0
0
0
0
365
}
366
0
0
$cc = $cc->{'contributors'}->{'person_name'};
367
0
0
0
if (ref($cc) eq "HASH") {
368
0
0
$self->_setauthcount(1);
369
0
0
$self->_setauth(1,$cc->{'given_name'}.' '.$cc->{'surname'});
370
} else {
371
0
0
my $count = 0;
372
0
0
foreach my $au (@{$cc}) {
0
0
373
0
0
0
if ($au->{'contributor_role'} ne 'author') {next;}
0
0
374
0
0
$count++;
375
0
0
$self->_setauth($count, $au->{'given_name'}.' '.$au->{'surname'});
376
}
377
0
0
$self->_setauthcount($count);
378
}
379
} else {
380
0
0
$self->_err("Problem with search.crossref.org/guestquery: ".$res->status_line);
381
}
382
}
383
384
sub printheader {
385
0
0
1
0
my $self = shift @_;
386
0
0
my $id = shift @_;
387
0
0
my $str = '';
388
0
0
0
if (defined $id) {$str = 'id="'.$id.'"';}
0
0
389
0
0
return 'Use Type Year Authors Title Journal Volume Issue Pages DOI url '."\n";
390
}
391
392
sub printfooter {
393
0
0
1
0
return "
\n";
394
}
395
396
sub _authstring {
397
1
1
4
my $self = shift @_;
398
1
2
my $out='';
399
1
50
3
if ($self->authcount > 0) {
400
1
3
$out = $self->auth(1);
401
1
4
for (my $j = 2; $j <= $self->authcount; $j++) {
402
1
3
$out.=' and '.$self->auth($j);
403
}
404
}
405
1
4
return $out;
406
}
407
408
sub print {
409
# return a reference in human readable form
410
1
1
1
3
my ($self, $id, $add) = @_;
411
1
2
my $ref = $self->{ref};
412
1
50
4
if (!defined $id) {$id='';}
0
0
413
1
50
3
if (!defined $add) {$add='';}
1
2
414
415
1
2
my $out='';
416
1
50
3
if ($self->{html}) {
417
1
2
$out.=sprintf "%s", ' ';
418
1
4
$out.=sprintf "%s", ' '.$id.' ';
419
1
50
2
if ($self->score<1) {
420
0
0
$out.=sprintf "%s", ' ';
421
0
0
$out.=sprintf "%s", ' Poor match ';
422
} else {
423
1
4
$out.=sprintf "%s", ' ';
424
}
425
1
3
$out.=sprintf "%s", ' '.$self->genre.' '.$self->date.' ';
426
1
27
$out.=sprintf "%s", ' '.$self->_authstring.' ';
427
1
3
$out.=sprintf "%s", ' '.$self->atitle.' '.encode_entities($self->jtitle).' ';
428
1
18
$out.=sprintf "%s", ' ';
429
1
50
3
if (defined $self->volume) {
430
1
2
$out.=sprintf "%s", $self->volume;
431
}
432
1
3
$out.=sprintf "%s", ' ';
433
1
50
2
if (defined $self->issue) {
434
1
3
$out.=sprintf "%s", $self->issue;
435
}
436
1
2
$out.=sprintf "%s", ' ';
437
1
50
3
if (defined $self->spage) {
438
1
21
$out.=sprintf "%s", $self->spage;
439
}
440
1
50
3
if (defined $self->epage) {
441
1
14
$out.=sprintf "%s", '-'.$self->epage;
442
}
443
1
2
$out.=sprintf "%s", ' ';
444
1
50
3
if (defined $self->doi) {
445
1
3
my $doi = $self->doi;
446
1
6
$doi =~ s/http:\/\/dx.doi.org\///;
447
1
2
$out.=$doi;
448
}
449
1
2
$out.=sprintf "%s", ' ';
450
1
50
3
if (defined $self->url) {
451
0
0
$out.=sprintf "%s", ''.$self->url.' ';
452
}
453
1
3
$out.= ' '.$add;
454
1
2
$out.=sprintf "%s", ' '."\n";
455
1
3
$out.=sprintf "%s", ' '.encode_entities($self->query).' '."\n";
456
} else {
457
0
0
0
if (length($id)>0) {$out .= $id.". ";}
0
0
458
0
0
0
if ($self->score<1) {
459
0
0
$out.=sprintf "%s", 'Poor match (score='.$self->score."):\n";
460
0
0
$out.=sprintf "%s", $self->query."\n";
461
} else {
462
#print "$count. ";
463
}
464
0
0
$out.=sprintf "%s", $self->genre.': '.$self->date.", ".$self->_authstring.", ";
465
0
0
$out.=sprintf "%s", "\'".$self->atitle."\'. ".$self->jtitle;
466
0
0
0
if (defined $self->volume) {
467
0
0
$out.=sprintf "%s", ", ".$self->volume;
468
0
0
0
if (defined $self->issue) {
469
0
0
$out.=sprintf "%s", "(".$self->issue.")";
470
}
471
}
472
0
0
0
if (defined $self->spage) {
473
0
0
$out.=sprintf "%s", ",pp".$self->spage;
474
}
475
0
0
0
if (defined $self->epage) {
476
0
0
$out.=sprintf "%s", '-'.$self->epage;
477
}
478
0
0
0
if (defined $self->doi) {
479
0
0
my $doi = $self->doi;
480
0
0
$doi =~ s/http:\/\/dx.doi.org\///;
481
0
0
$out.=sprintf "%s", ", DOI: ".$doi;
482
}
483
0
0
0
if (defined $self->url) {
484
0
0
$out.=sprintf "%s", ", ".$self->url;
485
}
486
}
487
1
10
return $out;
488
}
489
490
1;
491
492
=pod
493
494
=head1 NAME
495
496
Bib::CrossRef - Uses crossref to robustly parse bibliometric references.
497
498
=head1 SYNOPSIS
499
500
use strict;
501
use Bib::CrossRef;
502
503
# Create a new object
504
505
my $ref = Bib::CrossRef->new();
506
507
# Supply some details, Bib::CrossRef will do its best to use this to derive full citation details e.g. the DOI of a document ...
508
509
$ref->parse_text('10.1109/jstsp.2013.2251604');
510
511
# Show the full citation details, in human readable form
512
513
print $ref->print();
514
515
article: 2013, Alessandro Checco and Douglas J. Leith, 'Learning-Based Constraint Satisfaction With Sensing Restrictions'. IEEE Journal of Selected Topics in Signal Processing, 7(5),pp811-820, DOI: http://dx.doi.org/10.1109/jstsp.2013.2251604
516
517
# Show the full citation details, in html format
518
519
$ref->sethtml;
520
print $ref->printheader;
521
print $ref->print;
522
print $ref->printfooter;
523
524
525
=head1 EXAMPLES
526
527
A valid DOI will always be resolved to a full citation
528
e.g.
529
530
$ref->sparse_text('10.1109/jstsp.2013.2251604');
531
print $ref->print();
532
533
article: 2013, Alessandro Checco and Douglas J. Leith, 'Learning-Based Constraint Satisfaction With Sensing Restrictions'. IEEE Journal of Selected Topics in Signal Processing, 7(5),pp811-820, DOI: http://dx.doi.org/10.1109/jstsp.2013.2251604
534
535
An attempt will be made to resolve almost any text containing citation info
536
e.g. article title only
537
538
$ref->parse_text('Learning-Based Constraint Satisfaction With Sensing Restrictions');
539
540
e.g. author and journal
541
542
$ref->parse_text('Alessandro Checco, Douglas J. Leith, IEEE Journal of Selected Topics in Signal Processing, 7(5)');
543
544
Please bear in mind that crossref provides a great service for free -- don't abuse it by making excessive queries. If making many queries, be
545
sure to rate limit them to a sensible level or you will likely get blocked.
546
547
=head1 METHODS
548
549
=head2 new
550
551
my $ref = Bib::CrossRef->new();
552
553
Creates a new Bib::CrossRef object
554
555
=head2 parse_text
556
557
$ref->parse_text($string)
558
559
Given a text string, Bib::CrossRef will try to resolve into a full citation with the help of crossref.org
560
561
=head2 parse_doi
562
563
$ref->parse_doi($doi)
564
565
Given a string containing a DOI e.g. 10.1109/tnet.2012.2202686, resolve into a full citation with the unixref
566
interface of crossref.org. This should be definitive publishers DOI and is usually
567
much as the same as calling $ref->parse_text($doi), but is included completeness.
568
569
=head2 doi
570
571
my $info = $ref->doi
572
573
Returns a string containg the DOI (digital object identifier) field from a full citation. If present, this
574
should be unique to the document.
575
576
=head2 score
577
578
my $info = $ref->score
579
580
Returns a matching score from crossref.org. If less than 1, the text provided to set_details() was likely
581
insufficient to allow the correct full citation to be obtained.
582
583
=head2 genre
584
585
my $info = $ref->genre
586
587
Returns the type of publication e.g. jounal paper, conference paper etc
588
589
=head2 date
590
591
my $info = $ref->date
592
593
Returns the year of publication
594
595
=head2 atitle
596
597
my $info = $ref->atitle
598
599
Returns the article title
600
601
=head2 jtitle
602
603
my $info = $ref->jtitle
604
605
Returns the name of the journal (in long form)
606
607
=head2 authcount
608
609
my $info = $ref->authcount
610
611
Returns the number of authors
612
613
=head2 auth
614
615
my $info = $ref->auth($num)
616
617
Get the name of author number $num (first author is $ref->auth(1))
618
619
=head2 volume
620
621
my $info = $ref->volume
622
623
Returns the volume number in which paper appeared
624
625
=head2 issue
626
627
my $info = $ref->issue
628
629
Returns the issue number in which paper appeared
630
631
=head2 spage
632
633
my $info = $ref->spage
634
635
Returns the start page
636
637
=head2 epage
638
639
my $info = $ref->epage
640
641
Returns the end page
642
643
=head2 url
644
645
Return the url, if any
646
647
=head2 query
648
649
my $info = $ref->query
650
651
Returns the free form string from which full citation is derived
652
653
=head2 print
654
655
print $ref->printheader;
656
657
Prints full citation in human readable form.
658
659
=head2 sethtml
660
661
$ref->sethtml
662
663
Set output format to be html
664
665
=head2 clearhtml
666
667
$ref->clearhtml
668
669
Set output format to be plain text
670
671
=head2 printheader
672
673
print $ref->printheader;
674
675
When html formatting is enabled, prints some html header tags
676
677
=head2 printfooter
678
679
print $ref->printfooter;
680
681
When html formatting is enabled, prints some html footer tags
682
683
=head1 EXPORTS
684
685
You can export the following functions if you do not want to use the object orientated interface:
686
687
parse_text parse_doi sethtml clearhtml set_details print printheader printfooter
688
doi score date atitle jtitle volume issue genre spage epage authcount auth query url
689
690
The tag C is available to easily export everything:
691
692
use Bib::CrossRef qw(:all);
693
694
=head1 VERSION
695
696
Ver 0.09
697
698
=head1 AUTHOR
699
700
Doug Leith
701
702
=head1 BUGS
703
704
Please report any bugs or feature requests to C, or through the web interface at L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
705
706
=head1 COPYRIGHT
707
708
Copyright 2015 D.J.Leith.
709
710
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
711
712
See http://dev.perl.org/licenses/ for more information.
713
714
=cut
715
716
717
__END__