/[webpac2]/trunk/lib/WebPAC/Input/ISI.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/WebPAC/Input/ISI.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 899 by dpavlin, Wed Oct 10 19:01:57 2007 UTC revision 1209 by dpavlin, Sat May 30 14:21:58 2009 UTC
# Line 6  use strict; Line 6  use strict;
6  use WebPAC::Input;  use WebPAC::Input;
7  use base qw/WebPAC::Common/;  use base qw/WebPAC::Common/;
8    
9    use Data::Dump qw/dump/;
10    
11  =head1 NAME  =head1 NAME
12    
13  WebPAC::Input::ISI - support for ISI Export Format  WebPAC::Input::ISI - support for ISI Export Format
14    
 =head1 VERSION  
   
 Version 0.00  
   
15  =cut  =cut
16    
17  our $VERSION = '0.00';  our $VERSION = '0.03';
   
18    
19  =head1 SYNOPSIS  =head1 SYNOPSIS
20    
# Line 54  path to ISI export file Line 51  path to ISI export file
51    
52  =cut  =cut
53    
54    my $subfields = {
55            'CR' => sub {
56                    my $full_cr = shift;
57                    my @v = split(/, /, $full_cr);
58                    my $f = { full => $full_cr };
59                    foreach ( qw/author year reference volume page doi/ ) {
60                            if ( my $tmp = shift @v ) {
61                                    $f->{$_} = $tmp;
62                            }
63                    }
64                    if ( $f->{author} =~ /^\*(.+)/ ) {
65                            delete $f->{author};
66                            $f->{institution} = $1;
67                    }
68                    $f->{doi} =~ s{DOI\s+}{} if $f->{doi}; # strip DOI prefix
69                    return $f;
70            },
71    };
72    
73  sub new {  sub new {
74          my $class = shift;          my $class = shift;
75          my $self = {@_};          my $self = {@_};
# Line 88  sub new { Line 104  sub new {
104          my $tag;          my $tag;
105          my $rec;          my $rec;
106    
107            $self->{size} = 0;
108    
109          while( $line = <$fh> ) {          while( $line = <$fh> ) {
110                  chomp($line);                  chomp($line);
111    
# Line 98  sub new { Line 116  sub new {
116                                  $v = $2;                                  $v = $2;
117                  } elsif ( $line =~ /^\s{3}(.+)$/ ) {                  } elsif ( $line =~ /^\s{3}(.+)$/ ) {
118                                  $v = $1;                                  $v = $1;
119                                    if ( $tag eq 'CR' && $v =~ m{DOI$} ) {
120                                            my $doi = <$fh>;
121                                            chomp($doi);
122                                            $doi =~ s{^\s{3}}{ } || die "can't find DOI in: $doi";
123                                            $v .= $doi;
124                                    }
125                  } elsif ( $line eq 'ER' ) {                  } elsif ( $line eq 'ER' ) {
126                            # join tags
127                            foreach ( qw/AB DE ID TI/ ) {
128                                    $rec->{$_} = join(' ', @{ $rec->{$_} }) if defined $rec->{$_};
129                            }
130                            $rec->{'000'} = [ ++$self->{size} ];
131                          push @{ $self->{_rec} }, $rec;                          push @{ $self->{_rec} }, $rec;
132                          $rec = {};                          $rec = {};
133                          $line = <$fh>;                          $line = <$fh>;
# Line 110  sub new { Line 139  sub new {
139                          $log->logdie("can't parse +$. $arg->{path} : $line");                          $log->logdie("can't parse +$. $arg->{path} : $line");
140                  }                  }
141    
142                  push @{ $rec->{$tag} }, $v;                  if ( defined $v ) {
143                            $v = $subfields->{$tag}->($v) if defined $subfields->{$tag};
144    
145                            $log->debug("$tag: ", sub { dump( $v ) });
146                            push @{ $rec->{$tag} }, $v;
147                    }
148    
149          }          }
150    
# Line 146  Return number of records in database Line 180  Return number of records in database
180    
181  sub size {  sub size {
182          my $self = shift;          my $self = shift;
183          return $#{$self->{_rec}} + 1;          return $self->{size};
184  }  }
185    
186    =head1 SEE ALSO
187    
188    L<http://isibasic.com/help/helpprn.html> is only sane source of document format which Google could find...
189    
190  =head1 AUTHOR  =head1 AUTHOR
191    
192  Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>  Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>

Legend:
Removed from v.899  
changed lines
  Added in v.1209

  ViewVC Help
Powered by ViewVC 1.1.26