--- isis2stream.pl 2002/06/16 19:55:19 1.9 +++ isis2stream.pl 2002/06/24 15:36:52 1.11 @@ -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//ܫꔼȺ̪㍐슂ٝ/; @@ -310,13 +330,20 @@ 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,'<'); @@ -392,9 +419,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 +437,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 +491,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"; @@ -493,10 +518,11 @@ # headline if ($headline) { - $headline .= " [".$row->{mfn}."]"; ## debug MFN! + $headline .= " (".$DatabaseDescriptions{$db_dir}.", ".$row->{mfn}.")"; ## debug MFN! $headline =~ s/&/∧/g; $headline =~ s//>/g; + $headline =~ s/<(\/?[bi])>/<$1>/g; $mps .= "H ".c_852_iso($headline)."\n"; } else { $mps .= "H nepoznato\n";