4 |
use OpenIsis; |
use OpenIsis; |
5 |
use Getopt::Std; |
use Getopt::Std; |
6 |
#use Data::Dumper; |
#use Data::Dumper; |
7 |
|
use common; |
|
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 |
|
8 |
|
|
9 |
my %opts; |
my %opts; |
10 |
|
|
11 |
getopt('dD', \%opts); |
getopt('dm', \%opts); |
12 |
|
|
13 |
die "usage: $0 -d [database_dir] " if (! $opts{d}); |
die "usage: $0 -d [database_dir] -m [database1,database2] " if (! %opts); |
14 |
|
|
15 |
my $db_dir = $opts{d}; |
my $db_dir = $opts{d}; |
16 |
|
|
17 |
mkdir "$install_dir/$db_dir" if (!-e "$install_dir/$db_dir"); |
mkdir "$common::install_dir/$db_dir" if (!-e "$common::install_dir/$db_dir"); |
18 |
mkdir "$install_dir/$db_dir/data" if (!-e "$install_dir/$db_dir/data"); |
mkdir "$common::install_dir/$db_dir/data" if (!-e "$common::install_dir/$db_dir/data"); |
19 |
|
|
20 |
my $dir="$install_dir/$db_dir/data"; |
my $dir="$common::install_dir/$db_dir/data"; |
21 |
|
|
22 |
|
|
23 |
open(S,"> $dir/stream") || die "can't open output $dir/stram: $!"; |
open(S,"> $dir/stream") || die "can't open output $dir/stream: $!"; |
24 |
open(R,"> $dir/bib") || die "can't open output $dir/bib: $!"; |
open(R,"> $dir/bib") || die "can't open output $dir/bib: $!"; |
25 |
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: $!"; |
26 |
#open(MPS,"> /tmp/mpsindex") || die "mps: $!"; |
#open(MPS,"> /tmp/mpsindex") || die "mps: $!"; |
27 |
|
|
28 |
my $s="V 5 3 |
print S $common::mps_header; |
29 |
L hr-HR |
print MPS $common::mps_header; |
|
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; |
|
30 |
|
|
31 |
# |
# |
32 |
# expand(nr,"space separated string"); |
# expand(nr,"space separated string"); |
156 |
} |
} |
157 |
|
|
158 |
#-------------------------------------------------------------------- |
#-------------------------------------------------------------------- |
|
# |
|
|
# 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); |
|
|
} |
|
|
|
|
|
#-------------------------------------------------------------------- |
|
159 |
|
|
160 |
# $mps .= sf_to_mps($subfiled_hash,"subfields",mps_id); |
# $mps .= sf_to_mps($subfiled_hash,"subfields",mps_id); |
161 |
# |
# |
344 |
|
|
345 |
my $last_tell=0; |
my $last_tell=0; |
346 |
|
|
347 |
my $db = OpenIsis::open( "$isis_data/$db_dir/LIBRI/LIBRI" ); |
my @isis_dirs = ( '.' ); # use dirname as database name |
348 |
|
|
349 |
|
if ($opts{m}) { |
350 |
|
@isis_dirs = split(/,/,$opts{m}); |
351 |
|
} |
352 |
|
|
353 |
|
my @isis_dbs; |
354 |
|
|
355 |
|
foreach (@isis_dirs) { |
356 |
|
if (-e "$common::isis_data/$db_dir/$_/LIBRI") { |
357 |
|
push @isis_dbs,"$common::isis_data/$db_dir/$_/LIBRI/LIBRI"; |
358 |
|
} |
359 |
|
if (-e "$common::isis_data/$db_dir/$_/PERI") { |
360 |
|
push @isis_dbs,"$common::isis_data/$db_dir/$_/PERI/PERI"; |
361 |
|
} |
362 |
|
} |
363 |
|
|
364 |
|
foreach my $isis_db (@isis_dbs) { |
365 |
|
|
366 |
|
print MPS "M reading ISIS from '$isis_db'...\n"; |
367 |
|
|
368 |
|
my $db = OpenIsis::open( "$isis_db" ); |
369 |
|
|
370 |
my $max_rowid = OpenIsis::maxRowid( $db ); |
my $max_rowid = OpenIsis::maxRowid( $db ); |
371 |
|
|
372 |
my $last_pcnt = 0; |
my $last_pcnt = 0; |
373 |
|
|
374 |
for (my $row_id = 1; $row_id <= $max_rowid; $row_id++ ) { |
for (my $row_id = 1; $row_id <= $max_rowid; $row_id++ ) { |
375 |
my $row = OpenIsis::read( $db, $row_id ); |
my $row = OpenIsis::read( $db, $row_id ); |
376 |
if (my $tmp = $row->{'200'}->[0]) { |
if (my $tmp = $row->{'200'}->[0]) { |
377 |
|
|
519 |
print S $mps; |
print S $mps; |
520 |
print MPS $mps; |
print MPS $mps; |
521 |
} |
} |
522 |
|
} |
523 |
} |
} |
524 |
print S "M over and out\nX\n"; |
print S "M over and out\nX\n"; |
525 |
print MPS "M over and out\nX\n"; |
print MPS "M over and out\nX\n"; |