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

Annotation of /isis2stream.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.19 - (hide annotations)
Wed Jul 17 18:37:37 2002 UTC (17 years, 3 months ago) by dpavlin
Branch: MAIN
Changes since 1.18: +37 -1 lines
File MIME type: text/plain
podrska za casopise (polja, pretrazivanje)

1 dpavlin 1.1 #!/usr/bin/perl -w
2    
3     use strict;
4     use OpenIsis;
5     use Getopt::Std;
6 dpavlin 1.7 use Data::Dumper;
7 dpavlin 1.4 use common;
8 dpavlin 1.1
9     my %opts;
10    
11 dpavlin 1.11 getopts('d:m:q', \%opts);
12 dpavlin 1.1
13 dpavlin 1.4 die "usage: $0 -d [database_dir] -m [database1,database2] " if (! %opts);
14 dpavlin 1.1
15     my $db_dir = $opts{d};
16    
17 dpavlin 1.4 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 dpavlin 1.1
20 dpavlin 1.4 my $dir="$common::install_dir/$db_dir/data";
21 dpavlin 1.1
22    
23 dpavlin 1.4 open(S,"> $dir/stream") || die "can't open output $dir/stream: $!";
24 dpavlin 1.1 open(R,"> $dir/bib") || die "can't open output $dir/bib: $!";
25 dpavlin 1.4 open(MPS,"| $common::mpsindex -d $common::install_dir/$db_dir -autokey") || die "can't start MPS indexer $common::mpsindex: $!";
26 dpavlin 1.1 #open(MPS,"> /tmp/mpsindex") || die "mps: $!";
27    
28 dpavlin 1.4 print S $common::mps_header;
29     print MPS $common::mps_header;
30 dpavlin 1.1
31 dpavlin 1.8 #--------------------------------------------------------------------
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 dpavlin 1.10 # 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 dpavlin 1.18 # 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 dpavlin 1.10 }
56     }
57     close(CF);
58    
59     #--------------------------------------------------------------------
60 dpavlin 1.1 #
61     # expand(nr,"space separated string");
62     #
63    
64     sub expand {
65     my $nr = shift @_;
66 dpavlin 1.8 die "$nr is not in mps_header" if (!$in_mps_header{$nr});
67 dpavlin 1.1 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 dpavlin 1.11 sub c_iso_852 {
90     my $tmp = $_[0];
91     $tmp =~ tr/Çüéâäùæç³ëÕõî¬ÄÆÉÅåôö¥µ¦¶ÖÜ«»£×èáíóú¡±®¾ÊꔼȺ—„•’ˆƒÁÂ̪‡€œ›¯¿‹Ÿ–˜Ž‘Ã㍐…†“™ž¤ðÐÏËïÒÍÎ슂‰šÞٝÓßÔÑñò©¹ÀÚàÛýÝþ´­½²·¢§÷¸°¨ÿØøŒ /€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúüýþÿ/ if ($tmp);
92     return $tmp;
93     }
94    
95 dpavlin 1.1 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 dpavlin 1.8 # $mps .= sf_to_mps("subfields",$subfiled_hash)
106 dpavlin 1.1 #
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 dpavlin 1.8 die "$mps_id is not in mps_header" if (!$in_mps_header{$mps_id});
137 dpavlin 1.1 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 dpavlin 1.8 die "$mps_id is not in mps_header" if (!$in_mps_header{$mps_id});
157    
158 dpavlin 1.1 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 dpavlin 1.8 my $fld = $bib_id; $fld =~ s/^%//;
202     die "$fld is not in FieldNames" if (!$default::FieldNames{$fld});
203    
204 dpavlin 1.1 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 dpavlin 1.7 my $subfield = shift @_;
262 dpavlin 1.1 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 dpavlin 1.7 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 dpavlin 1.1 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 dpavlin 1.6 my @isis_dirs = ( '.' ); # use dirname as database name
300 dpavlin 1.1
301 dpavlin 1.5 if ($opts{m}) {
302 dpavlin 1.6 @isis_dirs = split(/,/,$opts{m});
303 dpavlin 1.5 }
304 dpavlin 1.1
305 dpavlin 1.6 my @isis_dbs;
306 dpavlin 1.1
307 dpavlin 1.6 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 dpavlin 1.19 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 dpavlin 1.6 }
321    
322     foreach my $isis_db (@isis_dbs) {
323    
324     print MPS "M reading ISIS from '$isis_db'...\n";
325 dpavlin 1.5
326 dpavlin 1.6 my $db = OpenIsis::open( "$isis_db" );
327 dpavlin 1.5
328 dpavlin 1.19 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 dpavlin 1.5 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 dpavlin 1.1 my $row = OpenIsis::read( $db, $row_id );
348     if (my $tmp = $row->{'200'}->[0]) {
349    
350 dpavlin 1.16 my $bib;
351 dpavlin 1.7 my $mps = "W $row->{mfn} 14\n";
352 dpavlin 1.1
353 dpavlin 1.19 # tip gradje
354     $mps .= "W ".c_852_czs($tip)." 17\n";
355     $bib .= "%tip $tip\n";
356    
357 dpavlin 1.1 my $pcnt = int($row->{mfn} * 100 / $max_rowid);
358     if ($pcnt != $last_pcnt) {
359 dpavlin 1.11 printf MPS ("M %5d / %5d -- %-2d %%\n",$row->{mfn},$max_rowid,$pcnt) if (! $opts{q});
360 dpavlin 1.1 $last_pcnt = $pcnt;
361     }
362    
363     my $headline;
364 dpavlin 1.10 $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 dpavlin 1.1
369 dpavlin 1.11 # remove newlines, compress spaces
370     $headline =~ s/[\n\r]//g;
371     $headline =~ s/^\s+//g;
372     $headline =~ s/\s+$//g;
373    
374 dpavlin 1.1 # author
375 dpavlin 1.14 $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 dpavlin 1.17 my $tmp;
380     $tmp = isis_sf($row,'710','abc', '', '', (' : ',', '));
381 dpavlin 1.14 $tmp .= isis_sf($row,'710','dfe', ' (', ')', ('', ' ; ',' ; '));
382     $bib .= "%700+ $tmp\n" if ($tmp);
383    
384 dpavlin 1.17 $tmp = isis_sf($row,'711','abc', '', '', (' : ',', '));
385 dpavlin 1.14 $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 dpavlin 1.1
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 dpavlin 1.7 $mps .= isis_to_mps($row,'200',1,"fg");
397 dpavlin 1.1
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 dpavlin 1.8 $bib .= "%200+ $book\n" if ($book);
413 dpavlin 1.1
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 dpavlin 1.7 $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 dpavlin 1.8 $tmp = isis_sf($row,'230','v').
425 dpavlin 1.7 isis_sf($row,'230','a',' : ').
426     isis_sf($row,'250',undef,'. - ').
427     isis_sf($row,'260',undef,'. - ').
428 dpavlin 1.8 isis_sf($row,'290',undef,'<br>ISBN ');
429     $bib .= "%sv $tmp\n" if ($tmp);
430    
431     $tmp = isis_sf($row,'231','v','<br>').
432 dpavlin 1.7 isis_sf($row,'231','a',' : ').
433     isis_sf($row,'251',undef,'. - ').
434     isis_sf($row,'261',undef,'. - ').
435 dpavlin 1.8 isis_sf($row,'291',undef,'<br>ISBN ');
436     $bib .= "%sv $tmp\n" if ($tmp);
437    
438     $tmp = isis_sf($row,'232','v','<br>').
439 dpavlin 1.7 isis_sf($row,'232','a',' : ').
440     isis_sf($row,'252',undef,'. - ').
441     isis_sf($row,'262',undef,'. - ').
442 dpavlin 1.8 isis_sf($row,'292',undef,'<br>ISBN ');
443     $bib .= "%sv $tmp\n" if ($tmp);
444    
445     $tmp = isis_sf($row,'233','v','<br>').
446 dpavlin 1.7 isis_sf($row,'233','a',' : ').
447     isis_sf($row,'253',undef,'. - ').
448     isis_sf($row,'263',undef,'. - ').
449 dpavlin 1.8 isis_sf($row,'293',undef,'<br>ISBN ');
450 dpavlin 1.7
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 dpavlin 1.1 # izdavac
457     $mps .= isis_to_mps($row,'210',3);
458 dpavlin 1.7 $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 dpavlin 1.1 # 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 dpavlin 1.7 $bib .= "%210+ ".isis_sf($row,'210','acd', '','', ('',' : ',', ') )."\n";
470 dpavlin 1.1
471     if (my $year = isis_sf($row,'210','d')) {
472     $year =~ s/^\s*cop\.*\s*//i;
473     $year =~ s/[\[\]]*//g;
474 dpavlin 1.11 $year =~ s/[\n\r]//g; # remove cr
475 dpavlin 1.1 $mps .= "D ${year}\n" if ($year !~ m/\?/ && $year =~ /\d{4}/);
476     }
477    
478 dpavlin 1.7 $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 dpavlin 1.1
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 dpavlin 1.7 $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 dpavlin 1.1
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 dpavlin 1.17 $bib .= isis_to_bib($row,'675','%675+','a');
510 dpavlin 1.1 $mps .= isis_to_mps($row,'675',9);
511 dpavlin 1.17 $bib .= isis_to_bib($row,'686','%675+','a');
512 dpavlin 1.1 $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 dpavlin 1.16
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 dpavlin 1.1
526 dpavlin 1.9 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 dpavlin 1.7 $isn =~ s/ +//g; # remove spaces
534 dpavlin 1.11 $isn =~ s/[\n\r]//g; # remove cr
535 dpavlin 1.7 $mps .= "W $isn $nr\n";
536     if ($isn =~ s/-//g) {
537     $mps .= "W $isn $nr\n";
538     }
539 dpavlin 1.9 $i++;
540 dpavlin 1.7 }
541 dpavlin 1.9 return $mps;
542 dpavlin 1.7 }
543    
544 dpavlin 1.1 # ISBN
545 dpavlin 1.9 $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 dpavlin 1.7
552     # ISSN
553 dpavlin 1.19 $bib .= isis_to_bib($row,'11','%ISSN');
554     $mps .= isis_isn_to_mps($row,'11',13);
555 dpavlin 1.1
556     $mps .= isis_to_mps($row,'532',1);
557 dpavlin 1.19
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     $bib .= c_iso_852($tmp);
567     $bib .= isis_to_bib($row,'992','%992');
568 dpavlin 1.1
569 dpavlin 1.15 $bib .= '%knjiz '.$DatabaseDescriptions{$db_dir}.", ".$row->{mfn}."\n";
570 dpavlin 1.1 # headline
571     if ($headline) {
572 dpavlin 1.10 $headline .= " <i>(".$DatabaseDescriptions{$db_dir}.", ".$row->{mfn}.")</i>"; ## debug MFN!
573 dpavlin 1.8 $headline =~ s/&/&and;/g;
574     $headline =~ s/</&lt;/g;
575     $headline =~ s/>/&gt;/g;
576 dpavlin 1.1 $mps .= "H ".c_852_iso($headline)."\n";
577     } else {
578     $mps .= "H nepoznato\n";
579     }
580    
581    
582     #if ($db_dir eq "sf") {
583     # print "MFN: $row->{mfn} ROW ID: $row_id\n";
584     # if ($row->{mfn} >= 146) {
585     # print Dumper($row);
586     # }
587     #}
588    
589     print R c_852_iso($bib);
590 dpavlin 1.8
591     # check if all fields are defined
592     foreach (split(/\n/,$bib)) {
593     if (/^%(\w+)\s/ && !$default::FieldNames{$1}) {
594     die "field $1 used but not in FieldNames";
595     }
596     }
597    
598     # print R "%perl ".Dumper($row)."\n";
599 dpavlin 1.1
600     $mps .= "T document text/plain ".(tell(R) - $last_tell)." $dir/bib $last_tell ".tell(R)."\n";
601     $last_tell=tell(R);
602    
603     print R "\n";
604    
605     $mps .= "E\n";
606    
607    
608     print S $mps;
609     print MPS $mps;
610     }
611 dpavlin 1.5 }
612 dpavlin 1.1 }
613     print S "M over and out\nX\n";
614     print MPS "M over and out\nX\n";
615     close(MPS);

  ViewVC Help
Powered by ViewVC 1.1.26