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 |
|
|
15 |
=head1 VERSION |
=head1 VERSION |
16 |
|
|
17 |
Version 0.00 |
Version 0.02 |
18 |
|
|
19 |
=cut |
=cut |
20 |
|
|
21 |
our $VERSION = '0.00'; |
our $VERSION = '0.02'; |
|
|
|
22 |
|
|
23 |
=head1 SYNOPSIS |
=head1 SYNOPSIS |
24 |
|
|
55 |
|
|
56 |
=cut |
=cut |
57 |
|
|
58 |
|
my $subfields = { |
59 |
|
'CR' => sub { |
60 |
|
my @v = split(/, /, shift); |
61 |
|
my $f; |
62 |
|
foreach ( qw/author year reference volume page/ ) { |
63 |
|
if ( my $tmp = shift @v ) { |
64 |
|
$f->{$_} = $tmp; |
65 |
|
} |
66 |
|
} |
67 |
|
if ( $f->{author} =~ /^\*(.+)/ ) { |
68 |
|
delete $f->{author}; |
69 |
|
$f->{institution} = $1; |
70 |
|
} |
71 |
|
return $f; |
72 |
|
}, |
73 |
|
}; |
74 |
|
|
75 |
sub new { |
sub new { |
76 |
my $class = shift; |
my $class = shift; |
77 |
my $self = {@_}; |
my $self = {@_}; |
106 |
my $tag; |
my $tag; |
107 |
my $rec; |
my $rec; |
108 |
|
|
109 |
|
$self->{size} = 0; |
110 |
|
|
111 |
while( $line = <$fh> ) { |
while( $line = <$fh> ) { |
112 |
chomp($line); |
chomp($line); |
113 |
|
|
119 |
} elsif ( $line =~ /^\s{3}(.+)$/ ) { |
} elsif ( $line =~ /^\s{3}(.+)$/ ) { |
120 |
$v = $1; |
$v = $1; |
121 |
} elsif ( $line eq 'ER' ) { |
} elsif ( $line eq 'ER' ) { |
122 |
|
# join tags |
123 |
|
foreach ( qw/AB DE ID TI/ ) { |
124 |
|
$rec->{$_} = join(' ', @{ $rec->{$_} }) if defined $rec->{$_}; |
125 |
|
} |
126 |
|
$rec->{'000'} = [ ++$self->{size} ]; |
127 |
push @{ $self->{_rec} }, $rec; |
push @{ $self->{_rec} }, $rec; |
128 |
$rec = {}; |
$rec = {}; |
129 |
$line = <$fh>; |
$line = <$fh>; |
135 |
$log->logdie("can't parse +$. $arg->{path} : $line"); |
$log->logdie("can't parse +$. $arg->{path} : $line"); |
136 |
} |
} |
137 |
|
|
138 |
push @{ $rec->{$tag} }, $v; |
if ( defined $v ) { |
139 |
|
$v = $subfields->{$tag}->($v) if defined $subfields->{$tag}; |
140 |
|
|
141 |
|
$log->debug("$tag: ", sub { dump( $v ) }); |
142 |
|
push @{ $rec->{$tag} }, $v; |
143 |
|
} |
144 |
|
|
145 |
} |
} |
146 |
|
|
176 |
|
|
177 |
sub size { |
sub size { |
178 |
my $self = shift; |
my $self = shift; |
179 |
return $#{$self->{_rec}} + 1; |
return $self->{size}; |
180 |
} |
} |
181 |
|
|
182 |
|
=head1 SEE ALSO |
183 |
|
|
184 |
|
L<http://isibasic.com/help/helpprn.html> is only sane source of document format which Google could find... |
185 |
|
|
186 |
=head1 AUTHOR |
=head1 AUTHOR |
187 |
|
|
188 |
Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >> |
Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >> |