Biblio::Citation::Parser 1.10 Documentation - How-To Guides


HOW TO: Modify Templates in Biblio::Citation::Parser::Standard

Adding new templates to the Standard parser is relatively easy:

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:

_ANY_
Matches anything.

_AUFIRST_
Matches the first name of an author.

_AULAST_
Matches the last name of an author.

_AUTHORS_
Matches a list of authors.

_CAPPUBLICATION_
Matches a capitalised publication title (e.g. ``Journal of Lemurs'').

_CAPTITLE_
Matches a capitalised title.

_CHAPTER_
Matches a chapter number.

_DATE_
Matches a date in nn/nn/nn form.

_EDITOR_
Matches an editor's name.

_EPAGE_
Matches the last page in a page range.

_ISBN_
Matches an ISBN number.

_ISSN_
Matches an ISSN number.

_ISSUE_
Matches an issue number.

_PAGES_
Matches a page range in nn-nn form.

_PUBLICATION_
Matches a publication name.

_PUBLISHER_
Matches a publisher name.

_PUBLOC_
Matches the location of a publisher.

_SPAGE_
Matches the start page.

_SUBTITLE_
Matches a subtitle.

_TITLE_
Matches an article title.

_UCPUBLICATION_
Matches a publication in entirely upper-case (e.g. JOURNAL OF LEMURS).

_UCTITLE_
Matches a title in entirely upper-case.

_URL_
Matches a URL.

_VOLUME_
Matches a volume.

_YEAR_
Matches a year (4 digits).


HOW TO: Integrate ParaTools with EPrints 2

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.


HOW TO: Create a New Parser

Creating a Citation Parser

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