/[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.11 - (hide annotations)
Mon Jun 24 15:36:52 2002 UTC (17 years, 2 months ago) by dpavlin
Branch: MAIN
Changes since 1.10: +15 -2 lines
File MIME type: text/plain
-q za manje uoutputa

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

  ViewVC Help
Powered by ViewVC 1.1.26