/[webpac]/trunk2/all2all.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

Diff of /trunk2/all2all.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 454 by dpavlin, Wed Sep 15 22:36:23 2004 UTC revision 490 by dpavlin, Sat Oct 9 21:44:25 2004 UTC
# Line 7  all2all.pl - basic script for all WebPAC Line 7  all2all.pl - basic script for all WebPAC
7  =cut  =cut
8    
9  use strict;  use strict;
10    use locale;
11  use YAML;  use YAML;
12  use Carp;  use Carp;
13  use Getopt::Long;  use Getopt::Long;
# Line 64  my $maxmfn = $webpac->open_isis( Line 65  my $maxmfn = $webpac->open_isis(
65          { 'key' => 'a:v561^4:v562^4:v461^1', 'val' => 'v900' },          { 'key' => 'a:v561^4:v562^4:v461^1', 'val' => 'v900' },
66          { 'key' => '900_mfn:v900', 'val' => 'v000' },          { 'key' => '900_mfn:v900', 'val' => 'v000' },
67          # tree structure          # tree structure
68          { 'eval' => 'length("v251") == 2', 'key' => 'root:v251', 'val' => 'v900' },          { 'eval' => 'length("v251") == 2 && "v800" =~ m/EUROVOC/ || "v800" =~ m/CROVOC/ && "v251" =~ m/^(H|HD|L|Z|P)$/', 'key' => 'root:v251', 'val' => 'v900' },
69          { 'eval' => '"v251"', 'key' => 'code:v900', 'val' => 'v561^4:v251' },          { 'eval' => '"v251"', 'key' => 'code:v900', 'val' => 'v561^4:v251' },
70            { 'eval' => '"v561^4" && "v562^4"', 'key' => 'code:v900', 'val' => 'v561^4:v562^4' },
71          ],          ],
72  );  );
73    
# Line 114  while (my $rec = $webpac->fetch_rec) { Line 116  while (my $rec = $webpac->fetch_rec) {
116          foreach my $ds (@ds) {          foreach my $ds (@ds) {
117                  next if (! $ds->{'swish'});                  next if (! $ds->{'swish'});
118    
119                    # strip all non word characters from beginning or end
120                    # of word
121                    my $words = join(" ",@{$ds->{'swish'}});
122                    $words =~ s/^\W+//;
123                    $words =~ s/\W*\s+\W*/ /g;
124                    $words =~ s/\W+$//;
125    
126                  $index->insert(                  $index->insert(
127                          index_name => $ds->{'tag'},                          index_name => $ds->{'tag'},
128                          path => $f,                          #path => $f,
129                            path => $webpac->mfn,
130                          headline => $headline,                          headline => $headline,
131                          words => join(" ",@{$ds->{'swish'}})                          words => $words,
132                  );                  );
133          }          }
134    
# Line 191  my @tree = ({ Line 201  my @tree = ({
201          lookup_mfn      => sub { shift @{$l->{"900_mfn:".$_[1]}} },          lookup_mfn      => sub { shift @{$l->{"900_mfn:".$_[1]}} },
202          have_children   => sub { return $l->{"a:".$_[0]."::"} },          have_children   => sub { return $l->{"a:".$_[0]."::"} },
203          have_children_at_level => sub {          have_children_at_level => sub {
204                                  my $l2 = shift;                                  return unless (defined($l->{"code:".$_[1]}));
205                                  my $l1 = substr($l2,0,1);                                  my $code = shift @{$l->{"code:".$_[1]}};
206                                  return(9, "a:$l1:$l2:" ) if ($l->{"a:$l1:$l2"});                                  print STDERR "## $_[1] -> $code\n";
207                                    return undef unless($code);
208                                    return(9, $l->{"a:$code:"} ) if (defined($l->{"a:$code:"}));
209                          },                          },
210          style           => 'display: none',          style           => 'display: none',
211          },{          },{
# Line 209  my @tree = ({ Line 221  my @tree = ({
221          # 2          # 2
222          code_arr        => sub { @{$_[0]} },          code_arr        => sub { @{$_[0]} },
223          filter_code     => sub { shift },          filter_code     => sub { shift },
224          lookup_v900     => sub { shift },          lookup_v900     => sub { shift @{$l->{"code:".$_[0]}} },
225          lookup_term     => sub { shift @{$l->{"d:".$_[0]}} },          lookup_term     => sub { shift @{$l->{"d:".$_[0]}} },
226          lookup_mfn      => sub { shift @{$l->{"900_mfn:".$_[0]}} },          lookup_mfn      => sub { shift @{$l->{"900_mfn:".$_[0]}} },
227          have_children   => sub { return $l->{"a:".$_[2].":".$_[1]} },          have_children   => sub { return $l->{"a:".$_[1].":".$_[0]} },
228          #style          => 'display: none',          #style          => 'display: none',
229          },{          },{
230          # 3 uži pojam          # 3 uži pojam
231          code_arr        => sub { @{$_[0]} },          code_arr        => sub { @{$_[0]} },
232          filter_code     => sub { shift },          filter_code     => sub { shift },
233          lookup_v900     => sub {          lookup_v900     => sub { shift @{$l->{"code:".$_[0]}} },
                                 my ($c,$p) = @_;  
                                 $p =~ s/^a:(..:....):.*$/$1/;  
                                 return "a:".$p.":".$c;  
                         },  
234          lookup_term     => sub { shift @{$l->{"d:".$_[0]}} },          lookup_term     => sub { shift @{$l->{"d:".$_[0]}} },
235          lookup_mfn      => sub { shift @{$l->{"900_mfn:".$_[0]}} },          lookup_mfn      => sub { shift @{$l->{"900_mfn:".$_[0]}} },
236          have_children   => sub { return $l->{$_[1]} },          have_children   => sub { return $l->{"a:".$_[1].":".$_[0]} },
237          },{          },{
238          # 4          # 4
239          code_arr        => sub { @{$_[0]} },          code_arr        => sub { @{$_[0]} },
240          filter_code     => sub { shift },          filter_code     => sub { shift },
241          lookup_v900     => sub {          lookup_v900     => sub { shift @{$l->{"code:".$_[0]}} },
                                 my ($c,$p) = @_;  
                                 $p =~ s/^a:(..:....):.*$/$1/;  
                                 return "a:".$p.":".$c;  
                         },  
242          lookup_term     => sub { shift @{$l->{"d:".$_[0]}} },          lookup_term     => sub { shift @{$l->{"d:".$_[0]}} },
243          lookup_mfn      => sub { shift @{$l->{"900_mfn:".$_[0]}} },          lookup_mfn      => sub { shift @{$l->{"900_mfn:".$_[0]}} },
244          have_children   => sub { return $l->{$_[1]} },          have_children   => sub { return $l->{"a:".$_[1].":".$_[0]} },
245          },{          },{
246          # 5          # 5
247          code_arr        => sub { @{$_[0]} },          code_arr        => sub { @{$_[0]} },
248          filter_code     => sub { shift },          filter_code     => sub { shift },
249          lookup_v900     => sub {          lookup_v900     => sub { shift @{$l->{"code:".$_[0]}} },
                                 my ($c,$p) = @_;  
                                 $p =~ s/^a:(..:....):.*$/$1/;  
                                 return "a:".$p.":".$c;  
                         },  
250          lookup_term     => sub { shift @{$l->{"d:".$_[0]}} },          lookup_term     => sub { shift @{$l->{"d:".$_[0]}} },
251          lookup_mfn      => sub { shift @{$l->{"900_mfn:".$_[0]}} },          lookup_mfn      => sub { shift @{$l->{"900_mfn:".$_[0]}} },
252          have_children   => sub { return $l->{$_[1]} },          have_children   => sub { return $l->{"a:".$_[1].":".$_[0]} },
253          },{          },{
254          # 6          # 6
255          code_arr        => sub { @{$_[0]} },          code_arr        => sub { @{$_[0]} },
256          filter_code     => sub { shift },          filter_code     => sub { shift },
257          lookup_v900     => sub {          lookup_v900     => sub { shift @{$l->{"code:".$_[0]}} },
                                 my ($c,$p) = @_;  
                                 $p =~ s/^a:(..:....):.*$/$1/;  
                                 return "a:".$p.":".$c;  
                         },  
258          lookup_term     => sub { shift @{$l->{"d:".$_[0]}} },          lookup_term     => sub { shift @{$l->{"d:".$_[0]}} },
259          lookup_mfn      => sub { shift @{$l->{"900_mfn:".$_[0]}} },          lookup_mfn      => sub { shift @{$l->{"900_mfn:".$_[0]}} },
260          have_children   => sub { return $l->{$_[1]} },          have_children   => sub { return $l->{"a:".$_[1].":".$_[0]} },
261          },{          },{
262          # 7          # 7
263          code_arr        => sub { @{$_[0]} },          code_arr        => sub { @{$_[0]} },
264          filter_code     => sub { shift },          filter_code     => sub { shift },
265          lookup_v900     => sub {          lookup_v900     => sub { shift @{$l->{"code:".$_[0]}} },
                                 my ($c,$p) = @_;  
                                 $p =~ s/^a:(..:....):.*$/$1/;  
                                 return "a:".$p.":".$c;  
                         },  
266          lookup_term     => sub { shift @{$l->{"d:".$_[0]}} },          lookup_term     => sub { shift @{$l->{"d:".$_[0]}} },
267          lookup_mfn      => sub { shift @{$l->{"900_mfn:".$_[0]}} },          lookup_mfn      => sub { shift @{$l->{"900_mfn:".$_[0]}} },
268          have_children   => sub { return $l->{$_[1]} },          have_children   => sub { return $l->{"a:".$_[1].":".$_[0]} },
269          },{          },{
270          # 8          # 8
271          code_arr        => sub { @{$_[0]} },          code_arr        => sub { @{$_[0]} },
272          filter_code     => sub { shift },          filter_code     => sub { shift },
273          lookup_v900     => sub {          lookup_v900     => sub { shift @{$l->{"code:".$_[0]}} },
                                 my ($c,$p) = @_;  
                                 $p =~ s/^a:(..:....):.*$/$1/;  
                                 return "a:".$p.":".$c;  
                         },  
274          lookup_term     => sub { shift @{$l->{"d:".$_[0]}} },          lookup_term     => sub { shift @{$l->{"d:".$_[0]}} },
275          lookup_mfn      => sub { shift @{$l->{"900_mfn:".$_[0]}} },          lookup_mfn      => sub { shift @{$l->{"900_mfn:".$_[0]}} },
276  #       have_children   => sub { return $l->{$_[1]} },  #       have_children   => sub { return $l->{"a:".$_[1].":".$_[0]} },
 #       child_code      => sub { return $_[1] },  
277          have_children   => sub { 0 },          have_children   => sub { 0 },
278          },{          },{
279          # 9 - level which is never reached except explicitly          # 9 - level which is never reached except explicitly
280          code_arr        => sub { @{$l->{$_[0]}} },          code_arr        => sub { @{$_[0]} },
281          filter_code     => sub { shift },          filter_code     => sub { shift },
282          lookup_v900     => sub {          lookup_v900     => sub { shift @{$l->{"code:".$_[0]}} },
                                 my ($c,$p) = @_;  
                                 $p =~ s/^a:(.+:.+):.*$/$1/;  
                                 return "a:".$p.":".$c;  
                         },  
283          lookup_term     => sub { shift @{$l->{"d:".$_[0]}} },          lookup_term     => sub { shift @{$l->{"d:".$_[0]}} },
284          lookup_mfn      => sub { shift @{$l->{"900_mfn:".$_[0]}} },          lookup_mfn      => sub { shift @{$l->{"900_mfn:".$_[0]}} },
285          have_children   => sub { 0 },          have_children   => sub { 0 },
286          have_children_at_level => sub { defined($l->{$_[1]}) && return (9,$_[1]) },          have_children_at_level => sub { defined($l->{"a:".$_[1].":".$_[0]}) && return (9,$l->{"a:".$_[1].":".$_[0]}) },
287          },{          },{
288  });  });
289    

Legend:
Removed from v.454  
changed lines
  Added in v.490

  ViewVC Help
Powered by ViewVC 1.1.26