1 package WebPAC::Input::ISI;
7 use base qw/WebPAC::Common/;
11 WebPAC::Input::ISI - support for ISI Export Format
19 our $VERSION = '0.01';
24 Open file in ISI export fromat
26 my $input = new WebPAC::Input::ISI(
27 path => '/path/to/ISI/records.txt',
34 Returns new low-level input API object
36 my $input = new WebPAC::Input::ISI(
37 path => '/path/to/ISI/records.txt'
39 my ($l,$field_nr) = @_;
40 # do something with $l which is line of input file
51 path to ISI export file
59 my @v = split(/, /, shift);
61 foreach ( qw/author year reference volume page/ ) {
62 if ( my $tmp = shift @v ) {
66 if ( $f->{author} =~ /^\*(.+)/ ) {
68 $f->{institution} = $1;
81 my $log = $self->_get_logger();
83 open( my $fh, '<', $arg->{path} ) || $log->logconfess("can't open $arg->{path}: $!");
85 my ( $format, $version );
89 if ( $line =~ /^FN\s(.+)$/) {
92 $log->logdie("first line of $arg->{path} has to be FN, but is: $line");
97 if ( $line =~ /^VR\s(.+)$/) {
100 $log->logdie("second line of $arg->{path} has to be VN, but is: $line");
103 $log->info("opening $format $version database '$arg->{path}'");
108 while( $line = <$fh> ) {
113 if ( $line =~ /^(\S\S)\s(.+)$/ ) {
116 } elsif ( $line =~ /^\s{3}(.+)$/ ) {
118 } elsif ( $line eq 'ER' ) {
121 $rec->{$_} = join(' ', @{ $rec->{$_} }) if defined $rec->{$_};
123 push @{ $self->{_rec} }, $rec;
127 $log->logdie("expected blank like in ",$arg->{path}, " +$.: $line") unless ( $line eq '' );
128 } elsif ( $line eq 'EF' ) {
131 $log->logdie("can't parse +$. $arg->{path} : $line");
134 $v = $subfields->{$tag}->($v) if defined $subfields->{$tag};
136 push @{ $rec->{$tag} }, $v;
140 $log->debug("loaded ", $self->size, " records");
142 $self ? return $self : return undef;
147 Return record with ID C<$mfn> from database
149 my $rec = $input->fetch_rec( $mfn, $filter_coderef );
156 my ( $mfn, $filter_coderef ) = @_;
158 return $self->{_rec}->[$mfn-1];
164 Return number of records in database
166 my $size = $input->size;
172 return $#{$self->{_rec}} + 1;
177 L<http://isibasic.com/help/helpprn.html> is only sane source of document format which Google could find...
181 Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>
183 =head1 COPYRIGHT & LICENSE
185 Copyright 2007 Dobrica Pavlinusic, All Rights Reserved.
187 This program is free software; you can redistribute it and/or modify it
188 under the same terms as Perl itself.
192 1; # End of WebPAC::Input::ISI