/[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.22 - (hide annotations)
Thu Oct 24 16:32:00 2002 UTC (16 years, 7 months ago) by dpavlin
Branch: MAIN
CVS Tags: HEAD
Changes since 1.21: +5 -18 lines
File MIME type: text/plain
changes to accomodate other data sources

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

  ViewVC Help
Powered by ViewVC 1.1.26