/[webpac-proto]/isis2stream.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /isis2stream.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.18 by dpavlin, Wed Jul 17 16:55:24 2002 UTC revision 1.22 by dpavlin, Thu Oct 24 16:32:00 2002 UTC
# Line 14  die "usage: $0 -d [database_dir] -m [dat Line 14  die "usage: $0 -d [database_dir] -m [dat
14    
15  my $db_dir = $opts{d};  my $db_dir = $opts{d};
16    
17  mkdir "$common::install_dir/$db_dir" if (!-e "$common::install_dir/$db_dir");  my $dir = open_data_files($db_dir);
 mkdir "$common::install_dir/$db_dir/data" if (!-e "$common::install_dir/$db_dir/data");  
   
 my $dir="$common::install_dir/$db_dir/data";  
   
   
 open(S,"> $dir/stream") || die "can't open output $dir/stream: $!";  
 open(R,"> $dir/bib") || die "can't open output $dir/bib: $!";  
 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: $!";  
   
 print S $common::mps_header;  
 print MPS $common::mps_header;  
18    
19  #--------------------------------------------------------------------  #--------------------------------------------------------------------
20  # init array in_mps_header for config checks later  # init array in_mps_header for config checks later
# Line 70  sub expand { Line 58  sub expand {
58                  foreach my $w (@words) {                  foreach my $w (@words) {
59                          # FIX: this should be replaced by stemmer!                          # FIX: this should be replaced by stemmer!
60                          #$w =~ tr/ƾ/sSdDcCcCzZ/;                          #$w =~ tr/ƾ/sSdDcCcCzZ/;
61                          $w =~ tr/ܫȺ̪/CueaauccleOoiZACELlooLlSsOUTtLcaiouAaZzEezCsAAESZzAadDDEdNIIeTUOoNnnSsRUrUyYt'-".'',"'Rr/;                          $w =~ tr/ܫȺ̪/CueaauccleOoiZACELlooLlSsOUTtLcaiouAaZzEezCsAAESZzAadDDEdNIIeTUOoNnnSsRUrUyYt'".'',"'Rr/;
62                          $w =~ s//ss/g;                          $w =~ s//ss/g;
63                          $out .= "W $w $nr\n";                          $out .= "W $w $nr\n";
64                  }                  }
# Line 95  sub c_iso_852 { Line 83  sub c_iso_852 {
83  sub c_852_czs {  sub c_852_czs {
84          my $tmp = $_[0];          my $tmp = $_[0];
85          $tmp =~ tr//ܫꔼȺ̪㍐슂ٝ/;          $tmp =~ tr//ܫꔼȺ̪㍐슂ٝ/;
86          $tmp =~ tr/ܫȺ̪/CueaauccleOoiZACELlooLlSsOUTtLcaiouAaZzEezCsAAESZzAadDDEdNIIeTUOoNnnSsRUrUyYt'-".'',"'Rr/;          $tmp =~ tr/ܫȺ̪/CueaauccleOoiZACELlooLlSsOUTtLcaiouAaZzEezCsAAESZzAadDDEdNIIeTUOoNnnSsRUrUyYt'".'',"'Rr/;
87          $tmp =~ s//ss/g;          $tmp =~ s//ss/g;
88          return $tmp;          return $tmp;
89  }  }
# Line 138  sub sf_to_mps { Line 126  sub sf_to_mps {
126          my @sf_arr = subfields_str_2_arr($subfields,$sf_hash);          my @sf_arr = subfields_str_2_arr($subfields,$sf_hash);
127    
128          foreach (@sf_arr) {          foreach (@sf_arr) {
129                  $out.=mps_expand($mps_id,$sf_hash->{$_});                  $out.=mps_expand($mps_id,c_852_iso($sf_hash->{$_}));
130          }          }
131          return $out;          return $out;
132  }  }
# Line 164  sub isis_to_mps { Line 152  sub isis_to_mps {
152                  if (scalar keys %{$sf_hash} > 0) {                  if (scalar keys %{$sf_hash} > 0) {
153                          if ($subfields) {                          if ($subfields) {
154                                  foreach (split(//,$subfields)) {                                  foreach (split(//,$subfields)) {
155                                          $out.=mps_expand($mps_id,$sf_hash->{$_});                                          $out.=mps_expand($mps_id,c_852_iso($sf_hash->{$_}));
156                                  }                                  }
157                          } else {                          } else {
158                                  foreach (keys %{$sf_hash}) {                                  foreach (keys %{$sf_hash}) {
159                                          $out.=mps_expand($mps_id,$sf_hash->{$_});                                          $out.=mps_expand($mps_id,c_852_iso($sf_hash->{$_}));
160                                  }                                  }
161                          }                          }
162                  } else {                  } else {
163                          $out.=mps_expand($mps_id,$row->{$isis_id}->[$i]);                          $out.=mps_expand($mps_id,c_852_iso($row->{$isis_id}->[$i]));
164                  }                  }
165                  $i++;                  $i++;
166          }          }
# Line 311  foreach (@isis_dirs) { Line 299  foreach (@isis_dirs) {
299          if (-e "$common::isis_data/$db_dir/$_/PERI") {          if (-e "$common::isis_data/$db_dir/$_/PERI") {
300                  push @isis_dbs,"$common::isis_data/$db_dir/$_/PERI/PERI";                  push @isis_dbs,"$common::isis_data/$db_dir/$_/PERI/PERI";
301          }          }
302            if (-e "$common::isis_data/$db_dir/$_/AMS") {
303                    push @isis_dbs,"$common::isis_data/$db_dir/$_/AMS/AMS";
304            }
305            if (-e "$common::isis_data/$db_dir/$_/ARTI") {
306    #               push @isis_dbs,"$common::isis_data/$db_dir/$_/ARTI/ARTI";
307            }
308  }  }
309    
310  foreach my $isis_db (@isis_dbs) {  foreach my $isis_db (@isis_dbs) {
# Line 319  foreach my $isis_db (@isis_dbs) { Line 313  foreach my $isis_db (@isis_dbs) {
313    
314    my $db = OpenIsis::open( "$isis_db" );    my $db = OpenIsis::open( "$isis_db" );
315    
316      if (! defined $db) {
317            die "can't open '$isis_db'";
318      }
319    
320      my $tip = $isis_db; $tip =~ s/^.+?\/([^\/]+)$/$1/;
321      if (defined $default::tip{$tip}) {
322            $tip=$default::tip{$tip};
323      } elsif ($tip eq "AMS") {
324            $tip=$default::tip{'LIBRI'};
325      } else {
326            die "can't find tip for database '$isis_db'";
327      }
328      $tip = c_iso_852($tip);
329    
330    my $max_rowid = OpenIsis::maxRowid( $db );    my $max_rowid = OpenIsis::maxRowid( $db );
331    
332    my $last_pcnt = 0;    my $last_pcnt = 0;
# Line 330  foreach my $isis_db (@isis_dbs) { Line 338  foreach my $isis_db (@isis_dbs) {
338                  my $bib;                  my $bib;
339                  my $mps = "W $row->{mfn} 14\n";                  my $mps = "W $row->{mfn} 14\n";
340    
341                    # tip gradje
342                    $mps .= "W ".c_852_czs($tip)." 17\n";
343                    $bib .= "%tip $tip\n";
344    
345                  my $pcnt = int($row->{mfn} * 100 / $max_rowid);                  my $pcnt = int($row->{mfn} * 100 / $max_rowid);
346                  if ($pcnt != $last_pcnt) {                  if ($pcnt != $last_pcnt) {
347                          printf MPS ("M %5d / %5d -- %-2d %%\n",$row->{mfn},$max_rowid,$pcnt) if (! $opts{q});                          printf MPS ("M %5d / %5d -- %-2d %%\n",$row->{mfn},$max_rowid,$pcnt) if (! $opts{q});
# Line 526  foreach my $isis_db (@isis_dbs) { Line 538  foreach my $isis_db (@isis_dbs) {
538                  $mps .= isis_isn_to_mps($row,'293',13);                  $mps .= isis_isn_to_mps($row,'293',13);
539    
540                  # ISSN                  # ISSN
541                  #store_isn($row->{11}->[0],14,'%ISSN');                  $bib .= isis_to_bib($row,'11','%ISSN');
542                    $mps .= isis_isn_to_mps($row,'11',13);
543    
544                  $mps .= isis_to_mps($row,'532',1);                  $mps .= isis_to_mps($row,'532',1);
545    
546                    # Casopisi
547                    $tmp = isis_to_bib($row,'326','%326');
548                    $tmp =~ s/g1/godinjak/;
549                    $tmp =~ s/g6/dvomjesenik/;
550                    $tmp =~ s/10/godinje 10 brojeva/;
551                    $tmp =~ s/m1/mjesenik/;
552                    $tmp =~ s/m2/polumjesenik/;
553                    $tmp =~ s/nr/neredovito/;
554                    $tmp =~ s/g4/etiri puta godinje/;
555                    $bib .= c_iso_852($tmp);
556                    $bib .= isis_to_bib($row,'992','%992');
557    
558                  $bib .= '%knjiz '.$DatabaseDescriptions{$db_dir}.", ".$row->{mfn}."\n";                  $bib .= '%knjiz '.$DatabaseDescriptions{$db_dir}.", ".$row->{mfn}."\n";
559                  # headline                  # headline
560                  if ($headline) {                  if ($headline) {
# Line 568  foreach my $isis_db (@isis_dbs) { Line 593  foreach my $isis_db (@isis_dbs) {
593    
594                  $mps .= "E\n";                  $mps .= "E\n";
595    
   
596                  print S $mps;                  print S $mps;
597                  print MPS $mps;                  print MPS $mps;
598          }          }

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.22

  ViewVC Help
Powered by ViewVC 1.1.26