From 440c10118fd2bde3b18d2de86dafc4d3a4772683 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Thu, 15 Dec 2005 14:12:00 +0000 Subject: [PATCH] various updates to make lookups work (but they don't still) git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@251 07558da8-63fa-0310-ba24-9fe276d99e06 --- conf/log.conf | 3 ++- conf/lookup/jzav.yml | 2 +- conf/normalize/isis_ffzg.xml | 10 +++++++++- conf/output/tt/html_ffzg_results_nonstd.tt | 10 ++++++---- lib/WebPAC/Input/ISIS.pm | 4 ++-- lib/WebPAC/Lookup.pm | 11 ++++++----- run.pl | 3 +++ 7 files changed, 29 insertions(+), 14 deletions(-) diff --git a/conf/log.conf b/conf/log.conf index 9d15e55..6f8da85 100644 --- a/conf/log.conf +++ b/conf/log.conf @@ -16,13 +16,14 @@ log4perl.logger.main=INFO #log4perl.logger.WebPAC.Store.load_ds=DEBUG #log4perl.logger.WebPAC.Lookup=DEBUG +log4perl.logger.WebPAC.Lookup.lookup=DEBUG #log4perl.logger.WebPAC.Input=DEBUG #log4perl.logger.WebPAC.Input.ISIS=DEBUG #log4perl.logger.WebPAC.Input.ISIS.fetch=DEBUG #log4perl.logger.WebPAC.Input.ISIS.open=DEBUG -#log4perl.logger.WebPAC.Normalize=DEBUG +log4perl.logger.WebPAC.Normalize=DEBUG #log4perl.logger.WebPAC.Normalize.XML=DEBUG #log4perl.logger.WebPAC.Normalize.data_structure=DEBUG #log4perl.logger.WebPAC.Normalize.fill_in_to_arr=DEBUG diff --git a/conf/lookup/jzav.yml b/conf/lookup/jzav.yml index d293ebb..11925df 100644 --- a/conf/lookup/jzav.yml +++ b/conf/lookup/jzav.yml @@ -3,7 +3,7 @@ lookup: - key: 'tip:v900' val: 'v200^a' eval: '"v909" eq "1"' - - kay: 'naslov:v900' + - key: 'naslov:v900' val: 'v200^a : v200^e' eval: '"v909" eq "2"' - key: 'tip-naslovi:v946^1' diff --git a/conf/normalize/isis_ffzg.xml b/conf/normalize/isis_ffzg.xml index 52b0993..8cf2e9f 100644 --- a/conf/normalize/isis_ffzg.xml +++ b/conf/normalize/isis_ffzg.xml @@ -239,6 +239,14 @@ v856^u + + [naslov:v946^1] + + + + lookup{[tip-naslovi:v946^1]} + + v990 @@ -251,7 +259,7 @@ materialtype material_code - 200e + v200^e
diff --git a/conf/output/tt/html_ffzg_results_nonstd.tt b/conf/output/tt/html_ffzg_results_nonstd.tt index 241b5e6..99b2f92 100644 --- a/conf/output/tt/html_ffzg_results_nonstd.tt +++ b/conf/output/tt/html_ffzg_results_nonstd.tt @@ -36,11 +36,13 @@ Tema: [% search('UncontrolledTerms','UncontrolledTerms',' * ') %] [% END %] - + + [% d('Parts') %] + [% IF d('APA') %] diff --git a/lib/WebPAC/Input/ISIS.pm b/lib/WebPAC/Input/ISIS.pm index 5ab2a76..061c48f 100644 --- a/lib/WebPAC/Input/ISIS.pm +++ b/lib/WebPAC/Input/ISIS.pm @@ -76,7 +76,7 @@ sub open { $log->logcroak("need filename") if (! $arg->{'filename'}); my $code_page = $arg->{'code_page'} || '852'; - $log->logdie("can't find database ",$arg->{'filename'}) unless (glob($arg->{'filename'}.'.*')); + #$log->logdie("can't find database ",$arg->{'filename'}) unless (glob($arg->{'filename'}.'.*')); # store data in object $self->{'isis_code_page'} = $code_page; @@ -194,7 +194,7 @@ sub open { } # create lookup - $self->{'lookup'}->add( $rec ) if ($self->{'lookup'} && can($self->{'lookup'}->add)); + $self->{'lookup'}->add( $rec ) if ($rec && $self->{'lookup'}); $self->progress_bar($mfn,$maxmfn); diff --git a/lib/WebPAC/Lookup.pm b/lib/WebPAC/Lookup.pm index 798cec5..fc1001d 100644 --- a/lib/WebPAC/Lookup.pm +++ b/lib/WebPAC/Lookup.pm @@ -79,17 +79,18 @@ sub new { } else { $log->logide("unsupported lookup file $lookup_file"); } + $log->debug("lookup_def: " . Dumper( $self->{lookup_def} )); $log->logconfess("lookup config file isn't ARRAY but ", sub { Dumper( $self->{'lookup_def'} ) }) if ($self->{'lookup_def'} !~ /ARRAY/o); - $self->{'is_lookup_regex'} ||= 'lookup{[^\{\}]+}'; + $self->{'is_lookup_regex'} ||= 'lookup{\[[^\{\}]+\]}'; $self->{'save_lookup_regex'} ||= 'lookup{([^\{\}]+)}'; $self->{'LOOKUP_REGEX'} = qr/$self->{'is_lookup_regex'}/; $self->{'LOOKUP_REGEX_SAVE'} = qr/$self->{'save_lookup_regex'}/; - $log->debug("regexps: ", $self->{'LOOKUP_REGEX'}, " ", $self->{'LOOKUP_REGEX_SAVE'}); + $log->debug("regexps lookup:", $self->{'LOOKUP_REGEX'}, " save:", $self->{'LOOKUP_REGEX_SAVE'}); $self ? return $self : return undef; } @@ -104,7 +105,7 @@ Returns true if this record produced lookup. =cut -sub add($) { +sub add { my $self = shift; my $log = $self->_get_logger(); @@ -116,8 +117,8 @@ sub add($) { my $n = 0; foreach my $i (@{ $self->{'lookup_def'} }) { - $log->logconfess("need key") unless defined($i->{'key'}); - $log->logconfess("need val") unless defined($i->{'val'}); + $log->logconfess("need key in ", Dumper($i) ) unless defined($i->{'key'}); + $log->logconfess("need val in ", Dumper($i) ) unless defined($i->{'val'}); $n++; diff --git a/run.pl b/run.pl index e4241c1..77c29a2 100755 --- a/run.pl +++ b/run.pl @@ -77,6 +77,7 @@ while (my ($database, $db_config) = each %{ $config->{databases} }) { my $isis = new WebPAC::Input::ISIS( code_page => $config->{webpac}->{webpac_encoding}, limit_mfn => $input->{limit}, + lookup => $lookup, ); my $maxmfn = $isis->open( @@ -84,6 +85,8 @@ while (my ($database, $db_config) = each %{ $config->{databases} }) { code_page => $input->{encoding}, # database encoding ); +$log->info( Dumper($lookup->{_lookup_data}) ); + my $n = new WebPAC::Normalize::XML( # filter => { 'foo' => sub { shift } }, db => $db, -- 2.20.1