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 $full_cr = shift; |
61 |
|
my @v = split(/, /, $full_cr); |
62 |
|
my $f = { full => $full_cr }; |
63 |
|
foreach ( qw/author year reference volume page/ ) { |
64 |
|
if ( my $tmp = shift @v ) { |
65 |
|
$f->{$_} = $tmp; |
66 |
|
} |
67 |
|
} |
68 |
|
if ( $f->{author} =~ /^\*(.+)/ ) { |
69 |
|
delete $f->{author}; |
70 |
|
$f->{institution} = $1; |
71 |
|
} |
72 |
|
return $f; |
73 |
|
}, |
74 |
|
}; |
75 |
|
|
76 |
sub new { |
sub new { |
77 |
my $class = shift; |
my $class = shift; |
78 |
my $self = {@_}; |
my $self = {@_}; |
104 |
|
|
105 |
$log->info("opening $format $version database '$arg->{path}'"); |
$log->info("opening $format $version database '$arg->{path}'"); |
106 |
|
|
107 |
|
my $tag; |
108 |
|
my $rec; |
109 |
|
|
110 |
|
$self->{size} = 0; |
111 |
|
|
112 |
|
while( $line = <$fh> ) { |
113 |
|
chomp($line); |
114 |
|
|
115 |
|
my $v; |
116 |
|
|
117 |
|
if ( $line =~ /^(\S\S)\s(.+)$/ ) { |
118 |
|
$tag = $1; |
119 |
|
$v = $2; |
120 |
|
} elsif ( $line =~ /^\s{3}(.+)$/ ) { |
121 |
|
$v = $1; |
122 |
|
} elsif ( $line eq 'ER' ) { |
123 |
|
# join tags |
124 |
|
foreach ( qw/AB DE ID TI/ ) { |
125 |
|
$rec->{$_} = join(' ', @{ $rec->{$_} }) if defined $rec->{$_}; |
126 |
|
} |
127 |
|
$rec->{'000'} = [ ++$self->{size} ]; |
128 |
|
push @{ $self->{_rec} }, $rec; |
129 |
|
$rec = {}; |
130 |
|
$line = <$fh>; |
131 |
|
chomp $line; |
132 |
|
$log->logdie("expected blank like in ",$arg->{path}, " +$.: $line") unless ( $line eq '' ); |
133 |
|
} elsif ( $line eq 'EF' ) { |
134 |
|
last; |
135 |
|
} else { |
136 |
|
$log->logdie("can't parse +$. $arg->{path} : $line"); |
137 |
|
} |
138 |
|
|
139 |
|
if ( defined $v ) { |
140 |
|
$v = $subfields->{$tag}->($v) if defined $subfields->{$tag}; |
141 |
|
|
142 |
|
$log->debug("$tag: ", sub { dump( $v ) }); |
143 |
|
push @{ $rec->{$tag} }, $v; |
144 |
|
} |
145 |
|
|
146 |
|
} |
147 |
|
|
148 |
|
$log->debug("loaded ", $self->size, " records"); |
149 |
|
|
150 |
$self ? return $self : return undef; |
$self ? return $self : return undef; |
151 |
} |
} |
152 |
|
|
154 |
|
|
155 |
Return record with ID C<$mfn> from database |
Return record with ID C<$mfn> from database |
156 |
|
|
157 |
my $rec = $input->fetch_rec( $mfn, $filter_coderef); |
my $rec = $input->fetch_rec( $mfn, $filter_coderef ); |
158 |
|
|
159 |
=cut |
=cut |
160 |
|
|
161 |
sub fetch_rec { |
sub fetch_rec { |
162 |
my $self = shift; |
my $self = shift; |
163 |
|
|
164 |
my ($mfn, $filter_coderef) = @_; |
my ( $mfn, $filter_coderef ) = @_; |
|
|
|
|
my $rec; |
|
165 |
|
|
166 |
return $rec; |
return $self->{_rec}->[$mfn-1]; |
167 |
} |
} |
168 |
|
|
169 |
|
|
177 |
|
|
178 |
sub size { |
sub size { |
179 |
my $self = shift; |
my $self = shift; |
180 |
return 2; |
return $self->{size}; |
181 |
} |
} |
182 |
|
|
183 |
|
=head1 SEE ALSO |
184 |
|
|
185 |
|
L<http://isibasic.com/help/helpprn.html> is only sane source of document format which Google could find... |
186 |
|
|
187 |
=head1 AUTHOR |
=head1 AUTHOR |
188 |
|
|
189 |
Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >> |
Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >> |