/[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

Contents of /isis2stream.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.20 - (show annotations)
Wed Jul 17 19:33:19 2002 UTC (17 years, 3 months ago) by dpavlin
Branch: MAIN
Changes since 1.19: +2 -1 lines
File MIME type: text/plain
privremeno maknuti ARTI

1 #!/usr/bin/perl -w
2
3 use strict;
4 use OpenIsis;
5 use Getopt::Std;
6 use Data::Dumper;
7 use common;
8
9 my %opts;
10
11 getopts('d:m:q', \%opts);
12
13 die "usage: $0 -d [database_dir] -m [database1,database2] " if (! %opts);
14
15 my $db_dir = $opts{d};
16
17 mkdir "$common::install_dir/$db_dir" if (!-e "$common::install_dir/$db_dir");
18 mkdir "$common::install_dir/$db_dir/data" if (!-e "$common::install_dir/$db_dir/data");
19
20 my $dir="$common::install_dir/$db_dir/data";
21
22
23 open(S,"> $dir/stream") || die "can't open output $dir/stream: $!";
24 open(R,"> $dir/bib") || die "can't open output $dir/bib: $!";
25 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: $!";
27
28 print S $common::mps_header;
29 print MPS $common::mps_header;
30
31 #--------------------------------------------------------------------
32 # init array in_mps_header for config checks later
33
34 my %in_mps_header;
35 foreach (split(/\n/,$common::mps_header)) {
36 if (/^F /) {
37 my (undef,$isis,$mps,undef) = split(/ /,$_,4);
38 $in_mps_header{$mps}=$isis;
39 }
40 }
41 require "./search/config.pm";
42
43 #--------------------------------------------------------------------
44 # read database configuration, store database names
45 open(CF,$common::database_cf) || die "$common::database_cf: $!";
46 my %DatabaseDescriptions;
47 while(<CF>) {
48 chomp;
49 if (/^database-name:([^=]+)=(.*)$/) {
50 my ($db_name,$db_desc) = ($1,$2);
51 $db_desc=~s/^##\w+##//g;
52 # c_iso_852 is a cludge so that output format would be
53 # correct 8859-2 again...
54 $DatabaseDescriptions{$db_name}=c_iso_852($db_desc);
55 }
56 }
57 close(CF);
58
59 #--------------------------------------------------------------------
60 #
61 # expand(nr,"space separated string");
62 #
63
64 sub expand {
65 my $nr = shift @_;
66 die "$nr is not in mps_header" if (!$in_mps_header{$nr});
67 my $out = "";
68 while (my $fld = c_852_iso(shift @_)) {
69 my @words=split(/\s+/,$fld);
70 foreach my $w (@words) {
71 # FIX: this should be replaced by stemmer!
72 #$w =~ tr/¹©ðÐèÈæƾ®/sSdDcCcCzZ/;
73 $w =~ tr/Çüéâäùæç³ëÕõî¬ÄÆÉÅåôö¥µ¦¶ÖÜ«»£èáíóú¡±®¾Êê¼ÈºÁÂ̪¯¿ÃãðÐÏËïÒÍÎìÞÙÓÔÑñò©¹ÀÚàÛýÝþ´­½²·¢¸¨ÿØø/CueaauccleOoiZACELlooLlSsOUTtLcaiouAaZzEezCsAAESZzAadDDEdNIIeTUOoNnnSsRUrUyYt'-".'',"'Rr/;
74 $w =~ s/ß/ss/g;
75 $out .= "W $w $nr\n";
76 }
77 }
78 return $out;
79 }
80
81 #--------------------------------------------------------------------
82
83 sub c_852_iso {
84 my $tmp = $_[0];
85 $tmp =~ tr/€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúüýþÿ/Çüéâäùæç³ëÕõî¬ÄÆÉÅåôö¥µ¦¶ÖÜ«»£×èáíóú¡±®¾ÊꔼȺ—„•’ˆƒÁÂ̪‡€œ›¯¿‹Ÿ–˜Ž‘Ã㍐…†“™ž¤ðÐÏËïÒÍÎ슂‰šÞٝÓßÔÑñò©¹ÀÚàÛýÝþ´­½²·¢§÷¸°¨ÿØøŒ / if ($tmp);
86 return $tmp;
87 }
88
89 sub c_iso_852 {
90 my $tmp = $_[0];
91 $tmp =~ tr/Çüéâäùæç³ëÕõî¬ÄÆÉÅåôö¥µ¦¶ÖÜ«»£×èáíóú¡±®¾ÊꔼȺ—„•’ˆƒÁÂ̪‡€œ›¯¿‹Ÿ–˜Ž‘Ã㍐…†“™ž¤ðÐÏËïÒÍÎ슂‰šÞٝÓßÔÑñò©¹ÀÚàÛýÝþ´­½²·¢§÷¸°¨ÿØøŒ /€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúüýþÿ/ if ($tmp);
92 return $tmp;
93 }
94
95 sub c_852_czs {
96 my $tmp = $_[0];
97 $tmp =~ tr/€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúüýþÿ/Çüéâäùæç³ëÕõî¬ÄÆÉÅåôö¥µ¦¶ÖÜ«»£×èáíóú¡±®¾ÊꔼȺ—„•’ˆƒÁÂ̪‡€œ›¯¿‹Ÿ–˜Ž‘Ã㍐…†“™ž¤ðÐÏËïÒÍÎ슂‰šÞٝÓßÔÑñò©¹ÀÚàÛýÝþ´­½²·¢§÷¸°¨ÿØøŒ /;
98 $tmp =~ tr/Çüéâäùæç³ëÕõî¬ÄÆÉÅåôö¥µ¦¶ÖÜ«»£èáíóú¡±®¾Êê¼ÈºÁÂ̪¯¿ÃãðÐÏËïÒÍÎìÞÙÓÔÑñò©¹ÀÚàÛýÝþ´­½²·¢¸¨ÿØø/CueaauccleOoiZACELlooLlSsOUTtLcaiouAaZzEezCsAAESZzAadDDEdNIIeTUOoNnnSsRUrUyYt'-".'',"'Rr/;
99 $tmp =~ s/ß/ss/g;
100 return $tmp;
101 }
102
103 #--------------------------------------------------------------------
104
105 # $mps .= sf_to_mps("subfields",$subfiled_hash)
106 #
107 # subfields options:
108 # * - all (no sort)
109 # > - all, sort ascending
110 # < - all, sort descending
111
112 sub subfields_str_2_arr {
113 my $subfields = shift @_ || return;
114 my $sf_hash = shift @_;
115 my @sf_arr;
116
117 if ($subfields eq "*") {
118 @sf_arr = keys %{$sf_hash};
119 } elsif ($subfields eq ">") {
120 @sf_arr = sort keys %{$sf_hash};
121 } elsif ($subfields eq "<") {
122 @sf_arr = sort {$b cmp $a} keys %{$sf_hash};
123 } elsif ($subfields =~ s/>//) {
124 @sf_arr = sort split(//,$subfields);
125 } elsif ($subfields =~ s/<//) {
126 @sf_arr = sort {$b cmp $a} split(//,$subfields);
127 } else {
128 @sf_arr = split(//,$subfields);
129 }
130 return @sf_arr;
131 }
132
133
134 sub sf_to_mps {
135 my ($sf_hash,$subfields,$mps_id) = @_;
136 die "$mps_id is not in mps_header" if (!$in_mps_header{$mps_id});
137 my $out="";
138 my @sf_arr = subfields_str_2_arr($subfields,$sf_hash);
139
140 foreach (@sf_arr) {
141 $out.=mps_expand($mps_id,$sf_hash->{$_});
142 }
143 return $out;
144 }
145
146 #--------------------------------------------------------------------
147
148 # $mps .= isis_to_mps ($row,isis_id,mps_id[,"subfields"])
149
150 sub isis_to_mps {
151 my $row = shift @_ || die;
152 my $isis_id = shift @_ || die;
153 my $mps_id = shift @_ || die;
154 my $subfields = shift @_;
155
156 die "$mps_id is not in mps_header" if (!$in_mps_header{$mps_id});
157
158 my $i=0;
159 my $out = "";
160
161 while ($row->{$isis_id}->[$i]) {
162 my $sf_hash = OpenIsis::subfields($row->{$isis_id}->[$i]);
163
164 if (scalar keys %{$sf_hash} > 0) {
165 if ($subfields) {
166 foreach (split(//,$subfields)) {
167 $out.=mps_expand($mps_id,$sf_hash->{$_});
168 }
169 } else {
170 foreach (keys %{$sf_hash}) {
171 $out.=mps_expand($mps_id,$sf_hash->{$_});
172 }
173 }
174 } else {
175 $out.=mps_expand($mps_id,$row->{$isis_id}->[$i]);
176 }
177 $i++;
178 }
179 return $out;
180 }
181
182 #--------------------------------------------------------------------
183
184 # $bib .= isis_to_bib ($row,isis_id,bib_id,"subfields",[,group size][,"group sort"][,"separator"])
185 #
186 # fields:
187 # * - all (no sort)
188 # > - all, sort ascending
189 # < - all, sort descending
190 #
191
192 sub isis_to_bib {
193 my $row = shift @_ || die;
194 my $isis_id = shift @_ || die;
195 my $bib_id = shift @_ || die;
196 my $subfields = shift @_ || '*';
197 my $group_size = shift @_ || 0;
198 my $group_sort = shift @_ || '';
199 my $sep = shift @_ || ' ';
200
201 my $fld = $bib_id; $fld =~ s/^%//;
202 die "$fld is not in FieldNames" if (!$default::FieldNames{$fld});
203
204 my $i=0;
205
206 my $bib="";
207
208 my $sf_hash;
209
210 # bib_grp(('a','b','c'))
211 sub bib_grp {
212 my $bib_grp;
213 my $sf_hash = shift @_ || return "";
214 my $bib_id = shift @_;
215 my $sep = shift @_;
216 foreach (@_) {
217 next if (! defined $sf_hash->{$_});
218 if ($bib_grp) {
219 $bib_grp.= $sep . $sf_hash->{$_};
220 } else {
221 $bib_grp = $sf_hash->{$_};
222 }
223 }
224 if ($bib_grp) {
225 return "$bib_id $bib_grp\n"
226 } else {
227 return "";
228 }
229 }
230
231 while ($row->{$isis_id}->[$i]) {
232 my $sf_hash = OpenIsis::subfields($row->{$isis_id}->[$i]);
233
234 if (scalar keys %{$sf_hash} > 0) {
235 if ($group_size) {
236 my $tmp_flds = join("",subfields_str_2_arr($subfields,$sf_hash));
237 while ($tmp_flds) {
238 my $tmp_fld_grp = substr($tmp_flds,0,$group_size);
239 $bib .= bib_grp( $sf_hash, $bib_id, $sep, subfields_str_2_arr($tmp_fld_grp.$group_sort) );
240 last if (length($tmp_flds) <= $group_size);
241 $tmp_flds=substr($tmp_flds,$group_size,length($tmp_flds)-$group_size);
242 }
243
244 } else {
245 $bib .= bib_grp( $sf_hash, $bib_id, $sep, subfields_str_2_arr($subfields,$sf_hash) );
246 }
247 } else {
248 # no subfields, use just value!
249 $bib .= "$bib_id ".$row->{$isis_id}->[$i]."\n";
250 }
251 $i++;
252 }
253 return $bib;
254 }
255
256 #--------------------------------------------------------------------
257
258 sub isis_sf {
259 my $row = shift @_;
260 my $isis_id = shift @_;
261 my $subfield = shift @_;
262 my $prefix = shift @_ || '';
263 my $postfix = shift @_ || '';
264
265 my @sep = @_; # rest are separators
266
267 if ($row->{$isis_id}->[0]) {
268 my $sf = OpenIsis::subfields($row->{$isis_id}->[0]);
269 if (! defined $subfield || length($subfield) == 0) {
270 # subfield list undef, empty or no defined subfields for this record
271 return $prefix . $row->{$isis_id}->[0] . $postfix;
272 } elsif (length($subfield) == 1) {
273 if ($sf->{$subfield}) {
274 return $prefix . $sf->{$subfield} . $postfix;
275 } else {
276 return '';
277 }
278 } elsif (length($subfield) > 1) {
279 my @s = split(//,$subfield);
280 my $out;
281 foreach (@s) {
282 my $sep = shift @sep || ' ';
283 if ($out) {
284 $out .= $sep . $sf->{$_} if ($sf->{$_});
285 } else {
286 $out = $sf->{$_} if ($sf->{$_});
287 }
288 }
289 return $prefix . $out . $postfix if ($out);
290 }
291 }
292 return '';
293 }
294
295 #--------------------------------------------------------------------
296
297 my $last_tell=0;
298
299 my @isis_dirs = ( '.' ); # use dirname as database name
300
301 if ($opts{m}) {
302 @isis_dirs = split(/,/,$opts{m});
303 }
304
305 my @isis_dbs;
306
307 foreach (@isis_dirs) {
308 if (-e "$common::isis_data/$db_dir/$_/LIBRI") {
309 push @isis_dbs,"$common::isis_data/$db_dir/$_/LIBRI/LIBRI";
310 }
311 if (-e "$common::isis_data/$db_dir/$_/PERI") {
312 push @isis_dbs,"$common::isis_data/$db_dir/$_/PERI/PERI";
313 }
314 if (-e "$common::isis_data/$db_dir/$_/AMS") {
315 push @isis_dbs,"$common::isis_data/$db_dir/$_/AMS/AMS";
316 }
317 if (-e "$common::isis_data/$db_dir/$_/ARTI") {
318 # push @isis_dbs,"$common::isis_data/$db_dir/$_/ARTI/ARTI";
319 }
320 }
321
322 foreach my $isis_db (@isis_dbs) {
323
324 print MPS "M reading ISIS from '$isis_db'...\n";
325
326 my $db = OpenIsis::open( "$isis_db" );
327
328 if (! defined $db) {
329 die "can't open '$isis_db'";
330 }
331
332 my $tip = $isis_db; $tip =~ s/^.+?\/([^\/]+)$/$1/;
333 if (defined $default::tip{$tip}) {
334 $tip=$default::tip{$tip};
335 } elsif ($tip eq "AMS") {
336 $tip=$default::tip{'LIBRI'};
337 } else {
338 die "can't find tip for database '$isis_db'";
339 }
340 $tip = c_iso_852($tip);
341
342 my $max_rowid = OpenIsis::maxRowid( $db );
343
344 my $last_pcnt = 0;
345
346 for (my $row_id = 1; $row_id <= $max_rowid; $row_id++ ) {
347 my $row = OpenIsis::read( $db, $row_id );
348 if (my $tmp = $row->{'200'}->[0]) {
349
350 my $bib;
351 my $mps = "W $row->{mfn} 14\n";
352
353 # tip gradje
354 $mps .= "W ".c_852_czs($tip)." 17\n";
355 $bib .= "%tip $tip\n";
356
357 my $pcnt = int($row->{mfn} * 100 / $max_rowid);
358 if ($pcnt != $last_pcnt) {
359 printf MPS ("M %5d / %5d -- %-2d %%\n",$row->{mfn},$max_rowid,$pcnt) if (! $opts{q});
360 $last_pcnt = $pcnt;
361 }
362
363 my $headline;
364 $headline .= isis_sf($row,'200','a');
365 $headline .= isis_sf($row,'200','e'," : ");
366 $headline .= isis_sf($row,'200','f'," / ");
367 $headline .= isis_sf($row,'210','d'," , ");
368
369 # remove newlines, compress spaces
370 $headline =~ s/[\n\r]//g;
371 $headline =~ s/^\s+//g;
372 $headline =~ s/\s+$//g;
373
374 # author
375 $bib .= isis_to_bib($row,'700','%700+','ab',undef,'>',', ');
376 $bib .= isis_to_bib($row,'701','%700+','ab',undef,'>',', ');
377 $bib .= isis_to_bib($row,'701','%700+','cd',undef,'>',', ');
378
379 my $tmp;
380 $tmp = isis_sf($row,'710','abc', '', '', (' : ',', '));
381 $tmp .= isis_sf($row,'710','dfe', ' (', ')', ('', ' ; ',' ; '));
382 $bib .= "%700+ $tmp\n" if ($tmp);
383
384 $tmp = isis_sf($row,'711','abc', '', '', (' : ',', '));
385 $tmp .= isis_sf($row,'711','dfe', ' (', ')', ('', ' ; ',' ; '));
386 $bib .= "%700+ $tmp\n" if ($tmp);
387
388 $bib .= isis_to_bib($row,'503','%700+','ab',undef,'>',', ');
389
390 $mps .= isis_to_mps($row,'700',1);
391 $mps .= isis_to_mps($row,'701',1);
392 $mps .= isis_to_mps($row,'710',1);
393 $mps .= isis_to_mps($row,'711',1);
394 $mps .= isis_to_mps($row,'503',1);
395 $mps .= isis_to_mps($row,'702',1);
396 $mps .= isis_to_mps($row,'200',1,"fg");
397
398 $bib .= isis_to_bib($row,'205','%205');
399
400 # naslov
401 my $sf = OpenIsis::subfields($row->{'200'}->[0]);
402 my $book;
403 $book .= $sf->{a} if ($sf->{a});
404 $book .= " ; ".$sf->{k} if ($sf->{k});
405 $book .= " = ".$sf->{d} if ($sf->{d});
406 $book .= " : ".$sf->{e} if ($sf->{e});
407 $book .= " / ".$sf->{f} if ($sf->{f});
408 $book .= " ; ".$sf->{g} if ($sf->{g});
409 $book .= ". ".$sf->{c} if ($sf->{c});
410 $book .= " / ".$sf->{x} if ($sf->{x});
411 $book .= " ; ".$sf->{y} if ($sf->{y});
412 $bib .= "%200+ $book\n" if ($book);
413
414 $mps .= isis_to_mps($row,'200',2,"akcde");
415 $mps .= isis_to_mps($row,'532',2);
416 $mps .= isis_to_mps($row,'424',2);
417
418 $mps .= isis_to_mps($row,'230',2,"ae");
419 $mps .= isis_to_mps($row,'231',2,"ae");
420 $mps .= isis_to_mps($row,'232',2,"ae");
421 $mps .= isis_to_mps($row,'233',2,"ae");
422
423
424 $tmp = isis_sf($row,'230','v').
425 isis_sf($row,'230','a',' : ').
426 isis_sf($row,'250',undef,'. - ').
427 isis_sf($row,'260',undef,'. - ').
428 isis_sf($row,'290',undef,'<br>ISBN ');
429 $bib .= "%sv $tmp\n" if ($tmp);
430
431 $tmp = isis_sf($row,'231','v','<br>').
432 isis_sf($row,'231','a',' : ').
433 isis_sf($row,'251',undef,'. - ').
434 isis_sf($row,'261',undef,'. - ').
435 isis_sf($row,'291',undef,'<br>ISBN ');
436 $bib .= "%sv $tmp\n" if ($tmp);
437
438 $tmp = isis_sf($row,'232','v','<br>').
439 isis_sf($row,'232','a',' : ').
440 isis_sf($row,'252',undef,'. - ').
441 isis_sf($row,'262',undef,'. - ').
442 isis_sf($row,'292',undef,'<br>ISBN ');
443 $bib .= "%sv $tmp\n" if ($tmp);
444
445 $tmp = isis_sf($row,'233','v','<br>').
446 isis_sf($row,'233','a',' : ').
447 isis_sf($row,'253',undef,'. - ').
448 isis_sf($row,'263',undef,'. - ').
449 isis_sf($row,'293',undef,'<br>ISBN ');
450
451 $mps .= isis_to_mps($row,'270',2);
452 $mps .= isis_to_mps($row,'271',2);
453 $mps .= isis_to_mps($row,'272',2);
454 $mps .= isis_to_mps($row,'273',2);
455
456 # izdavac
457 $mps .= isis_to_mps($row,'210',3);
458 $mps .= isis_to_mps($row,'250',3);
459 $mps .= isis_to_mps($row,'251',3);
460 $mps .= isis_to_mps($row,'252',3);
461 $mps .= isis_to_mps($row,'253',3);
462 # if (my $sf = OpenIsis::subfields($row->{'210'}->[0])) {
463 # my $tmp;
464 # $tmp .= $sf->{a} if ($sf->{a});
465 # $tmp .= " : ".$sf->{c} if ($sf->{c});
466 # $tmp .= ", ".$sf->{d} if ($sf->{d});
467 # $bib .= "%210 $tmp\n" if ($tmp);
468 # }
469 $bib .= "%210+ ".isis_sf($row,'210','acd', '','', ('',' : ',', ') )."\n";
470
471 if (my $year = isis_sf($row,'210','d')) {
472 $year =~ s/^\s*cop\.*\s*//i;
473 $year =~ s/[\[\]]*//g;
474 $year =~ s/[\n\r]//g; # remove cr
475 $mps .= "D ${year}\n" if ($year !~ m/\?/ && $year =~ /\d{4}/);
476 }
477
478 $mps .= isis_to_mps($row,'215',15);
479 $mps .= isis_to_mps($row,'260',15);
480 $mps .= isis_to_mps($row,'261',15);
481 $mps .= isis_to_mps($row,'262',15);
482 $mps .= isis_to_mps($row,'263',15);
483 $bib .= isis_to_bib($row,'215','%215+', '*', undef, undef, ', ');
484
485 # $bib .= isis_to_bib($row,'225','%225', 'aehivw');
486 $bib .= "%225 ".isis_sf($row,'225','aevhiw', '(',')', ('',' : ',' ; ','. ',', ',' ; '))."\n";
487 $mps .= isis_to_mps($row,'225',4);
488
489 $bib .= isis_to_bib($row,'300','%300+');
490 $bib .= isis_to_bib($row,'320','%300+');
491 $bib .= isis_to_bib($row,'327','%300+');
492 $mps .= isis_to_mps($row,'300',5);
493 $mps .= isis_to_mps($row,'320',5);
494 $mps .= isis_to_mps($row,'327',5);
495 $mps .= isis_to_mps($row,'280',5);
496 $mps .= isis_to_mps($row,'281',5);
497 $mps .= isis_to_mps($row,'282',5);
498 $mps .= isis_to_mps($row,'283',5);
499
500 $bib .= isis_to_bib($row,'330','%330');
501 $mps .= isis_to_mps($row,'330',6);
502
503 $bib .= isis_to_bib($row,'423','%423');
504 $bib .= isis_to_bib($row,'464','%464');
505 $mps .= isis_to_mps($row,'464',7);
506 $bib .= isis_to_bib($row,'610','%610');
507 $mps .= isis_to_mps($row,'610',8);
508
509 $bib .= isis_to_bib($row,'675','%675+','a');
510 $mps .= isis_to_mps($row,'675',9);
511 $bib .= isis_to_bib($row,'686','%675+','a');
512 $mps .= isis_to_mps($row,'686',10);
513
514 $bib .= isis_to_bib($row,'990','%990');
515 $mps .= isis_to_mps($row,'990',11);
516
517 $bib .= isis_to_bib($row,'991','%991');
518 $mps .= isis_to_mps($row,'991',12);
519
520 # Jezik
521 $bib .= isis_to_bib($row,'101','%101');
522 $mps .= isis_to_mps($row,'101',16);
523 # Pismo
524 $bib .= isis_to_bib($row,'998','%101', 'a');
525
526 sub isis_isn_to_mps {
527 my $row = shift @_ || die;
528 my $isis_id = shift @_ || die;
529 my $nr = shift @_ || die;
530 my $i=0;
531 my $mps='';
532 while (my $isn=$row->{$isis_id}->[$i]) {
533 $isn =~ s/ +//g; # remove spaces
534 $isn =~ s/[\n\r]//g; # remove cr
535 $mps .= "W $isn $nr\n";
536 if ($isn =~ s/-//g) {
537 $mps .= "W $isn $nr\n";
538 }
539 $i++;
540 }
541 return $mps;
542 }
543
544 # ISBN
545 $bib .= isis_to_bib($row,'10','%ISBN');
546 $mps .= isis_isn_to_mps($row,'10',13);
547 $mps .= isis_isn_to_mps($row,'290',13);
548 $mps .= isis_isn_to_mps($row,'291',13);
549 $mps .= isis_isn_to_mps($row,'292',13);
550 $mps .= isis_isn_to_mps($row,'293',13);
551
552 # ISSN
553 $bib .= isis_to_bib($row,'11','%ISSN');
554 $mps .= isis_isn_to_mps($row,'11',13);
555
556 $mps .= isis_to_mps($row,'532',1);
557
558 # Casopisi
559 $tmp = isis_to_bib($row,'326','%326');
560 $tmp =~ s/g1/godi¹njak/;
561 $tmp =~ s/g6/dvomjeseènik/;
562 $tmp =~ s/10/godi¹nje 10 brojeva/;
563 $tmp =~ s/m1/mjeseènik/;
564 $tmp =~ s/m2/polumjeseènik/;
565 $tmp =~ s/nr/neredovito/;
566 $tmp =~ s/g4/èetiri puta godi¹nje/;
567 $bib .= c_iso_852($tmp);
568 $bib .= isis_to_bib($row,'992','%992');
569
570 $bib .= '%knjiz '.$DatabaseDescriptions{$db_dir}.", ".$row->{mfn}."\n";
571 # headline
572 if ($headline) {
573 $headline .= " <i>(".$DatabaseDescriptions{$db_dir}.", ".$row->{mfn}.")</i>"; ## debug MFN!
574 $headline =~ s/&/&and;/g;
575 $headline =~ s/</&lt;/g;
576 $headline =~ s/>/&gt;/g;
577 $mps .= "H ".c_852_iso($headline)."\n";
578 } else {
579 $mps .= "H nepoznato\n";
580 }
581
582
583 #if ($db_dir eq "sf") {
584 # print "MFN: $row->{mfn} ROW ID: $row_id\n";
585 # if ($row->{mfn} >= 146) {
586 # print Dumper($row);
587 # }
588 #}
589
590 print R c_852_iso($bib);
591
592 # check if all fields are defined
593 foreach (split(/\n/,$bib)) {
594 if (/^%(\w+)\s/ && !$default::FieldNames{$1}) {
595 die "field $1 used but not in FieldNames";
596 }
597 }
598
599 # print R "%perl ".Dumper($row)."\n";
600
601 $mps .= "T document text/plain ".(tell(R) - $last_tell)." $dir/bib $last_tell ".tell(R)."\n";
602 $last_tell=tell(R);
603
604 print R "\n";
605
606 $mps .= "E\n";
607
608
609 print S $mps;
610 print MPS $mps;
611 }
612 }
613 }
614 print S "M over and out\nX\n";
615 print MPS "M over and out\nX\n";
616 close(MPS);

  ViewVC Help
Powered by ViewVC 1.1.26