--- isis2stream.pl 2002/06/16 19:55:19 1.9 +++ isis2stream.pl 2002/06/24 17:52:25 1.15 @@ -8,7 +8,7 @@ my %opts; -getopt('dm', \%opts); +getopts('d:m:q', \%opts); die "usage: $0 -d [database_dir] -m [database1,database2] " if (! %opts); @@ -41,6 +41,20 @@ require "./search/config.pm"; #-------------------------------------------------------------------- +# read database configuration, store database names +open(CF,$common::database_cf) || die "$common::database_cf: $!"; +my %DatabaseDescriptions; +while() { + chomp; + if (/^database-name:([^=]+)=(.*)$/) { + my ($db_name,$db_desc) = ($1,$2); + $db_desc=~s/^##\w+##//g; + $DatabaseDescriptions{$db_name}=$db_desc; + } +} +close(CF); + +#-------------------------------------------------------------------- # # expand(nr,"space separated string"); # @@ -70,6 +84,12 @@ return $tmp; } +sub c_iso_852 { + my $tmp = $_[0]; + $tmp =~ tr/ܫꔼȺ̪㍐슂ٝ// if ($tmp); + return $tmp; +} + sub c_852_czs { my $tmp = $_[0]; $tmp =~ tr//ܫꔼȺ̪㍐슂ٝ/; @@ -305,25 +325,39 @@ my $row = OpenIsis::read( $db, $row_id ); if (my $tmp = $row->{'200'}->[0]) { - my $bib = "%MFN $row->{mfn}\n"; my $mps = "W $row->{mfn} 14\n"; my $pcnt = int($row->{mfn} * 100 / $max_rowid); if ($pcnt != $last_pcnt) { - printf MPS ("M %5d / %5d -- %-2d %%\n",$row->{mfn},$max_rowid,$pcnt); + printf MPS ("M %5d / %5d -- %-2d %%\n",$row->{mfn},$max_rowid,$pcnt) if (! $opts{q}); $last_pcnt = $pcnt; } my $headline; - $headline .= isis_sf($row,'200','a',"'"); - $headline .= isis_sf($row,'200','e'," : ","'"); + $headline .= isis_sf($row,'200','a'); + $headline .= isis_sf($row,'200','e'," : "); + $headline .= isis_sf($row,'200','f'," / "); + $headline .= isis_sf($row,'210','d'," , "); + + # remove newlines, compress spaces + $headline =~ s/[\n\r]//g; + $headline =~ s/^\s+//g; + $headline =~ s/\s+$//g; # author - $bib .= isis_to_bib($row,'700','%700+','*',2,'<'); - $bib .= isis_to_bib($row,'701','%700+','*',2,'<'); - $bib .= isis_to_bib($row,'710','%700+','*',2,'<'); - $bib .= isis_to_bib($row,'711','%700+','*',2,'<'); - $bib .= isis_to_bib($row,'503','%700+','*',2,'<'); + $bib .= isis_to_bib($row,'700','%700+','ab',undef,'>',', '); + $bib .= isis_to_bib($row,'701','%700+','ab',undef,'>',', '); + $bib .= isis_to_bib($row,'701','%700+','cd',undef,'>',', '); + + my $tmp = isis_sf($row,'710','abc', '', '', (' : ',', ')); + $tmp .= isis_sf($row,'710','dfe', ' (', ')', ('', ' ; ',' ; ')); + $bib .= "%700+ $tmp\n" if ($tmp); + + my $tmp = isis_sf($row,'711','abc', '', '', (' : ',', ')); + $tmp .= isis_sf($row,'711','dfe', ' (', ')', ('', ' ; ',' ; ')); + $bib .= "%700+ $tmp\n" if ($tmp); + + $bib .= isis_to_bib($row,'503','%700+','ab',undef,'>',', '); $mps .= isis_to_mps($row,'700',1); $mps .= isis_to_mps($row,'701',1); @@ -392,9 +426,6 @@ $mps .= isis_to_mps($row,'272',2); $mps .= isis_to_mps($row,'273',2); - $headline .= isis_sf($row,'700','b'," "); - $headline .= isis_sf($row,'700','a'," "); - # izdavac $mps .= isis_to_mps($row,'210',3); $mps .= isis_to_mps($row,'250',3); @@ -413,8 +444,8 @@ if (my $year = isis_sf($row,'210','d')) { $year =~ s/^\s*cop\.*\s*//i; $year =~ s/[\[\]]*//g; + $year =~ s/[\n\r]//g; # remove cr $mps .= "D ${year}\n" if ($year !~ m/\?/ && $year =~ /\d{4}/); - $headline .= " ($year)"; } $mps .= isis_to_mps($row,'215',15); @@ -467,6 +498,7 @@ my $mps=''; while (my $isn=$row->{$isis_id}->[$i]) { $isn =~ s/ +//g; # remove spaces + $isn =~ s/[\n\r]//g; # remove cr $mps .= "W $isn $nr\n"; if ($isn =~ s/-//g) { $mps .= "W $isn $nr\n"; @@ -489,11 +521,10 @@ $mps .= isis_to_mps($row,'532',1); - $bib .= isis_to_bib($row,'994','%994a','a'); - + $bib .= '%knjiz '.$DatabaseDescriptions{$db_dir}.", ".$row->{mfn}."\n"; # headline if ($headline) { - $headline .= " [".$row->{mfn}."]"; ## debug MFN! + $headline .= " (".$DatabaseDescriptions{$db_dir}.", ".$row->{mfn}.")"; ## debug MFN! $headline =~ s/&/∧/g; $headline =~ s//>/g;