added splitting of tags into subfields (CR for now)
authorDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 10 Oct 2007 20:05:45 +0000 (20:05 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 10 Oct 2007 20:05:45 +0000 (20:05 +0000)
and ability to join tags into single line (AB)

git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@901 07558da8-63fa-0310-ba24-9fe276d99e06

lib/WebPAC/Input/ISI.pm

index 7dad6a2..be4bfaf 100644 (file)
@@ -12,11 +12,11 @@ WebPAC::Input::ISI - support for ISI Export Format
 
 =head1 VERSION
 
-Version 0.00
+Version 0.01
 
 =cut
 
-our $VERSION = '0.00';
+our $VERSION = '0.01';
 
 
 =head1 SYNOPSIS
@@ -54,6 +54,23 @@ path to ISI export file
 
 =cut
 
+my $subfields = {
+       'CR' => sub {
+               my @v = split(/, /, shift);
+               my $f;
+               foreach ( qw/author year reference volume page/ ) {
+                       if ( my $tmp = shift @v ) {
+                               $f->{$_} = $tmp;
+                       }
+               }
+               if ( $f->{author} =~ /^\*(.+)/ ) {
+                       delete $f->{author};
+                       $f->{institution} = $1;
+               }
+               return $f;
+       },
+};
+
 sub new {
        my $class = shift;
        my $self = {@_};
@@ -99,6 +116,10 @@ sub new {
                } elsif ( $line =~ /^\s{3}(.+)$/ ) {
                                $v = $1;
                } elsif ( $line eq 'ER' ) {
+                       # join tags
+                       foreach ( qw/AB/ ) {
+                               $rec->{$_} = join(' ', @{ $rec->{$_} }) if defined $rec->{$_};
+                       }
                        push @{ $self->{_rec} }, $rec;
                        $rec = {};
                        $line = <$fh>;
@@ -110,6 +131,8 @@ sub new {
                        $log->logdie("can't parse +$. $arg->{path} : $line");
                }
 
+               $v = $subfields->{$tag}->($v) if defined $subfields->{$tag};
+
                push @{ $rec->{$tag} }, $v;
 
        }
@@ -152,7 +175,7 @@ sub size {
 =head1 SEE ALSO
 
 L<http://isibasic.com/help/helpprn.html> is only sane source of document format which Google could find...
-
 =head1 AUTHOR
 
 Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>