--- trunk2/all2all.pl 2004/09/15 16:53:51 448 +++ trunk2/all2all.pl 2004/09/15 22:36:23 454 @@ -7,7 +7,7 @@ =cut use strict; -use Data::Dumper; +use YAML; use Carp; use Getopt::Long; @@ -82,8 +82,8 @@ my @ds = $webpac->data_structure($rec); if (0 && $log->is_debug) { - $log->debug("rec = ",Dumper($rec)); - $log->debug("ds = ",Dumper(\@ds)); + $log->debug("rec = ",Dump($rec)); + $log->debug("ds = ",Dump(\@ds)); } next if (! @ds); @@ -136,7 +136,7 @@ } } -# print Dumper(\@ds); +# print Dump(\@ds); } @@ -160,16 +160,16 @@ } if (0 && $log->is_debug) { - $log->debug("lookup hash: ",Dumper($webpac->{'lookup'})); - $log->debug("data hash: ",Dumper($webpac->{'data'})); + $log->debug("lookup hash: ",Dump($webpac->{'lookup'})); + $log->debug("data hash: ",Dump($webpac->{'data'})); foreach my $t (keys %{$thes}) { - $log->debug("thesaurus $t hash: ",Dumper($thes->{$t})); + $log->debug("thesaurus $t hash: ",Dump($thes->{$t})); } } } # XXX if(0) -$log->debug("lookup hash: ",Dumper($webpac->{'lookup'})); +$log->debug("lookup hash: ",Dump($webpac->{'lookup'})); $log->info("creating tree"); @@ -189,32 +189,34 @@ lookup_v900 => sub { shift @{$l->{"root:".$_[0]}} }, lookup_term => sub { shift @{$l->{"d:".$_[1]}} }, lookup_mfn => sub { shift @{$l->{"900_mfn:".$_[1]}} }, - have_children => sub { defined($l->{"a:".$_[0]."::"}) }, - child_code => sub { return $_[0] }, + have_children => sub { return $l->{"a:".$_[0]."::"} }, + have_children_at_level => sub { + my $l2 = shift; + my $l1 = substr($l2,0,1); + return(9, "a:$l1:$l2:" ) if ($l->{"a:$l1:$l2"}); + }, style => 'display: none', },{ # 1 - code_arr => sub { @{$l->{"a:".$_[0]."::"}} }, + code_arr => sub { @{$_[0]} }, filter_code => sub { shift }, # nop lookup_v900 => sub { shift @{$l->{"code:".$_[0]}} }, lookup_term => sub { shift @{$l->{"d:".$_[0]}} }, lookup_mfn => sub { shift @{$l->{"900_mfn:".$_[0]}} }, - have_children => sub { defined($l->{"a:".$_[1].":"}) }, - child_code => sub { return $_[1] }, + have_children => sub { return $l->{"a:".$_[1].":"} }, style => 'display: none', },{ # 2 - code_arr => sub { @{$l->{"a:".$_[0].":"}} }, + code_arr => sub { @{$_[0]} }, filter_code => sub { shift }, lookup_v900 => sub { shift }, lookup_term => sub { shift @{$l->{"d:".$_[0]}} }, lookup_mfn => sub { shift @{$l->{"900_mfn:".$_[0]}} }, - have_children => sub { defined($l->{"a:".$_[2].":".$_[1]}) }, - child_code => sub { return "a:".$_[2].":".$_[1] }, - style => 'display: none', + have_children => sub { return $l->{"a:".$_[2].":".$_[1]} }, + #style => 'display: none', },{ # 3 uži pojam - code_arr => sub { @{$l->{$_[0]}} }, + code_arr => sub { @{$_[0]} }, filter_code => sub { shift }, lookup_v900 => sub { my ($c,$p) = @_; @@ -223,11 +225,10 @@ }, lookup_term => sub { shift @{$l->{"d:".$_[0]}} }, lookup_mfn => sub { shift @{$l->{"900_mfn:".$_[0]}} }, - have_children => sub { defined($l->{$_[1]}) }, - child_code => sub { return $_[1] }, + have_children => sub { return $l->{$_[1]} }, },{ # 4 - code_arr => sub { @{$l->{$_[0]}} }, + code_arr => sub { @{$_[0]} }, filter_code => sub { shift }, lookup_v900 => sub { my ($c,$p) = @_; @@ -236,11 +237,10 @@ }, lookup_term => sub { shift @{$l->{"d:".$_[0]}} }, lookup_mfn => sub { shift @{$l->{"900_mfn:".$_[0]}} }, - have_children => sub { defined($l->{$_[1]}) }, - child_code => sub { return $_[1] }, + have_children => sub { return $l->{$_[1]} }, },{ # 5 - code_arr => sub { @{$l->{$_[0]}} }, + code_arr => sub { @{$_[0]} }, filter_code => sub { shift }, lookup_v900 => sub { my ($c,$p) = @_; @@ -249,11 +249,10 @@ }, lookup_term => sub { shift @{$l->{"d:".$_[0]}} }, lookup_mfn => sub { shift @{$l->{"900_mfn:".$_[0]}} }, - have_children => sub { defined($l->{$_[1]}) }, - child_code => sub { return $_[1] }, + have_children => sub { return $l->{$_[1]} }, },{ # 6 - code_arr => sub { @{$l->{$_[0]}} }, + code_arr => sub { @{$_[0]} }, filter_code => sub { shift }, lookup_v900 => sub { my ($c,$p) = @_; @@ -262,11 +261,10 @@ }, lookup_term => sub { shift @{$l->{"d:".$_[0]}} }, lookup_mfn => sub { shift @{$l->{"900_mfn:".$_[0]}} }, - have_children => sub { defined($l->{$_[1]}) }, - child_code => sub { return $_[1] }, + have_children => sub { return $l->{$_[1]} }, },{ # 7 - code_arr => sub { @{$l->{$_[0]}} }, + code_arr => sub { @{$_[0]} }, filter_code => sub { shift }, lookup_v900 => sub { my ($c,$p) = @_; @@ -275,11 +273,10 @@ }, lookup_term => sub { shift @{$l->{"d:".$_[0]}} }, lookup_mfn => sub { shift @{$l->{"900_mfn:".$_[0]}} }, - have_children => sub { defined($l->{$_[1]}) }, - child_code => sub { return $_[1] }, + have_children => sub { return $l->{$_[1]} }, },{ # 8 - code_arr => sub { @{$l->{$_[0]}} }, + code_arr => sub { @{$_[0]} }, filter_code => sub { shift }, lookup_v900 => sub { my ($c,$p) = @_; @@ -288,10 +285,23 @@ }, lookup_term => sub { shift @{$l->{"d:".$_[0]}} }, lookup_mfn => sub { shift @{$l->{"900_mfn:".$_[0]}} }, -# have_children => sub { defined($l->{$_[1]}) }, +# have_children => sub { return $l->{$_[1]} }, # child_code => sub { return $_[1] }, have_children => sub { 0 }, - child_code => sub { 0 }, + },{ + # 9 - level which is never reached except explicitly + code_arr => sub { @{$l->{$_[0]}} }, + filter_code => sub { shift }, + lookup_v900 => sub { + my ($c,$p) = @_; + $p =~ s/^a:(.+:.+):.*$/$1/; + return "a:".$p.":".$c; + }, + lookup_term => sub { shift @{$l->{"d:".$_[0]}} }, + lookup_mfn => sub { shift @{$l->{"900_mfn:".$_[0]}} }, + have_children => sub { 0 }, + have_children_at_level => sub { defined($l->{$_[1]}) && return (9,$_[1]) }, + },{ }); my $tree = new WebPAC::Tree(