1 |
#!/usr/bin/perl -w |
#!/usr/bin/perl -w |
2 |
|
|
3 |
use strict; |
use strict; |
4 |
use OpenIsis; |
use Biblio::Isis; |
5 |
use Getopt::Std; |
use Getopt::Std; |
6 |
use Data::Dumper; |
use Data::Dumper; |
7 |
use XML::Simple; |
use XML::Simple; |
|
use Text::Unaccent 1.02; # 1.01 won't compile on my platform, |
|
8 |
use Text::Iconv; |
use Text::Iconv; |
9 |
use Config::IniFiles; |
use Config::IniFiles; |
10 |
use Encode; |
use Encode; |
11 |
#use GDBM_File; |
#use GDBM_File; |
12 |
use Fcntl; # for O_RDWR |
use Fcntl; # for O_RDWR |
13 |
use TDB_File; |
use TDB_File; |
14 |
|
use Carp; |
15 |
|
|
16 |
$|=1; |
$|=1; |
17 |
|
|
18 |
my $config_file = $0; |
my $config_file = $0; |
19 |
$config_file =~ s/\.pl$/.conf/; |
$config_file =~ s/\.pl$/.conf/; |
20 |
|
$config_file = $ARGV[0] if ($ARGV[0] && -f $ARGV[0]); |
21 |
die "FATAL: can't find configuration file '$config_file'" if (! -e $config_file); |
die "FATAL: can't find configuration file '$config_file'" if (! -e $config_file); |
22 |
|
|
23 |
my $config; |
my $config; |
24 |
|
|
25 |
#use index_DBI; # default DBI module for index |
#use index_DBI; # default DBI module for index |
26 |
use index_DBI_cache; # faster DBI module using memory cache |
#use index_DBI_cache; # faster DBI module using memory cache |
27 |
|
use index_DBI_filter; # filter support for indexes |
28 |
my $index; |
my $index; |
29 |
|
|
30 |
my %opts; |
my %opts; |
63 |
'isis' => 'isis', |
'isis' => 'isis', |
64 |
'excel' => 'column', |
'excel' => 'column', |
65 |
'marc' => 'marc', |
'marc' => 'marc', |
66 |
'feed' => 'feed' |
'feed' => 'feed', |
67 |
); |
); |
68 |
|
|
69 |
my $cache; # for cacheing |
my $cache; # for cacheing |
74 |
# if you are tight on memory, turn this off |
# if you are tight on memory, turn this off |
75 |
my $use_lhash_cache = 1; |
my $use_lhash_cache = 1; |
76 |
|
|
77 |
|
my $last_field_name; # cache to prevent repeated fields |
78 |
|
|
79 |
sub data2xml { |
sub data2xml { |
80 |
|
|
81 |
use xmlify; |
use xmlify; |
113 |
$cache->{tags_by_order} = \@sorted_tags; |
$cache->{tags_by_order} = \@sorted_tags; |
114 |
} |
} |
115 |
|
|
116 |
|
if (! @sorted_tags) { |
117 |
|
print STDERR "WARNING: no tags for this type found in import_xml file!\n"; |
118 |
|
} |
119 |
|
|
120 |
# lookup key |
# lookup key |
121 |
my $lookup_key; |
my $lookup_key; |
122 |
|
|
126 |
delete $cache->{swish_exact_data}; |
delete $cache->{swish_exact_data}; |
127 |
delete $cache->{index_data}; |
delete $cache->{index_data}; |
128 |
delete $cache->{index_delimiter}; |
delete $cache->{index_delimiter}; |
129 |
|
delete $cache->{distinct}; |
130 |
my @page_fields; # names of fields |
my @page_fields; # names of fields |
131 |
|
|
132 |
|
|
146 |
} else { |
} else { |
147 |
print STDERR "WARNING: field '$field' doesn't have 'name' attribute!"; |
print STDERR "WARNING: field '$field' doesn't have 'name' attribute!"; |
148 |
} |
} |
149 |
|
|
150 |
if ($field_name) { |
if ($field_name) { |
151 |
return x($field_name); |
$field_name = x($field_name); |
152 |
|
if (! $last_field_name) { |
153 |
|
$last_field_name = $field_name; |
154 |
|
return $last_field_name; |
155 |
|
} elsif ($field_name ne $last_field_name) { |
156 |
|
$last_field_name = $field_name; |
157 |
|
return $last_field_name; |
158 |
|
} |
159 |
|
} |
160 |
|
} |
161 |
|
|
162 |
|
|
163 |
|
# init variables for different types |
164 |
|
sub init_visible_type($) { |
165 |
|
my $type = shift; |
166 |
|
|
167 |
|
# swish, swish_exact, display, index, index_lookup |
168 |
|
# swish and display defaults |
169 |
|
my ($s,$se,$d,$i,$il) = (1,0,1,0,0); |
170 |
|
if (lc($type) eq "display") { |
171 |
|
$s = 0; |
172 |
|
} elsif (lc($type) eq "swish") { |
173 |
|
$d = 0; |
174 |
|
} elsif (lc($type) eq "index") { |
175 |
|
($s,$se,$d,$i) = (0,1,0,1); |
176 |
|
} elsif (lc($type) eq "swish_exact") { |
177 |
|
($s,$se,$d,$i) = (0,1,0,0); |
178 |
|
} elsif (lc($type) =~ /^lookup/) { |
179 |
|
($s,$se,$d,$i,$il) = (0,1,0,0,1); |
180 |
|
} elsif ($type) { |
181 |
|
print STDERR "WARNING: unknown type: $type\n"; |
182 |
} |
} |
183 |
|
return ($s,$se,$d,$i,$il); |
184 |
} |
} |
185 |
|
|
186 |
|
|
187 |
|
# convert |
188 |
|
# |
189 |
|
# <tag> |
190 |
|
# <delimiter>, </delimiter> |
191 |
|
# <value>200a</value> |
192 |
|
# </tag> |
193 |
|
# |
194 |
|
# to |
195 |
|
# |
196 |
|
# <tag delimiter=", ">200a</tag> |
197 |
|
# |
198 |
|
# but without loosing spaces in delimiter (becasue |
199 |
|
# new XML::Simple strips spaces in attribute values |
200 |
|
# as defined in XML specification) |
201 |
|
# |
202 |
|
sub unroll_x($) { |
203 |
|
my $x = shift; |
204 |
|
|
205 |
|
if (defined $x->{value}) { |
206 |
|
my ($v,$d) = ($x->{value}->{content}, $x->{delimiter}->{content}); |
207 |
|
delete $x->{value}; |
208 |
|
delete $x->{delimiter}; |
209 |
|
$x->{content} = $v; |
210 |
|
$x->{delimiter} = $d; |
211 |
|
} |
212 |
|
return $x; |
213 |
|
} |
214 |
|
|
215 |
# begin real work: go field by field |
# begin real work: go field by field |
216 |
foreach my $field (@sorted_tags) { |
foreach my $field (@sorted_tags) { |
217 |
|
|
226 |
|
|
227 |
my ($swish,$display); |
my ($swish,$display); |
228 |
|
|
229 |
my $tag = $type2tag{$type} || die "can't find which tag to use for type $type"; |
my $tag = $cfg->val($database, 'import_xml_tag') || $type2tag{$type} || die "can't find which tag to use for type $type"; |
230 |
|
|
231 |
# is this field page-by-page? |
# is this field page-by-page? |
232 |
my $iterate_by_page = $config->{indexer}->{$field}->{iterate_by_page}; |
my $iterate_by_page = $config->{indexer}->{$field}->{iterate_by_page}; |
235 |
# default line_delimiter if using |
# default line_delimiter if using |
236 |
my $page_line_delimiter = $config->{indexer}->{$field}->{page_line_delimiter} || '<br/>'; |
my $page_line_delimiter = $config->{indexer}->{$field}->{page_line_delimiter} || '<br/>'; |
237 |
$cache->{index_delimiter}->{$field} = $config->{indexer}->{$field}->{index_delimiter}; |
$cache->{index_delimiter}->{$field} = $config->{indexer}->{$field}->{index_delimiter}; |
238 |
|
my $distinct = $config->{indexer}->{$field}->{distinct}; |
239 |
|
if ($distinct && !$iterate_by_page) { |
240 |
|
warn "WARNING: distinct is currently not supported without iterate_by_page!\n"; |
241 |
|
$distinct = 0; |
242 |
|
} |
243 |
|
|
244 |
|
my $format_name = $config->{indexer}->{$field}->{format_name}; |
245 |
|
my $format_delimiter = $config->{indexer}->{$field}->{format_delimiter}; |
246 |
|
if ($format_name && $format_delimiter) { |
247 |
|
$cache->{format}->{$field}->{format_name} = $format_name; |
248 |
|
$cache->{format}->{$field}->{format_delimiter} = $format_delimiter; |
249 |
|
} |
250 |
|
|
251 |
foreach my $x (@{$config->{indexer}->{$field}->{$tag}}) { |
foreach my $x (@{$config->{indexer}->{$field}->{$tag}}) { |
252 |
|
|
253 |
|
$x = unroll_x($x); |
254 |
|
|
255 |
my $format = x($x->{content}); |
my $format = x($x->{content}); |
256 |
my $delimiter = x($x->{delimiter}) || ' '; |
my $delimiter = x($x->{delimiter}) || ' '; |
257 |
|
|
258 |
my $repeat_off = 0; # init repeatable offset |
my $repeat_off = 0; # init repeatable offset |
259 |
|
|
260 |
# swish, swish_exact, display, index, index_lookup |
my ($s,$se,$d,$i,$il) = init_visible_type($x->{type}); |
|
# swish and display defaults |
|
|
my ($s,$se,$d,$i,$il) = (1,0,1,0,0); |
|
|
$s = 0 if (lc($x->{type}) eq "display"); |
|
|
$d = 0 if (lc($x->{type}) eq "swish"); |
|
|
($s,$se,$d,$i) = (0,1,0,1) if (lc($x->{type}) eq "index"); |
|
|
($s,$se,$d,$i) = (0,1,0,0) if (lc($x->{type}) eq "swish_exact"); |
|
|
($s,$se,$d,$i,$il) = (0,1,0,0,1) if (lc($x->{type}) =~ /^lookup/); |
|
261 |
|
|
262 |
# what will separate last line from this one? |
# what will separate last line from this one? |
263 |
if ($display_data && $x->{append}) { |
if ($display_data && $x->{append}) { |
264 |
$line_delimiter = ' '; |
$line_delimiter = $delimiter; |
265 |
} elsif ($display_data) { |
} elsif ($display_data) { |
266 |
$line_delimiter = '<br/>'; |
$line_delimiter = '<br/>'; |
267 |
} |
} |
269 |
# init vars so that we go into while... |
# init vars so that we go into while... |
270 |
($swish,$display) = (1,1); |
($swish,$display) = (1,1); |
271 |
|
|
272 |
# placeholder for all repeatable entries for index |
sub mkformat($$) { |
|
|
|
|
sub mkformat { |
|
273 |
my $x = shift || die "mkformat needs tag reference"; |
my $x = shift || die "mkformat needs tag reference"; |
274 |
my $data = shift || return; |
my $data = shift || return; |
275 |
my $format_name = x($x->{format_name}) || return $data; |
my $format_name = x($x->{format_name}) || return $data; |
287 |
if (($#data+1) == $nr) { |
if (($#data+1) == $nr) { |
288 |
return sprintf($fmt,@data); |
return sprintf($fmt,@data); |
289 |
} else { |
} else { |
290 |
print STDERR "mkformat: [$data] can't be split on [$format_delimiter] to $nr fields!\n"; |
#print STDERR "mkformat: [$data] can't be split on [$format_delimiter] to $nr fields!\n"; |
291 |
return $data; |
return $data; |
292 |
} |
} |
293 |
} else { |
} else { |
316 |
$display = $new_display; |
$display = $new_display; |
317 |
$cache->{lhash}->{$display} = $new_display; |
$cache->{lhash}->{$display} = $new_display; |
318 |
} else { |
} else { |
319 |
print STDERR "WARNING: lookup for '$display' didn't find anything.\n"; |
# print STDERR "WARNING: lookup for '$display' didn't find anything.\n"; |
320 |
$display = ""; |
$display = ""; |
321 |
$cache->{lhash}->{$display} = $null; |
$cache->{lhash}->{$display} = $null; |
322 |
} |
} |
337 |
} |
} |
338 |
# type="swish" ; field for swish |
# type="swish" ; field for swish |
339 |
if ($swish) { |
if ($swish) { |
340 |
|
my $tmp = $swish; |
341 |
if ($filter && ($s || $se)) { |
if ($filter && ($s || $se)) { |
342 |
no strict 'refs'; |
no strict 'refs'; |
343 |
my $tmp = join(" ",&$filter($swish)) if ($s || $se); |
$tmp = join(" ",&$filter($tmp)) if ($s || $se); |
|
$swish_data .= $tmp if ($s); |
|
|
$swish_exact_data .= $tmp if ($se); |
|
|
|
|
|
} else { |
|
|
$swish_data .= $swish if ($s); |
|
|
$swish_exact_data .= $swish if ($se); |
|
344 |
} |
} |
345 |
|
|
346 |
|
$swish_data .= $tmp if ($s && $tmp); |
347 |
|
$swish_exact_data .= "xxbxx $tmp xxexx " if ($tmp && $tmp ne "" && $se); |
348 |
} |
} |
349 |
|
|
350 |
# type="display" ; field for display |
# type="display" ; field for display |
351 |
if ($d && $display) { |
if ($d && $display) { |
352 |
|
my $ldel = $delimiter; |
353 |
if ($line_delimiter && $display_data) { |
if ($line_delimiter && $display_data) { |
354 |
$display_data .= $line_delimiter; |
$ldel = $line_delimiter; |
355 |
} |
} |
356 |
if ($filter) { |
if ($filter) { |
357 |
no strict 'refs'; |
no strict 'refs'; |
358 |
if ($display_data) { |
my @arr; |
359 |
$display_data .= $delimiter.join($delimiter,mkformat($x,&$filter($display))); |
foreach my $tmp (&$filter($display)) { |
360 |
} else { |
my $tmp2 = mkformat($x,$tmp); |
361 |
$display_data = join($delimiter,mkformat($x,&$filter($display))); |
push @arr,$tmp2 if ($tmp2); |
362 |
} |
} |
363 |
|
$display_data .= $ldel if ($display_data && @arr); |
364 |
|
$display_data .= join($delimiter,@arr); |
365 |
} else { |
} else { |
366 |
if ($display_data) { |
$display_data .= $ldel if ($display_data); |
367 |
$display_data .= $delimiter.mkformat($x,$display); |
my $tmp = mkformat($x,$display); |
368 |
} else { |
$display_data .= $tmp if ($tmp); |
|
$display_data = mkformat($x,$display); |
|
|
} |
|
369 |
} |
} |
370 |
} |
} |
371 |
|
|
377 |
no strict 'refs'; |
no strict 'refs'; |
378 |
$idisplay = &$filter($idisplay); |
$idisplay = &$filter($idisplay); |
379 |
} |
} |
380 |
push @index_data, $idisplay if (! $iterate_by_page); |
push @index_data, $idisplay if ($idisplay && !$iterate_by_page); |
381 |
} |
} |
382 |
|
|
383 |
# store fields in lookup |
# store fields in lookup |
386 |
if ($lookup_key) { |
if ($lookup_key) { |
387 |
print STDERR "WARNING: try to redefine lookup_key (keys shouldn't be repeatable fields!)"; |
print STDERR "WARNING: try to redefine lookup_key (keys shouldn't be repeatable fields!)"; |
388 |
} else { |
} else { |
389 |
$lookup_key = $display; |
if ($filter) { |
390 |
|
no strict 'refs'; |
391 |
|
$lookup_key = &$filter($display); |
392 |
|
} else { |
393 |
|
$lookup_key = $display; |
394 |
|
} |
395 |
} |
} |
396 |
} elsif (lc($x->{type}) eq "lookup_val") { |
} elsif (lc($x->{type}) eq "lookup_val") { |
397 |
if ($lookup_key) { |
if ($lookup_key) { |
398 |
$lhash{$lookup_key} = $display; |
if ($filter) { |
399 |
|
no strict 'refs'; |
400 |
|
$lhash{$lookup_key} = &$filter($display); |
401 |
|
} else { |
402 |
|
$lhash{$lookup_key} = $display; |
403 |
|
} |
404 |
} else { |
} else { |
405 |
print STDERR "WARNING: no lookup_key defined for '$display'?"; |
print STDERR "WARNING: no lookup_key defined for '$display'?"; |
406 |
} |
} |
418 |
$ldel = " " if ($append); |
$ldel = " " if ($append); |
419 |
#print STDERR "line delimiter: ",Dumper($ldel) if ($ldel); |
#print STDERR "line delimiter: ",Dumper($ldel) if ($ldel); |
420 |
if (! $cache->{$what}->{$field}->[$page]) { |
if (! $cache->{$what}->{$field}->[$page]) { |
421 |
$cache->{$what}->{$field}->[$page] = $data; |
push @{$cache->{$what}->{$field}->[$page]}, { |
422 |
} else { |
data => $data, |
423 |
$cache->{$what}->{$field}->[$page] .= $ldel.$data; |
delimiter => $ldel, |
424 |
|
}; |
425 |
} |
} |
426 |
} |
} |
427 |
|
|
446 |
@index_data = @{$cache->{index_data}->{$field}->[$page]}; |
@index_data = @{$cache->{index_data}->{$field}->[$page]}; |
447 |
} |
} |
448 |
if ($x->{append}) { |
if ($x->{append}) { |
449 |
$index_data[$#index_data] .= $idisplay; |
if (@index_data) { |
450 |
|
$index_data[$#index_data] .= $idisplay; |
451 |
|
} else { |
452 |
|
push @index_data, $idisplay; |
453 |
|
} |
454 |
} else { |
} else { |
455 |
push @index_data, $idisplay; |
push @index_data, $idisplay; |
456 |
} |
} |
477 |
# now try to parse variables from configuration file |
# now try to parse variables from configuration file |
478 |
foreach my $x (@{$config->{indexer}->{$field}->{'config'}}) { |
foreach my $x (@{$config->{indexer}->{$field}->{'config'}}) { |
479 |
|
|
480 |
|
$x = unroll_x($x); |
481 |
|
|
482 |
my $delimiter = x($x->{delimiter}) || ' '; |
my $delimiter = x($x->{delimiter}) || ' '; |
483 |
my $val = $cfg->val($database, x($x->{content})); |
my $val = $cfg->val($database, x($x->{content})); |
484 |
|
|
485 |
my ($s,$d,$i) = (1,1,0); # swish, display default |
# FIXME index_lookup is not supported! |
486 |
$s = 0 if (lc($x->{type}) eq "display"); |
my ($s,$se,$d,$i,$il) = init_visible_type($x->{type}); |
|
$d = 0 if (lc($x->{type}) eq "swish"); |
|
|
# no support for swish exact in config. |
|
|
# IMHO, it's useless |
|
|
($s,$d,$i) = (0,0,1) if (lc($x->{type}) eq "index"); |
|
487 |
|
|
488 |
if ($val) { |
if ($val) { |
489 |
$display_data .= $delimiter.$val if ($d); |
$display_data .= $delimiter.$val if ($d); |
490 |
$swish_data .= $val if ($s); |
$swish_data .= " ".$val if ($s); |
491 |
$index->insert($field, $val, $path) if ($i); |
$index->insert($field, $val, $path) if ($i); |
492 |
} |
} |
493 |
|
|
496 |
# on first page!!! |
# on first page!!! |
497 |
my $page = 0; |
my $page = 0; |
498 |
if ($display_data) { |
if ($display_data) { |
499 |
$cache->{display_data}->{$field}->[$page] = $display_data; |
push @{$cache->{display_data}->{$field}->[$page]}, { data => $display_data }; |
500 |
$display_data = ""; |
$display_data = ""; |
501 |
} |
} |
502 |
if ($swish_data) { |
if ($swish_data) { |
503 |
$cache->{swish_data}->{$field}->[$page] = $swish_data; |
push @{$cache->{swish_data}->{$field}->[$page]}, { data => $swish_data }; |
504 |
$swish_data = ""; |
$swish_data = ""; |
505 |
} |
} |
506 |
if ($swish_exact_data) { |
if ($swish_exact_data) { |
507 |
$cache->{swish_exact_data}->{$field}->[$page] = $swish_exact_data; |
push @{$cache->{swish_exact_data}->{$field}->[$page]}, { data => $swish_exact_data }; |
508 |
$swish_exact_data = ""; |
$swish_exact_data = ""; |
509 |
} |
} |
510 |
} |
} |
515 |
my $nr_pages = $page_max{$field} || next; |
my $nr_pages = $page_max{$field} || next; |
516 |
#print STDERR "field '$field' iterate over ",($nr_pages || 0)," pages...\n"; |
#print STDERR "field '$field' iterate over ",($nr_pages || 0)," pages...\n"; |
517 |
#print STDERR Dumper($cache->{display_data}); |
#print STDERR Dumper($cache->{display_data}); |
518 |
|
my $seen; # used for distinct |
519 |
for (my $page=0; $page <= $nr_pages; $page++) { |
for (my $page=0; $page <= $nr_pages; $page++) { |
520 |
|
my $display_data; |
521 |
|
my $delimiter = ''; |
522 |
|
foreach my $element (@{ $cache->{display_data}->{$field}->[$page] }) { |
523 |
|
my $data = $element->{data}; |
524 |
|
die "BUG! no data in element?" unless ($data); |
525 |
|
|
526 |
|
if ($distinct) { |
527 |
|
next if ($cache->{distinct}->{$field}->{ $data }); |
528 |
|
$cache->{distinct}->{$field}->{ $data } = 1; |
529 |
|
} |
530 |
|
|
531 |
|
if ($cache->{format}->{$field}) { |
532 |
|
my $tmp = mkformat($cache->{format}->{$field},$data); |
533 |
|
$display_data .= $delimiter . $tmp if ($tmp); |
534 |
|
} else { |
535 |
|
$display_data .= $delimiter . $data; |
536 |
|
} |
537 |
|
$delimiter = $element->{delimiter} if ($element->{delimiter}); |
538 |
|
} |
539 |
|
|
|
my $display_data = $cache->{display_data}->{$field}->[$page]; |
|
540 |
if ($display_data) { # default |
if ($display_data) { # default |
541 |
if ($field eq "headline") { |
if ($field eq "headline") { |
542 |
$xml .= xmlify("headline", $display_data); |
$xml .= xmlify("headline", $display_data); |
548 |
} |
} |
549 |
} |
} |
550 |
|
|
551 |
my $swish_data = $cache->{swish_data}->{$field}->[$page]; |
my $swish_data = join(" ",map { $_->{data} } @{ $cache->{swish_data}->{$field}->[$page] }); |
552 |
if ($swish_data) { |
if ($swish_data) { |
553 |
# remove extra spaces |
# remove extra spaces |
554 |
$swish_data =~ s/ +/ /g; |
$swish_data =~ s/ +/ /g; |
555 |
$swish_data =~ s/ +$//g; |
$swish_data =~ s/ +$//g; |
556 |
|
|
557 |
$xml .= xmlify($field."_swish", unac_string($codepage,$swish_data)); |
$xml .= xmlify($field."_swish", my_unac_string($codepage,$swish_data)); |
558 |
} |
} |
559 |
|
|
560 |
my $swish_exact_data = $cache->{swish_exact_data}->{$field}->[$page]; |
my $swish_exact_data = join(" ", map { $_->{data} } @{ $cache->{swish_exact_data}->{$field}->[$page] }); |
561 |
if ($swish_exact_data) { |
if ($swish_exact_data) { |
562 |
$swish_exact_data =~ s/ +/ /g; |
$swish_exact_data =~ s/ +/ /g; |
563 |
$swish_exact_data =~ s/ +$//g; |
$swish_exact_data =~ s/ +$//g; |
564 |
|
|
565 |
# add delimiters before and after word. |
# add delimiters before and after word. |
566 |
# That is required to produce exact match |
# That is required to produce exact match |
567 |
$xml .= xmlify($field."_swish_exact", unac_string($codepage,'xxbxx '.$swish_exact_data.' xxexx')); |
$xml .= xmlify($field."_swish_exact", my_unac_string($codepage,$swish_exact_data)); |
568 |
} |
} |
569 |
|
|
570 |
my $idel = $cache->{index_delimiter}->{$field}; |
my $idel = $cache->{index_delimiter}->{$field}; |
597 |
$swish_data =~ s/ +/ /g; |
$swish_data =~ s/ +/ /g; |
598 |
$swish_data =~ s/ +$//g; |
$swish_data =~ s/ +$//g; |
599 |
|
|
600 |
$xml .= xmlify($field."_swish", unac_string($codepage,$swish_data)); |
$xml .= xmlify($field."_swish", my_unac_string($codepage,$swish_data)); |
601 |
} |
} |
602 |
|
|
603 |
if ($swish_exact_data) { |
if ($swish_exact_data) { |
606 |
|
|
607 |
# add delimiters before and after word. |
# add delimiters before and after word. |
608 |
# That is required to produce exact match |
# That is required to produce exact match |
609 |
$xml .= xmlify($field."_swish_exact", unac_string($codepage,'xxbxx '.$swish_exact_data.' xxexx')); |
$xml .= xmlify($field."_swish_exact", my_unac_string($codepage,$swish_exact_data)); |
610 |
} |
} |
611 |
} |
} |
612 |
} |
} |
643 |
|
|
644 |
my $show_progress = $cfg_global->val('global', 'show_progress'); |
my $show_progress = $cfg_global->val('global', 'show_progress'); |
645 |
|
|
646 |
my $unac_filter = $cfg_global->val('global', 'unac_filter'); |
my $my_unac_filter = $cfg_global->val('global', 'my_unac_filter'); |
647 |
if ($unac_filter) { |
if ($my_unac_filter) { |
648 |
require $unac_filter; |
print STDERR "using $my_unac_filter to filter characters for search\n"; |
649 |
|
require $my_unac_filter; |
650 |
|
} else { |
651 |
|
print STDERR "### fallback to default my_unac_string!\n"; |
652 |
|
eval q{ |
653 |
|
sub main::my_unac_string($$) { |
654 |
|
my ($charset, $string) = (@_); |
655 |
|
return $string; |
656 |
|
} |
657 |
|
}; |
658 |
} |
} |
659 |
|
|
660 |
foreach my $database ($cfg->Sections) { |
foreach my $database ($cfg->Sections) { |
661 |
|
|
662 |
|
# save database name in global variable path for later |
663 |
|
# (need for index filter creation) |
664 |
|
$path = $database; |
665 |
|
|
666 |
my $type = lc($cfg -> val($database, 'type')) || die "$database doesn't have 'type' defined"; |
my $type = lc($cfg -> val($database, 'type')) || die "$database doesn't have 'type' defined"; |
667 |
my $add_xml = $cfg -> val($database, 'xml'); # optional |
my $add_xml = $cfg -> val($database, 'xml'); # optional |
668 |
|
|
670 |
my $lookup_file = $cfg -> val($database, 'lookup_newfile'); # optional |
my $lookup_file = $cfg -> val($database, 'lookup_newfile'); # optional |
671 |
if ($lookup_file) { |
if ($lookup_file) { |
672 |
#tie %lhash, 'GDBM_File', $lookup_file, &GDBM_NEWDB, 0644; |
#tie %lhash, 'GDBM_File', $lookup_file, &GDBM_NEWDB, 0644; |
673 |
|
if (! -e $lookup_file) { |
674 |
|
open(LOOKUP, "> $lookup_file") || die "can't create $lookup_file': $!"; |
675 |
|
close(LOOKUP); |
676 |
|
} |
677 |
tie %lhash, 'TDB_File', $lookup_file, TDB_CLEAR_IF_FIRST, O_RDWR, 0644; |
tie %lhash, 'TDB_File', $lookup_file, TDB_CLEAR_IF_FIRST, O_RDWR, 0644; |
678 |
print STDERR "creating lookup file '$lookup_file'\n"; |
print STDERR "creating lookup file '$lookup_file'\n"; |
679 |
|
# delete memory cache for lookup file |
680 |
|
delete $cache->{lhash}; |
681 |
} |
} |
682 |
|
|
683 |
# open existing lookup file |
# open existing lookup file |
688 |
print STDERR "opening lookup file '$lookup_file'\n"; |
print STDERR "opening lookup file '$lookup_file'\n"; |
689 |
} |
} |
690 |
|
|
691 |
print STDERR "reading ./import_xml/$type.xml\n"; |
my $import_xml_type = $cfg->val($database, 'import_xml_file') || $type; |
692 |
|
my $import_xml_file = "./import_xml/$import_xml_type.xml"; |
693 |
|
|
694 |
|
if (! -r $import_xml_file) { |
695 |
|
print STDERR "ERROR: file $import_xml_file not readable skipping!\n"; |
696 |
|
next; |
697 |
|
} |
698 |
|
|
699 |
|
print STDERR "reading $import_xml_file\n"; |
700 |
|
|
701 |
# extract just type basic |
# extract just type basic |
702 |
my $type_base = $type; |
my $type_base = $type; |
703 |
$type_base =~ s/_.+$//g; |
$type_base =~ s/_.+$//g; |
704 |
|
|
705 |
$config=XMLin("./import_xml/$type.xml", forcearray => [ $type2tag{$type_base}, 'config', 'format' ], forcecontent => 1); |
my $tag = $cfg->val($database, 'import_xml_tag') || $type2tag{$type_base} || die "can't find which tag to use for type $type"; |
706 |
|
$config=XMLin($import_xml_file, ForceArray => [ $tag, 'config', 'format' ], ForceContent => 1 ); |
707 |
|
|
708 |
|
# helper for progress bar |
709 |
|
sub fmt_time { |
710 |
|
my $t = shift || 0; |
711 |
|
my $out = ""; |
712 |
|
|
713 |
|
my ($ss,$mm,$hh) = gmtime($t); |
714 |
|
$out .= "${hh}h" if ($hh); |
715 |
|
$out .= sprintf("%02d:%02d", $mm,$ss); |
716 |
|
$out .= " " if ($hh == 0); |
717 |
|
return $out; |
718 |
|
} |
719 |
|
|
720 |
# output current progress indicator |
# output current progress indicator |
721 |
my $last_p = 0; |
my $last_p = 0; |
722 |
|
my $start_t = time(); |
723 |
sub progress { |
sub progress { |
724 |
return if (! $show_progress); |
return if (! $show_progress); |
725 |
my $current = shift; |
my $current = shift; |
726 |
my $total = shift || 1; |
my $total = shift || 1; |
727 |
my $p = int($current * 100 / $total); |
my $p = int($current * 100 / $total); |
728 |
if ($p != $last_p) { |
if ($p < $last_p || $current == 1) { |
729 |
printf STDERR ("%5d / %5d [%-51s] %-2d %% \r",$current,$total,"=" x ($p/2).">", $p ); |
$start_t = time(); |
730 |
|
$last_p = 0; |
731 |
|
} elsif ($p != $last_p) { |
732 |
|
my $rate = ($current / (time() - $start_t || 1)); |
733 |
|
my $eta = ($total-$current) / ($rate || 1); |
734 |
|
printf STDERR ("%5d [%-38s] %-5d %0.1f/s %s\r",$current,"=" x ($p/3)."$p%>", $total, $rate, fmt_time($eta)); |
735 |
$last_p = $p; |
$last_p = $p; |
736 |
} |
} |
737 |
} |
} |
738 |
|
|
739 |
my $fake_dir = 1; |
my $fake_dir = 1; |
740 |
|
my $fake_pos = 0; |
741 |
|
my $last_fake_t = time(); |
742 |
sub fakeprogress { |
sub fakeprogress { |
743 |
return if (! $show_progress); |
return if (! $show_progress); |
744 |
my $current = shift @_; |
my $current = shift @_; |
745 |
|
|
746 |
my @ind = ('-','\\','|','/','-','\\','|','/', '-'); |
my @ind = ('-','\\','|','/','-','\\','|','/'); |
747 |
|
|
748 |
$last_p += $fake_dir; |
if ($current < $fake_pos) { |
749 |
$fake_dir = -$fake_dir if ($last_p > 1000 || $last_p < 0); |
$start_t = time(); |
750 |
if ($last_p % 10 == 0) { |
$last_fake_t = 0; |
751 |
printf STDERR ("%5d / %5s [%-51s]\r",$current,"?"," " x ($last_p/20).$ind[($last_p/20) % $#ind]); |
$fake_dir = 1; |
752 |
|
$fake_pos = 0; |
753 |
|
} |
754 |
|
|
755 |
|
if (time()-$last_fake_t >= 1) { |
756 |
|
$last_fake_t = time(); |
757 |
|
$fake_pos += $fake_dir; |
758 |
|
$fake_dir = -$fake_dir if ($fake_pos > 38); |
759 |
|
} |
760 |
|
|
761 |
|
if ($current % 10 == 0) { |
762 |
|
my $rate = ($current / (time() - $start_t || 1)); |
763 |
|
printf STDERR ("%5d [%-38s] %0.1f/s\r",$current, " " x $fake_pos .$ind[($current / 10) % 8], $rate); |
764 |
} |
} |
765 |
} |
} |
766 |
|
|
767 |
# now read database |
# now read database |
|
print STDERR "using: $type...\n"; |
|
768 |
|
|
769 |
# erase cache for tags by order in this database |
# erase cache for tags by order in this database |
770 |
delete $cache->{tags_by_order}; |
delete $cache->{tags_by_order}; |
774 |
my $isis_db = $cfg -> val($database, 'isis_db') || die "$database doesn't have 'isis_db' defined!"; |
my $isis_db = $cfg -> val($database, 'isis_db') || die "$database doesn't have 'isis_db' defined!"; |
775 |
|
|
776 |
$import2cp = Text::Iconv->new($config->{isis_codepage},$codepage); |
$import2cp = Text::Iconv->new($config->{isis_codepage},$codepage); |
777 |
my $db = OpenIsis::open( $isis_db ); |
my $db = new Biblio::Isis( isisdb => $isis_db ); |
|
|
|
|
# check if .txt database for OpenIsis is zero length, |
|
|
# if so, erase it and re-open database |
|
|
sub check_txt_db { |
|
|
my $isis_db = shift || die "need isis database name"; |
|
|
my $reopen = 0; |
|
|
|
|
|
if (-e $isis_db.".TXT") { |
|
|
print STDERR "WARNING: removing $isis_db.TXT OpenIsis database...\n"; |
|
|
unlink $isis_db.".TXT" || warn "FATAL: unlink error on '$isis_db.TXT': $!"; |
|
|
$reopen++; |
|
|
} |
|
|
if (-e $isis_db.".PTR") { |
|
|
print STDERR "WARNING: removing $isis_db.PTR OpenIsis database...\n"; |
|
|
unlink $isis_db.".PTR" || warn "FATAL: unlink error on '$isis_db.PTR': $!"; |
|
|
$reopen++; |
|
|
} |
|
|
return OpenIsis::open( $isis_db ) if ($reopen); |
|
|
} |
|
|
|
|
|
# EOF error |
|
|
if ($db == -1) { |
|
|
$db = check_txt_db($isis_db); |
|
|
if ($db == -1) { |
|
|
print STDERR "FATAL: OpenIsis can't open zero size file $isis_db\n"; |
|
|
next; |
|
|
} |
|
|
} |
|
778 |
|
|
779 |
# OpenIsis::ERR_BADF |
if (! $db) { |
780 |
if ($db == -4) { |
print STDERR "FATAL: can't read ISIS database: $isis_db, skipping...\n"; |
|
print STDERR "FATAL: OpenIsis can't find file $isis_db\n"; |
|
|
next; |
|
|
# OpenIsis::ERR_IO |
|
|
} elsif ($db == -5) { |
|
|
print STDERR "FATAL: OpenIsis can't access file $isis_db\n"; |
|
|
next; |
|
|
} elsif ($db < 0) { |
|
|
print STDERR "FATAL: OpenIsis unknown error $db with file $isis_db\n"; |
|
781 |
next; |
next; |
782 |
} |
} |
783 |
|
|
784 |
my $max_rowid = OpenIsis::maxRowid( $db ); |
my $max_rowid = $db->count if ($db); |
|
|
|
|
# if 0 records, try to rease isis .txt database |
|
|
if ($max_rowid == 0) { |
|
|
# force removal of database |
|
|
$db = check_txt_db($isis_db); |
|
|
$max_rowid = OpenIsis::maxRowid( $db ); |
|
|
} |
|
785 |
|
|
786 |
print STDERR "Reading database: $isis_db [$max_rowid rows]\n"; |
print STDERR "Reading database: $isis_db [$max_rowid rows]\n"; |
787 |
|
|
|
my $path = $database; |
|
|
|
|
788 |
for (my $row_id = 1; $row_id <= $max_rowid; $row_id++ ) { |
for (my $row_id = 1; $row_id <= $max_rowid; $row_id++ ) { |
789 |
my $row = OpenIsis::read( $db, $row_id ); |
my $row = $db->to_hash( $row_id ); |
790 |
if ($row && $row->{mfn}) { |
if ($row) { |
791 |
|
|
792 |
|
$row->{mfn} = $row_id; |
793 |
|
$row->{record} = $db->{record}; |
794 |
|
|
795 |
progress($row->{mfn}, $max_rowid); |
progress($row->{mfn}, $max_rowid); |
796 |
|
|
797 |
my $swishpath = $path."#".int($row->{mfn}); |
my $swishpath = $path."#".int($row->{mfn}); |
805 |
} |
} |
806 |
} |
} |
807 |
} |
} |
|
# for this to work with current version of OpenIsis (0.9.0) |
|
|
# you might need my patch from |
|
|
# http://www.rot13.org/~dpavlin/projects/openisis-0.9.0-perl_close.diff |
|
|
OpenIsis::close($db); |
|
808 |
print STDERR "\n"; |
print STDERR "\n"; |
809 |
|
|
810 |
} elsif ($type_base eq "excel") { |
} elsif ($type_base eq "excel") { |
811 |
use Spreadsheet::ParseExcel; |
require Spreadsheet::ParseExcel; |
812 |
use Spreadsheet::ParseExcel::Utility qw(int2col); |
require Spreadsheet::ParseExcel::Utility; |
813 |
|
import Spreadsheet::ParseExcel::Utility qw(int2col); |
814 |
|
|
815 |
$import2cp = Text::Iconv->new($config->{excel_codepage},$codepage); |
$import2cp = Text::Iconv->new($config->{excel_codepage},$codepage); |
816 |
my $excel_file = $cfg -> val($database, 'excel_file') || die "$database doesn't have 'excel_file' defined!"; |
my $excel_file = $cfg -> val($database, 'excel_file') || die "$database doesn't have 'excel_file' defined!"; |
817 |
|
|
818 |
my $sheet = x($config->{sheet}) || die "no sheet in $type.xml"; |
my $sheet = x($config->{sheet}) || die "no sheet in $type.xml"; |
819 |
my $start_row = x($config->{start_row}) - 1 || die "no start_row in $type.xml"; |
my $start_row = x($config->{start_row}) || die "no start_row in $type.xml"; |
820 |
|
$start_row--; |
821 |
|
|
822 |
my $oBook = Spreadsheet::ParseExcel::Workbook->Parse($excel_file) || die "can't open Excel file '$excel_file'"; |
my $oBook = Spreadsheet::ParseExcel::Workbook->Parse($excel_file) || die "can't open Excel file '$excel_file'"; |
823 |
|
|
839 |
for(my $iC = $oWorksheet->{MinCol} ; defined $oWorksheet->{MaxCol} && $iC <= $oWorksheet->{MaxCol} ; $iC++) { |
for(my $iC = $oWorksheet->{MinCol} ; defined $oWorksheet->{MaxCol} && $iC <= $oWorksheet->{MaxCol} ; $iC++) { |
840 |
my $cell = $oWorksheet->{Cells}[$iR][$iC]; |
my $cell = $oWorksheet->{Cells}[$iR][$iC]; |
841 |
if ($cell) { |
if ($cell) { |
842 |
$row->{int2col($iC)} = $cell->Value; |
# this conversion is a cludge. |
843 |
|
# Files from Excell could have |
844 |
|
# characters which don't fit into |
845 |
|
# destination encoding. |
846 |
|
$row->{int2col($iC)} = $utf2cp->convert($cell->Value) || $cell->Value; |
847 |
} |
} |
848 |
} |
} |
849 |
|
|
867 |
print "Document-Type: XML\n\n$xml\n"; |
print "Document-Type: XML\n\n$xml\n"; |
868 |
} |
} |
869 |
} |
} |
870 |
|
|
871 |
|
print STDERR "\n"; |
872 |
|
|
873 |
} elsif ($type_base eq "marc") { |
} elsif ($type_base eq "marc") { |
874 |
|
|
875 |
use MARC; |
require MARC::File::USMARC; |
876 |
|
|
877 |
$import2cp = Text::Iconv->new($config->{marc_codepage},$codepage); |
$import2cp = Text::Iconv->new($config->{marc_codepage},$codepage); |
878 |
my $marc_file = $cfg -> val($database, 'marc_file') || die "$database doesn't have 'marc_file' defined!"; |
my $marc_file = $cfg -> val($database, 'marc_file') || die "$database doesn't have 'marc_file' defined!"; |
879 |
|
|
880 |
# optional argument is format |
# optional argument is format |
881 |
my $format = x($config->{format}) || 'usmarc'; |
warn "marc_format is no longer used!" if ($config->{marc_format}); |
|
|
|
882 |
print STDERR "Reading MARC file '$marc_file'\n"; |
print STDERR "Reading MARC file '$marc_file'\n"; |
883 |
|
|
884 |
my $marc = new MARC; |
my $marc = MARC::File::USMARC->in( $marc_file ); |
885 |
my $nr = $marc->openmarc({ |
|
886 |
file=>$marc_file, format=>$format |
if (! $marc) { |
887 |
}) || die "Can't open MARC file '$marc_file'"; |
print STDERR "FATAL: can't read MARC file: $marc_file, skipping...\n"; |
888 |
|
next; |
889 |
|
} |
890 |
|
|
891 |
|
# count records in MARC file |
892 |
|
sub marc_count { |
893 |
|
my $filename = shift || die; |
894 |
|
my $file = MARC::File::USMARC->in($filename) || return; |
895 |
|
my $count = 0; |
896 |
|
while ($file->skip()) { |
897 |
|
$count++; |
898 |
|
} |
899 |
|
return $count; |
900 |
|
} |
901 |
|
|
902 |
my $i=0; # record nr. |
my $count = marc_count($marc_file) || warn "no records in '$marc_file'?"; |
903 |
|
|
904 |
my $rec; |
my $i = 1; |
905 |
|
|
906 |
while ($marc->nextmarc(1)) { |
while( my $rec = $marc->next() ) { |
907 |
|
|
908 |
# XXX |
progress($i,$count); |
|
fakeprogress($i++); |
|
909 |
|
|
910 |
my $swishpath = $database."#".$i; |
my $swishpath = $database."#".$i; |
911 |
|
|
912 |
if (my $xml = data2xml($type_base,$marc,$add_xml,$cfg,$database)) { |
if (my $xml = data2xml($type_base,$rec,$add_xml,$cfg,$database)) { |
913 |
$xml = $cp2utf->convert($xml); |
$xml = $cp2utf->convert($xml); |
914 |
use bytes; # as opposed to chars |
use bytes; # as opposed to chars |
915 |
print "Path-Name: $swishpath\n"; |
print "Path-Name: $swishpath\n"; |
916 |
print "Content-Length: ".(length($xml)+1)."\n"; |
print "Content-Length: ".(length($xml)+1)."\n"; |
917 |
print "Document-Type: XML\n\n$xml\n"; |
print "Document-Type: XML\n\n$xml\n"; |
918 |
} |
} |
919 |
|
|
920 |
|
$i++; |
921 |
} |
} |
922 |
|
|
923 |
|
print STDERR "\n"; |
924 |
|
|
925 |
} elsif ($type_base eq "feed") { |
} elsif ($type_base eq "feed") { |
926 |
|
|
927 |
$import2cp = Text::Iconv->new($config->{feed_codepage},$codepage); |
$import2cp = Text::Iconv->new($config->{feed_codepage},$codepage); |
962 |
} |
} |
963 |
# close lookup |
# close lookup |
964 |
untie %lhash if (%lhash); |
untie %lhash if (%lhash); |
965 |
|
|
966 |
|
} elsif ($type_base eq "dbf") { |
967 |
|
|
968 |
|
my $dbf_file = $cfg -> val($database, 'dbf_file') || die "$database doesn't have 'dbf_file' defined!"; |
969 |
|
my $dbf_codepage = $cfg -> val($database, 'dbf_codepage') || die "$database doesn't have 'dbf_codepage' defined!"; |
970 |
|
my $dbf_mapping = $cfg -> val($database, 'dbf_mapping') || die "$database doesn't have 'dbf_mapping' defined!"; |
971 |
|
|
972 |
|
$import2cp = Text::Iconv->new($dbf_codepage,$codepage); |
973 |
|
require XBase; |
974 |
|
my $db = new XBase $dbf_file; |
975 |
|
|
976 |
|
if (! $db) { |
977 |
|
print STDERR "ERROR: can't read DBF database: $dbf_file, skipping...\n"; |
978 |
|
next; |
979 |
|
} |
980 |
|
|
981 |
|
my $max_rowid = $db->last_record; |
982 |
|
|
983 |
|
print STDERR "Reading database: $dbf_file [$max_rowid rows]\n"; |
984 |
|
|
985 |
|
my %dbf2iso; |
986 |
|
foreach my $m (split(/[\n\r]+/,$dbf_mapping)) { |
987 |
|
my ($col,$fld) = split(/\s+/,$m,2); |
988 |
|
$dbf2iso{$col} = $fld; |
989 |
|
} |
990 |
|
|
991 |
|
#print STDERR "## dbf2iso: ",Dumper(\%dbf2iso),"\n## /dbf2iso\n"; |
992 |
|
|
993 |
|
# bad, bad... |
994 |
|
require "to_hash.pm"; |
995 |
|
|
996 |
|
foreach my $row_id (0 .. $max_rowid) { |
997 |
|
my $dbf_row = $db->get_record_as_hash($row_id); |
998 |
|
if ($dbf_row) { |
999 |
|
|
1000 |
|
#print STDERR "## dbf_row: ",Dumper($dbf_row),"\n## /dbf_row\n"; |
1001 |
|
# apply mapping from config file |
1002 |
|
# all unspecified records will get _ in |
1003 |
|
# front of them - _DELETE will be __DELETE |
1004 |
|
my $rec; |
1005 |
|
map { |
1006 |
|
my $new_fld = $dbf2iso{$_} || '_'.$_; |
1007 |
|
my $data = $dbf_row->{$_}; |
1008 |
|
push @{ $rec->{$new_fld} }, $data if ($data && $data !~ /^(?:\s+|\$a\.|)$/); |
1009 |
|
} keys %{$dbf_row}; |
1010 |
|
#print STDERR "## rec: ",Dumper($rec),"\n## /rec\n"; |
1011 |
|
my $row = to_hash($row_id+1, $rec); |
1012 |
|
|
1013 |
|
$row->{mfn} = $row_id+1; |
1014 |
|
$row->{record} = $rec; |
1015 |
|
|
1016 |
|
#print STDERR "## row: ",Dumper($row),"\n## /row\n"; |
1017 |
|
progress($row->{mfn}, $max_rowid); |
1018 |
|
|
1019 |
|
my $swishpath = $path."#".int($row->{mfn}); |
1020 |
|
|
1021 |
|
if (my $xml = data2xml($type_base,$row,$add_xml,$cfg,$database)) { |
1022 |
|
$xml = $cp2utf->convert($xml); |
1023 |
|
use bytes; # as opposed to chars |
1024 |
|
print "Path-Name: $swishpath\n"; |
1025 |
|
print "Content-Length: ".(length($xml)+1)."\n"; |
1026 |
|
print "Document-Type: XML\n\n$xml\n"; |
1027 |
|
} |
1028 |
|
} |
1029 |
|
} |
1030 |
|
print STDERR "\n"; |
1031 |
} |
} |
1032 |
} |
} |
1033 |
|
|
1042 |
|
|
1043 |
all2xml.pl - read various file formats and dump XML for SWISH-E |
all2xml.pl - read various file formats and dump XML for SWISH-E |
1044 |
|
|
1045 |
|
=head1 SYNOPSYS |
1046 |
|
|
1047 |
|
$ all2xml.pl [test.conf] |
1048 |
|
|
1049 |
=head1 DESCRIPTION |
=head1 DESCRIPTION |
1050 |
|
|
1051 |
This command will read ISIS data file using OpenIsis perl module, MARC |
This command will read ISIS data file using Biblio::Isis perl module, MARC |
1052 |
records using MARC module and optionally Micro$oft Excel files to |
records using MARC::File module and optionally Micro$oft Excel files to |
1053 |
create one XML file for usage with I<SWISH-E> indexer. Dispite it's name, |
create one XML file for usage with I<SWISH-E> indexer. Dispite it's name, |
1054 |
this script B<isn't general xml generator> from isis files (isis allready |
this script B<isn't general xml generator> from isis files (isis allready |
1055 |
has something like that). Output of this script is tailor-made for SWISH-E. |
has something like that). Output of this script is tailor-made for SWISH-E. |
1056 |
|
|
1057 |
|
If no configuration file is specified, it will use default one called |
1058 |
|
C<all2xml.conf>. |
1059 |
|
|
1060 |
=head1 BUGS |
=head1 BUGS |
1061 |
|
|
1062 |
Documentation is really lacking. However, in true Open Source spirit, source |
Documentation is really lacking. However, in true Open Source spirit, source |