/[webpac2]/branches/Sack/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 /branches/Sack/lib/WebPAC/Input/ISI.pm

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

revision 1194 by dpavlin, Wed May 27 09:31:35 2009 UTC revision 1302 by dpavlin, Sun Sep 20 19:05:56 2009 UTC
# Line 12  use Data::Dump qw/dump/; Line 12  use Data::Dump qw/dump/;
12    
13  WebPAC::Input::ISI - support for ISI Export Format  WebPAC::Input::ISI - support for ISI Export Format
14    
 =head1 VERSION  
   
 Version 0.02  
   
15  =cut  =cut
16    
17  our $VERSION = '0.02';  our $VERSION = '0.03';
18    
19  =head1 SYNOPSIS  =head1 SYNOPSIS
20    
# Line 60  my $subfields = { Line 56  my $subfields = {
56                  my $full_cr = shift;                  my $full_cr = shift;
57                  my @v = split(/, /, $full_cr);                  my @v = split(/, /, $full_cr);
58                  my $f = { full => $full_cr };                  my $f = { full => $full_cr };
59                  foreach ( qw/author year reference volume page/ ) {                  foreach ( qw/author year reference volume page doi/ ) {
60                          if ( my $tmp = shift @v ) {                          if ( my $tmp = shift @v ) {
61                                  $f->{$_} = $tmp;                                  $f->{$_} = $tmp;
62                          }                          }
# Line 69  my $subfields = { Line 65  my $subfields = {
65                          delete $f->{author};                          delete $f->{author};
66                          $f->{institution} = $1;                          $f->{institution} = $1;
67                  }                  }
68                    $f->{doi} =~ s{DOI\s+}{} if $f->{doi}; # strip DOI prefix
69                  return $f;                  return $f;
70          },          },
71  };  };
# Line 108  sub new { Line 105  sub new {
105          my $rec;          my $rec;
106    
107          $self->{size} = 0;          $self->{size} = 0;
108            my $max_size;
109            $max_size = ( $self->{offset} || 0 ) + $self->{limit} if $self->{limit};
110    
111            warn "# max_size: $max_size";
112    
113          while( $line = <$fh> ) {          while( $line = <$fh> ) {
114                  chomp($line);                  chomp($line);
# Line 119  sub new { Line 120  sub new {
120                                  $v = $2;                                  $v = $2;
121                  } elsif ( $line =~ /^\s{3}(.+)$/ ) {                  } elsif ( $line =~ /^\s{3}(.+)$/ ) {
122                                  $v = $1;                                  $v = $1;
123                                    if ( $tag eq 'CR' && $v =~ m{DOI$} ) {
124                                            my $doi = <$fh>;
125                                            chomp($doi);
126                                            $doi =~ s{^\s{3}}{ } || die "can't find DOI in: $doi";
127                                            $v .= $doi;
128                                    }
129                  } elsif ( $line eq 'ER' ) {                  } elsif ( $line eq 'ER' ) {
130                          # join tags                          # join tags
131                          foreach ( qw/AB DE ID TI/ ) {                          foreach ( qw/AB DE ID TI SO RP SC FU FX PA JI/ ) {
132                                  $rec->{$_} = join(' ', @{ $rec->{$_} }) if defined $rec->{$_};                                  $rec->{$_} = join(' ', @{ $rec->{$_} }) if defined $rec->{$_};
133                          }                          }
134                            # split on ;
135                            foreach ( qw/ID SC DE/ ) {
136                                    $rec->{$_} = [ split(/;\s/, $rec->{$_}) ] if defined $rec->{$_};
137                            }
138                          $rec->{'000'} = [ ++$self->{size} ];                          $rec->{'000'} = [ ++$self->{size} ];
139                          push @{ $self->{_rec} }, $rec;                          push @{ $self->{_rec} }, $rec;
140    
141                            last if $max_size && $self->{size} == $max_size;
142    
143                          $rec = {};                          $rec = {};
144                          $line = <$fh>;                          $line = <$fh>;
145                          chomp $line;                          chomp $line;
146                          $log->logdie("expected blank like in ",$arg->{path}, " +$.: $line") unless ( $line eq '' );                          $log->logdie("expected blank like in ",$arg->{path}, " +$.: $line") unless ( $line eq '' );
147                  } elsif ( $line eq 'EF' ) {                  } elsif ( $line eq 'EF' ) {
148                          last;                          last;
149                    } elsif ( $line =~ m{^(\S\S)\s*$} ) {
150                            warn "# $arg->{path} +$. empty |$line|\n";
151                  } else {                  } else {
152                          $log->logdie("can't parse +$. $arg->{path} : $line");                          $log->logdie("can't parse +$. $arg->{path} |$line|");
153                  }                  }
154    
155                  if ( defined $v ) {                  if ( defined $v ) {

Legend:
Removed from v.1194  
changed lines
  Added in v.1302

  ViewVC Help
Powered by ViewVC 1.1.26