Biblio::Citation::Parser 1.10 Documentation - How-To Guides |
Adding new templates to the Standard parser is relatively easy:
On Linux systems this should just involve doing 'locate Templates.pm', otherwise 'find / -name Templates.pm' should work. Alternatively, you can edit the Templates.pm in the Biblio/Citation/Parser/ directory of an unpacked distribution, and install it once you have finished.
Add the template to the list.If you are editing an already installed Templates.pm file you will probably have to be root to do this. If you are editing the Templates.pm inside an unpacked distribution, you will have to reinstall the modules once you are finished (see the Installation section).
The Templates.pm file should contain a structure similar to this:
$Biblio::Citation::Parser::Templates::templates = [ '_AUTHORS_, _PUBLICATION_, _YEAR_, _ISSUE_, _SPAGE_-_EPAGE_', ... ];
Each template is a string containing a set of placeholders. For example, '_AUTHORS_ (_YEAR_) _TITLE_' can match 'Jewell, M (2002) Title'. The following are valid field names:
EPrints already contains ParaCite support, but using a specially built version of the module before it was part of ParaTools. To alter your cgi/paracite script to use ParaTools, you need to do the following:
First replace
use Citation::Parser::Simple;
with
use Biblio::Citation::Parser::Standard;
Next, replace this line:
my $parser = new Citation::Parser::Simple();
with this line:
my $parser = new Biblio::Citation::Parser::Standard();
This should work fine, although you can obviously integrate ParaCite more if you wish.
All new citation parsers should be named Biblio::Citation::Parser::SomeName, where SomeName is replaced with a unique name (ideally the author's surname). The parser should extend the Biblio::Citation::Parser module like so:
package Biblio::Citation::Parser::SomeName; require Exporter; @ISA = ("Exporter", "Biblio::Citation::Parser"); our @EXPORT_OK = ( 'new', 'parse' );
You should then override the 'new' and 'parse' methods:
e.g.
sub new { my($class) = @_; my $self = {}; return bless($self, $class); }
sub parse { my($self, $ref) = @_; my $hashout = $self->extract_metadata($ref); return $hashout; }
This makes it easy for users to swap out one reference parser for another.
Biblio::Citation::Parser 1.10 Documentation - How-To Guides |