--- isis2stream.pl 2002/06/13 15:32:10 1.1.1.1 +++ isis2stream.pl 2002/06/16 16:06:55 1.6 @@ -4,50 +4,29 @@ use OpenIsis; use Getopt::Std; #use Data::Dumper; - -my $install_dir="/local/index"; -my $mpsindex="/local/mps-5.3/bin/mpsindex -l 9 -b"; -my $isis_data="/var/autofs/misc/isis_data/"; -#my $isis_data="/mnt/20020606/Isis/Data/"; # doma +use common; my %opts; -getopt('dD', \%opts); +getopt('dm', \%opts); -die "usage: $0 -d [database_dir] " if (! $opts{d}); +die "usage: $0 -d [database_dir] -m [database1,database2] " if (! %opts); my $db_dir = $opts{d}; -mkdir "$install_dir/$db_dir" if (!-e "$install_dir/$db_dir"); -mkdir "$install_dir/$db_dir/data" if (!-e "$install_dir/$db_dir/data"); +mkdir "$common::install_dir/$db_dir" if (!-e "$common::install_dir/$db_dir"); +mkdir "$common::install_dir/$db_dir/data" if (!-e "$common::install_dir/$db_dir/data"); -my $dir="$install_dir/$db_dir/data"; +my $dir="$common::install_dir/$db_dir/data"; -open(S,"> $dir/stream") || die "can't open output $dir/stram: $!"; +open(S,"> $dir/stream") || die "can't open output $dir/stream: $!"; open(R,"> $dir/bib") || die "can't open output $dir/bib: $!"; -open(MPS,"| $mpsindex -d $install_dir/$db_dir -autokey") || die "can't start MPS indexer $mpsindex: $!"; +open(MPS,"| $common::mpsindex -d $common::install_dir/$db_dir -autokey") || die "can't start MPS indexer $common::mpsindex: $!"; #open(MPS,"> /tmp/mpsindex") || die "mps: $!"; -my $s="V 5 3 -L hr-HR -F 700+ 1 Autor -F 200+ 2 Naslov -F 210 3 Izdavanje -F 225 4 Nakladnička cjelina -F 300+ 5 Napomene -F 330 6 Sadržaj -F 464 7 Analitički radovi -F 610 8 Ključne riječi -F 675 9 UDK -F 686 10 CC -F 990 11 Signatura -F 991 12 Inventarni broj -F 10 13 ISBN -"; - -print S $s; -print MPS $s; +print S $common::mps_header; +print MPS $common::mps_header; # # expand(nr,"space separated string"); @@ -177,27 +156,6 @@ } #-------------------------------------------------------------------- -# -# mps_expand(nr,"space separated string"); -# - -sub mps_expand { - my $nr = shift @_; - my $out = ""; - while (my $fld = shift @_) { - if ($fld =~ m/\s+/) { - foreach my $w (split(/\s+/,$fld)) { - # FIX: this should be replaced by stemmer! - $out .= "W $w $nr\n"; - } - } else { - $out .= "W $fld $nr\n"; - } - } - return c_852_czs($out); -} - -#-------------------------------------------------------------------- # $mps .= sf_to_mps($subfiled_hash,"subfields",mps_id); # @@ -386,13 +344,34 @@ my $last_tell=0; -my $db = OpenIsis::open( "$isis_data/$db_dir/LIBRI/LIBRI" ); +my @isis_dirs = ( '.' ); # use dirname as database name + +if ($opts{m}) { + @isis_dirs = split(/,/,$opts{m}); +} + +my @isis_dbs; + +foreach (@isis_dirs) { + if (-e "$common::isis_data/$db_dir/$_/LIBRI") { + push @isis_dbs,"$common::isis_data/$db_dir/$_/LIBRI/LIBRI"; + } + if (-e "$common::isis_data/$db_dir/$_/PERI") { + push @isis_dbs,"$common::isis_data/$db_dir/$_/PERI/PERI"; + } +} + +foreach my $isis_db (@isis_dbs) { + + print MPS "M reading ISIS from '$isis_db'...\n"; + + my $db = OpenIsis::open( "$isis_db" ); -my $max_rowid = OpenIsis::maxRowid( $db ); + my $max_rowid = OpenIsis::maxRowid( $db ); -my $last_pcnt = 0; + my $last_pcnt = 0; -for (my $row_id = 1; $row_id <= $max_rowid; $row_id++ ) { + for (my $row_id = 1; $row_id <= $max_rowid; $row_id++ ) { my $row = OpenIsis::read( $db, $row_id ); if (my $tmp = $row->{'200'}->[0]) { @@ -540,6 +519,7 @@ print S $mps; print MPS $mps; } + } } print S "M over and out\nX\n"; print MPS "M over and out\nX\n";