/[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 466 by dpavlin, Thu Sep 23 23:17:42 2004 UTC revision 504 by dpavlin, Sun Oct 10 17:36:43 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 31  my $result = GetOptions( Line 32  my $result = GetOptions(
32          "low_mem!"      => \$low_mem,          "low_mem!"      => \$low_mem,
33  );  );
34    
35    my $filter = {
36            'CROVOC' => sub {
37                    my $tmp = shift || return;
38                    return undef unless ($tmp =~ s/\s*CROVOC.*$/ */);
39                    return $tmp;
40            },
41            'CROVOC_tree' => sub {
42                    my $tmp = shift || return;
43                    $tmp =~ s/\s*CROVOC.*$/ */;
44                    $tmp =~ s/\s*EUROVOC.*//;
45                    return $tmp;
46            },
47    };
48    
49  # create WebPAC object  # create WebPAC object
50  #  #
51  my $webpac = new WebPAC(  my $webpac = new WebPAC(
# Line 39  my $webpac = new WebPAC( Line 54  my $webpac = new WebPAC(
54          start_mfn => $start_mfn,          start_mfn => $start_mfn,
55          debug => $debug,          debug => $debug,
56          low_mem => $low_mem,          low_mem => $low_mem,
57            filter => $filter,
58  ) || die;  ) || die;
59    
60  my $log = $webpac->_get_logger() || die "can't get logger";  my $log = $webpac->_get_logger() || die "can't get logger";
# Line 57  $|=1; Line 73  $|=1;
73  my $maxmfn = $webpac->open_isis(  my $maxmfn = $webpac->open_isis(
74          filename => shift @ARGV || '/data/hidra/THS/THS',          filename => shift @ARGV || '/data/hidra/THS/THS',
75          lookup => [          lookup => [
76          { 'key' => 'd:v900', 'val' => 'v250^a' },          { 'key' => 'd:v900', 'val' => 'filter{CROVOC_tree}v250^a v800' },
77  #       { 'eval' => '"v901^a" eq "Područje"', 'key' => 'pa:v561^4:v562^4:v461^1', 'val' => 'v900' },  #       { 'eval' => '"v901^a" eq "Područje"', 'key' => 'pa:v561^4:v562^4:v461^1', 'val' => 'v900' },
78  #       { 'eval '=> '"v901^a" eq "Mikrotezaurus"', 'key' => 'a:v561^4:v562^4:v461^1', 'val' => 'v900' },  #       { 'eval '=> '"v901^a" eq "Mikrotezaurus"', 'key' => 'a:v561^4:v562^4:v461^1', 'val' => 'v900' },
79  #       { 'eval' => '"v901^a" eq "Deskriptor"', 'key' => 'a:v561^4:v562^4:v461^1', 'val' => 'v900' },  #       { 'eval' => '"v901^a" eq "Deskriptor"', 'key' => 'a:v561^4:v562^4:v461^1', 'val' => 'v900' },
80          { 'key' => 'a:v561^4:v562^4:v461^1', 'val' => 'v900' },          { 'key' => 'a:v561^4:v562^4:v461^1', 'val' => 'v900' },
81          { 'key' => '900_mfn:v900', 'val' => 'v000' },          { 'key' => '900_mfn:v900', 'val' => 'v000' },
82          # tree structure          # tree structure
83          { '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' },
84          { 'eval' => '"v251"', 'key' => 'code:v900', 'val' => 'v561^4:v251' },          { 'eval' => '"v251"', 'key' => 'code:v900', 'val' => 'v561^4:v251' },
85          { 'eval' => '"v561^4" && "v562^4"', 'key' => 'code:v900', 'val' => 'v561^4:v562^4' },          { 'eval' => '"v561^4" && "v562^4"', 'key' => 'code:v900', 'val' => 'v561^4:v562^4' },
86          ],          ],
# Line 122  while (my $rec = $webpac->fetch_rec) { Line 138  while (my $rec = $webpac->fetch_rec) {
138                  $words =~ s/\W*\s+\W*/ /g;                  $words =~ s/\W*\s+\W*/ /g;
139                  $words =~ s/\W+$//;                  $words =~ s/\W+$//;
140    
141                    # first try to generate headline for this entry from index
142                    my $h = shift @{$ds->{'index'}};
143                    # then, from display
144                    $h ||= shift @{$ds->{'display'}};
145                    # and as last resport, fallback to headline
146                    $h ||= $headline;
147    
148                  $index->insert(                  $index->insert(
149                          index_name => $ds->{'tag'},                          index_name => $ds->{'tag'},
150                          #path => $f,                          #path => $f,
151                          path => $webpac->mfn,                          path => $webpac->mfn,
152                          headline => $headline,                          headline => $h,
153                          words => $words,                          words => $words,
154                  );                  );
155          }          }
# Line 200  my @tree = ({ Line 223  my @tree = ({
223          lookup_mfn      => sub { shift @{$l->{"900_mfn:".$_[1]}} },          lookup_mfn      => sub { shift @{$l->{"900_mfn:".$_[1]}} },
224          have_children   => sub { return $l->{"a:".$_[0]."::"} },          have_children   => sub { return $l->{"a:".$_[0]."::"} },
225          have_children_at_level => sub {          have_children_at_level => sub {
226                                  my $l2 = shift;                                  return unless (defined($l->{"code:".$_[1]}));
227                                  my $l1 = substr($l2,0,1);                                  my $code = shift @{$l->{"code:".$_[1]}};
228                                  return(9, "a:$l1:$l2:" ) if ($l->{"a:$l1:$l2"});                                  print STDERR "## $_[1] -> $code\n";
229                                    return undef unless($code);
230                                    return(9, $l->{"a:$code:"} ) if (defined($l->{"a:$code:"}));
231                          },                          },
232          style           => 'display: none',          style           => 'display: none',
233          },{          },{
# Line 274  my @tree = ({ Line 299  my @tree = ({
299          have_children   => sub { 0 },          have_children   => sub { 0 },
300          },{          },{
301          # 9 - level which is never reached except explicitly          # 9 - level which is never reached except explicitly
302          code_arr        => sub { @{$l->{$_[0]}} },          code_arr        => sub { @{$_[0]} },
303          filter_code     => sub { shift },          filter_code     => sub { shift },
304          lookup_v900     => sub { shift @{$l->{"code:".$_[0]}} },          lookup_v900     => sub { shift @{$l->{"code:".$_[0]}} },
305          lookup_term     => sub { shift @{$l->{"d:".$_[0]}} },          lookup_term     => sub { shift @{$l->{"d:".$_[0]}} },
306          lookup_mfn      => sub { shift @{$l->{"900_mfn:".$_[0]}} },          lookup_mfn      => sub { shift @{$l->{"900_mfn:".$_[0]}} },
307          have_children   => sub { 0 },          have_children   => sub { 0 },
308          have_children_at_level => sub { defined($l->{"a:".$_[1].":".$_[0]}) && return (9,"a:".$_[1].":".$_[0]) },          have_children_at_level => sub { defined($l->{"a:".$_[1].":".$_[0]}) && return (9,$l->{"a:".$_[1].":".$_[0]}) },
309          },{          },{
310  });  });
311    

Legend:
Removed from v.466  
changed lines
  Added in v.504

  ViewVC Help
Powered by ViewVC 1.1.26