NAME
Bib::Tools - for managing collections of Bib::CrossRef references.
SYNOPSIS
use strict;
use Bib::Tools;
# Create a new object
my $refs = Bib::Tools->new();
# Add some bibliometric info e.g. as text, one reference per line
$text=<<"END";
10.1109/lcomm.2011.040111.102111
10.1109/tnet.2010.2051038
END
open $fh, '<', \$text;
$refs->add_fromfile($fh);
or
$text=<<"END";
Dangerfield, I., Malone, D., Leith, D.J., 2011, Incentivising fairness and policing nodes in WiFi, IEEE Communications Letters, 15(5), pp500-502
D. Giustiniano, D. Malone, D.J. Leith and K. Papagiannaki, 2010. Measuring transmission opportunities in 802.11 links. IEEE/ACM Transactions on Networking, 18(5), pp1516-1529
END
open $fh, '<', \$text;
$refs->add_fromfile($fh);
# or as text scraped from a google scholar personal home page
$refs->add_google('http://scholar.google.com/citations?user=n8dX1fUAAAAJ');
# or as text obtained from ORCID (www.orcid.org)
$refs->add_orcid('0000-0003-4056-4014');
# Bib:Tools will use Bib:CrossRef to try to resolve the supplied text into full citations. It will try to detect duplicates using DOI information, so its fairly safe to import from multiple sources without creating clashes. Full citations without DOI information are kept separately from those with a DOI for better quality control.
# The resulting list of full citations containing DOI's can be printed out in human readable form using
print $refs->print;
# and the list of full citations without DOI's
print $refs->print_nodoi;
# or the complete citation list can also be output as a simple web page using
print $refs->send_resp;
METHODS
new
my $refs = Bib::Tools->new();
Creates a new Bib::Tools object. Queries to crossref via Bib::CrossRef are rate limited. To change the ratelimit pass this as an option to new e.g $refs = Bib::Tools->new(3) sets the rate limit to 3 queries per second.
add_google
$refs->add_google($url);
Scrapes citation information from a google scholar personal home page (*not* a search page, see below) and tries resolve it into full citations using crossref.
add_google_search
$refs->add_google_search($url);
Scrapes citation information from a google scholar search page and tries to resolve into full citations. A different method is needed for search and home pages due to the different html tags used.
add_orcid
$refs->add_orcid($orcid_id);
Uses the ORCID API to extract citations for the specified user identifier. If possible, the DOI is obtained from ORCID and then resolved using crossref. Please bear in mind that ORCID provide a free service -- do rate limit queries if you have a large number to make.
add_details
$refs->add_details(@lines);
Given a array of strings, one per citation, tries to resolve these into full citations.
add_fromfile
$refs->add_fromfile($fh);
Given a file handle to a text file, with one citation per line, tries to resolve these into full citations.
my $info = $refs->print;
Display the list of full citations that have DOIs in human readable form.
print_nodoi
my $info = $refs->print_nodoi;
Display the list of full citations without DOIs in human readable form.
sethtml
$refs->sethtml
Set the output format to be html
clearhtml
$refs->clearhtml
Set the output format to be plain text
send_resp
my $info = $refs->send_resp;
num
my $num = $refs->num;
Returns the number of full citations that have DOIs
num_nodoi
my $num = $refs->num_nodoi;
Returns the number of full citations without DOIs
getref
my $ref = $refs->getref($i);
Returns the $i citation from the list with DOIs. This can be used to walk the list of citations.
getref_nodoi
my $ref = $refs->getref_nodoi($i);
Returns the $i citation from the list without DOIs
EXPORTS
You can export the following functions if you do not want to use the object orientated interface:
sethtml clearhtml add_details add_google add_google_search add_orcid add_fromfile send_resp print print_nodoi num num_nodoi getref getref_nodoi
The tag all
is available to easily export everything:
use Bib::Tools qw(:all);
WEB INTERFACE
A simple web interface to Bib::Tools is contained in the scripts folder. This consists of two files: query.html and handle_query.pl.
query.html
<!DOCTYPE HTML>
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"></head><body>
<h3>Import References</h3>
<form action="handle_query.pl" method="POST" id="in">
<p>Use ORCID id: <INPUT type="text" name="orcid" size="30"></p>
<p>Use Google Scholar personal page: <INPUT type="text" name="google" size="128"></p>
<p>Use Google Scholar search page: <INPUT type="text" name="google2" size="128"></p>
<p>Enter references, one per line:</p>
<textarea name="refs" rows="10" cols="128" form="in"></textarea><br>
<INPUT type="submit" value="Submit">
</form>
</body></html>
handle_query.pl
#!/usr/bin/perl
use Bib::CrossRef;
use Bib::Tools;
use CGI;
# send html header
print "Content-Type: text/html;\n\n";
my $q = CGI->new;
my $refs = Bib::Tools->new;
my $orcid = scalar $q->param('orcid');
$orcid =~ /([0-9\-]+)$/; # extract id out of url
$orcid = $1;
if (length($orcid) > 5) {
$refs->add_orcid($1);
}
my $google = scalar $q->param('google'); #NB: CGI has already carried out URL decoding
if (length($google) > 5) {
if (!($google =~ m/^http/)) { $google = "http://".$google;}
$refs->add_google($google);
}
my $google2 = scalar $q->param('google2'); #NB: CGI has already carried out URL decoding
if (length($google2) > 5) {
if (!($google2 =~ m/^http/)) { $google2 = "http://".$google2;}
$refs->add_google_search($google2);
}
my @values = $q->multi_param('refs');
foreach my $value (@values) {
open my $fh, "<", \$value; #NB: CGI has already carried out URL decoding
$refs->add_fromfile($fh);
}
$refs->sethtml;
print $refs->send_resp;
VERSION
Ver 0.02
AUTHOR
Doug Leith
BUGS
Please report any bugs or feature requests to bug-rrd-db at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Bib-Tools. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
COPYRIGHT
Copyright 2015 D.J.Leith.
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.
See http://dev.perl.org/licenses/ for more information.