19 |
|
|
20 |
This script B<is somewhat specific> to MODS export from |
This script B<is somewhat specific> to MODS export from |
21 |
Faculty of Electrical Engineering and Computing |
Faculty of Electrical Engineering and Computing |
22 |
so you might want to edit it |
so you might want to edit it (among other thing, it includes a lot |
23 |
|
of fields which are in Croatian). |
24 |
|
|
25 |
|
Feel free to hack this script and convert it to your own needs. |
26 |
|
|
27 |
=head1 WARNING |
=head1 WARNING |
28 |
|
|
85 |
ContentKey => '-content', |
ContentKey => '-content', |
86 |
); |
); |
87 |
|
|
88 |
my $m=$marc->createrecord(); |
my $m_cache; |
89 |
|
|
90 |
sub marc_arr { |
sub marc_add { |
91 |
my $m = shift || die "no marc record?"; |
my $m_cache = \shift; |
92 |
my $fld = shift || die "no marc field?"; |
my $fld = shift || die "need field!"; |
93 |
my $sf = shift || ''; |
my $sf = shift || ''; |
94 |
|
|
95 |
return if (! @_); |
return if (! @_); |
97 |
my @a; |
my @a; |
98 |
foreach (@_) { |
foreach (@_) { |
99 |
next if (! $_); |
next if (! $_); |
100 |
push @a,$sf; |
push @a,$sf if ($sf); |
101 |
# push @a,$utf2iso->convert($_) || $_; |
# push @a,$utf2iso->convert($_) || $_; |
102 |
push @a,$_; |
push @a,$_; |
103 |
} |
} |
106 |
|
|
107 |
# print "storing $fld: ",join("|",@a),"\n"; |
# print "storing $fld: ",join("|",@a),"\n"; |
108 |
|
|
109 |
$marc->addfield({record=>$m, |
push @{$$m_cache->{$fld}}, @a; |
110 |
field=>$fld, |
|
|
# i1=>$i1, |
|
|
# i2=>$i2, |
|
|
value=>\@a}); |
|
111 |
} |
} |
112 |
|
|
113 |
marc_arr($m,'610','a',@{$ref->{subject}->{topic}}); |
my $journal = 0; |
114 |
|
$journal = 1 if ($ref->{recordInfo}->{recordIdentifier} =~ m/^c-/); |
115 |
|
|
116 |
|
marc_add($m_cache,'610','a',@{$ref->{subject}->{topic}}); |
117 |
|
|
118 |
my $fld = '700'; |
my $fld = '700'; |
119 |
|
|
121 |
my $role = $name->{role}->{roleTerm}->{content}; |
my $role = $name->{role}->{roleTerm}->{content}; |
122 |
next if (! $role); |
next if (! $role); |
123 |
if ($role eq "author") { |
if ($role eq "author") { |
124 |
marc_arr($m,$fld,'a',$name->{namePart}->{family}); |
marc_add($m_cache,$fld,'a',$name->{namePart}->{family}); |
125 |
marc_arr($m,$fld,'b',$name->{namePart}->{given}); |
marc_add($m_cache,$fld,'b',$name->{namePart}->{given}); |
126 |
marc_arr($m,$fld,'4',$role); |
marc_add($m_cache,$fld,'4',$role); |
127 |
|
|
128 |
# first author goes in 700, others in 701 |
# first author goes in 700, others in 701 |
129 |
$fld = '701'; |
$fld = '701'; |
130 |
} elsif ($role eq "editor" or $role eq "illustrator") { |
} elsif ($role eq "editor" or $role eq "illustrator") { |
131 |
marc_arr($m,'702','a',$name->{namePart}->{family}); |
marc_add($m_cache,'702','a',$name->{namePart}->{family}); |
132 |
marc_arr($m,'702','b',$name->{namePart}->{given}); |
marc_add($m_cache,'702','b',$name->{namePart}->{given}); |
133 |
marc_arr($m,'702','4',$role); |
marc_add($m_cache,'702','4',$role); |
134 |
} else { |
} else { |
135 |
die "FATAL: don't know how to map role '$role'" if ($role); |
die "FATAL: don't know how to map role '$role'" if ($role); |
136 |
} |
} |
141 |
if ($note) { |
if ($note) { |
142 |
foreach my $n (split(/\s*;\s+/, $note)) { |
foreach my $n (split(/\s*;\s+/, $note)) { |
143 |
if ($n =~ s/bibliogr:\s+//i) { |
if ($n =~ s/bibliogr:\s+//i) { |
144 |
marc_arr($m,'320','a',"Bibliografija: $n"); |
marc_add($m_cache,'320','a',"Bibliografija: $n"); |
145 |
} elsif ($n =~ s/ilustr:\s+//i) { |
} elsif ($n =~ s/ilustr:\s+//i) { |
146 |
marc_arr($m,'215','c', $n); |
marc_add($m_cache,'215','c', $n); |
147 |
} else { |
} else { |
148 |
marc_arr($m,'320','a',$n); |
marc_add($m_cache,'320','a',$n); |
149 |
} |
} |
150 |
} |
} |
151 |
} |
} |
155 |
|
|
156 |
if ($type) { |
if ($type) { |
157 |
if ($type eq "isbn") { |
if ($type eq "isbn") { |
158 |
marc_arr($m,'010','a',$ref->{identifier}->{content}); |
marc_add($m_cache,'010','a',$ref->{identifier}->{content}); |
159 |
} elsif ($type eq "issn") { |
} elsif ($type eq "issn") { |
160 |
marc_arr($m,'011','a',$ref->{identifier}->{content}); |
marc_add($m_cache,'011','a',$ref->{identifier}->{content}); |
161 |
} else { |
} else { |
162 |
die "unknown identifier type $type"; |
die "unknown identifier type $type"; |
163 |
} |
} |
178 |
if ($tmp->{str}) { |
if ($tmp->{str}) { |
179 |
$data .= $tmp->{str}." str"; |
$data .= $tmp->{str}." str"; |
180 |
} |
} |
181 |
marc_arr($m,'210','a', $data) if ($data); |
marc_add($m_cache,'215','a', $data) if ($data); |
182 |
marc_arr($m,'210','d', $tmp->{visina}); |
marc_add($m_cache,'215','d', $tmp->{visina}); |
183 |
} |
} |
184 |
|
|
185 |
marc_arr($m,'001','',$ref->{recordInfo}->{recordIdentifier}); |
marc_add($m_cache,'001',undef,$ref->{recordInfo}->{recordIdentifier}); |
186 |
|
|
187 |
marc_arr($m,'200','a',$ref->{titleInfo}->{title}); |
marc_add($m_cache,'200','a',$ref->{titleInfo}->{title}); |
188 |
marc_arr($m,'200','e',$ref->{titleInfo}->{subTitle}); |
marc_add($m_cache,'200','e',$ref->{titleInfo}->{subTitle}); |
189 |
|
|
190 |
marc_arr($m,'675','a',$ref->{classification}->{udc}); |
marc_add($m_cache,'675','a',$ref->{classification}->{udc}); |
191 |
|
|
192 |
my $related = $ref->{relatedItem}->{type}; |
my $related = $ref->{relatedItem}->{type}; |
193 |
if ($related) { |
if ($related) { |
194 |
if ($related eq "series") { |
if ($related eq "series") { |
195 |
marc_arr($m,'675','a',$ref->{relatedItem}->{titleInfo}->{title}); |
marc_add($m_cache,'225','a',$ref->{relatedItem}->{titleInfo}->{title}); |
196 |
marc_arr($m,'999','a',$ref->{relatedItem}->{titleInfo}->{partNumber}); |
marc_add($m_cache,'999','a',$ref->{relatedItem}->{titleInfo}->{partNumber}); |
197 |
} elsif ($related eq "preceding") { |
} elsif ($related eq "preceding") { |
198 |
marc_arr($m,'430','a',$ref->{relatedItem}->{titleInfo}->{title}); |
marc_add($m_cache,'430','a',$ref->{relatedItem}->{titleInfo}->{title}); |
199 |
} else { |
} else { |
200 |
die "can't parse related item type $related" if ($related); |
die "can't parse related item type $related" if ($related); |
201 |
} |
} |
202 |
} |
} |
203 |
|
|
204 |
marc_arr($m,'205','a',$ref->{originInfo}->{edition}); |
marc_add($m_cache,'205','a',$ref->{originInfo}->{edition}); |
205 |
|
|
206 |
my $publisher = $ref->{originInfo}->{publisher}; |
my $publisher = $ref->{originInfo}->{publisher}; |
207 |
if ($publisher =~ m,^(.+?)\s*/\s*(.+)$,) { |
if ($publisher =~ m,^(.+?)\s*/\s*(.+)$,) { |
208 |
marc_arr($m,'210','a', $2); |
marc_add($m_cache,'210','a', $2); |
209 |
marc_arr($m,'210','c', $1); |
marc_add($m_cache,'210','c', $1); |
210 |
} else { |
} else { |
211 |
marc_arr($m,'210','c', $publisher); |
marc_add($m_cache,'210','c', $publisher); |
212 |
} |
} |
213 |
|
|
214 |
marc_arr($m,'326','a',$ref->{originInfo}->{frequency}); |
marc_add($m_cache,'326','a',$ref->{originInfo}->{frequency}) if ($journal); |
215 |
marc_arr($m,'326','a',$ref->{originInfo}->{place}); |
|
216 |
|
marc_add($m_cache,'210','a',$ref->{originInfo}->{place}); |
217 |
|
|
218 |
marc_arr($m,'210','d',$ref->{originInfo}->{dateIssued}); |
marc_add($m_cache,'210','d',$ref->{originInfo}->{dateIssued}); |
219 |
|
|
220 |
$nr++; |
$nr++; |
221 |
print "$nr " if ($nr % 100 == 0); |
print "$nr " if ($nr % 100 == 0); |
222 |
|
|
223 |
|
# dump record |
224 |
|
my $m=$marc->createrecord(); |
225 |
|
foreach my $fld (keys %{$m_cache}) { |
226 |
|
# print "$fld: ",join(" * ",@{$m_cache->{$fld}}),"\n"; |
227 |
|
$marc->addfield({record=>$m, |
228 |
|
field=>$fld, |
229 |
|
value=>\@{$m_cache->{$fld}} |
230 |
|
}); |
231 |
|
} |
232 |
|
|
233 |
$t->purge; # frees the memory |
$t->purge; # frees the memory |
234 |
} |
} |
235 |
|
|
|
__END__ |
|
|
|
|
|
KNJIGA = { |
|
|
610a 'subject' => [ |
|
|
{ |
|
|
'topic' => [ |
|
|
'LIBRARIES-AUTOMATION', |
|
|
'ELECTRONIC DATA PROCESSING-LIBRARY SCIENCE' |
|
|
] |
|
|
} |
|
|
], |
|
|
'name' => [ |
|
|
{ |
|
|
'namePart' => { |
|
|
700b,701a... 'given' => 'Robert M.', |
|
|
700a,701b... 'family' => 'Hayes' |
|
|
}, |
|
|
'type' => 'personal', |
|
|
'role' => { |
|
|
'roleTerm' => { |
|
|
7004,7014... 'content' => 'author', |
|
|
'type' => 'text' |
|
|
} |
|
|
} |
|
|
}, |
|
|
{ |
|
|
'namePart' => { |
|
|
702b 'given' => 'Joseph', |
|
|
702a 'family' => 'Becker' |
|
|
}, |
|
|
'type' => 'personal', |
|
|
'role' => { |
|
|
'roleTerm' => { |
|
|
7024 'content' => 'editor', |
|
|
'type' => 'text' |
|
|
} |
|
|
} |
|
|
}, |
|
|
{ |
|
|
'namePart' => { |
|
|
702b 'given' => 'Joseph', |
|
|
702a 'family' => 'Becker' |
|
|
}, |
|
|
'type' => 'personal', |
|
|
'role' => { |
|
|
'roleTerm' => { |
|
|
7024 'content' => 'illustrator', |
|
|
'type' => 'text' |
|
|
} |
|
|
} |
|
|
} |
|
|
], |
|
|
'note' => 'bibliogr: 645-647; kazalo; ilustr: ilustr.', |
|
|
'identifier' => { |
|
|
010a 'content' => '0-471-36483-5', |
|
|
'type' => 'isbn' |
|
|
}, |
|
|
215a;215d 'physicalDescription' => 'str: 688; pagin: xvi; visina: 24. cm', |
|
|
001 'recordInfo' => { |
|
|
'recordIdentifier' => 'k-7996-8073' |
|
|
}, |
|
|
200a 'titleInfo' => { |
|
|
'title' => 'Handbook of data processing for libraries' |
|
|
}, |
|
|
'typeOfResource' => 'text', |
|
|
675a 'classification' => { |
|
|
'udc' => '=20' |
|
|
}, |
|
|
225a 'relatedItem' => { |
|
|
'titleInfo' => { |
|
|
'title' => 'A WILEY-BECKER & HAYES SERIES BOOK' |
|
|
}, |
|
|
'type' => 'series' |
|
|
}, |
|
|
'originInfo' => { |
|
|
'issuance' => 'monographic', |
|
|
205a 'edition' => '2.', |
|
|
210c/210a 'publisher' => 'MELVILLE PUBLISHING COMPANY /LOS ANGELES, CALIFORNIA/', |
|
|
210d 'dateIssued' => '1974' |
|
|
} |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
CASOPIS = { |
|
|
'identifier' => { |
|
|
011a 'content' => '1041-5173', |
|
|
'type' => 'issn' |
|
|
}, |
|
|
'recordInfo' => { |
|
|
'recordIdentifier' => 'c-1' |
|
|
}, |
|
|
'titleInfo' => { |
|
|
'title' => 'DBMS - CLIENT/SERVER COMPUTING' |
|
|
}, |
|
|
'typeOfResource' => 'text', |
|
|
999a 'relatedItem' => { |
|
|
'titleInfo' => { |
|
|
'partNumber' => 'g. 1990, vol. 137, br. 5' |
|
|
}, |
|
|
'type' => 'series' |
|
|
}, |
|
|
'classification' => { |
|
|
'udc' => '=20' |
|
|
}, |
|
|
'originInfo' => { |
|
|
326a 'frequency' => 'mjeseļæ½no', |
|
|
'issuance' => 'continuing', |
|
|
210a 'place' => 'SAN MATEO, KANADA', |
|
|
210c 'publisher' => 'M&T PUBLISHING INC.' |
|
|
} |
|
|
}; |
|
|
|
|
|
|
|
|
=cut |
|
|
|
|