/[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 501 by dpavlin, Sun Oct 10 11:25:10 2004 UTC revision 546 by dpavlin, Tue Oct 26 18:59:38 2004 UTC
# Line 11  use locale; Line 11  use locale;
11  use YAML;  use YAML;
12  use Carp;  use Carp;
13  use Getopt::Long;  use Getopt::Long;
14    use Text::Unaccent 1.02;
15    
16  use lib './lib';  use lib './lib';
17  use WebPAC;  use WebPAC;
# Line 35  my $result = GetOptions( Line 36  my $result = GetOptions(
36  my $filter = {  my $filter = {
37          'CROVOC' => sub {          'CROVOC' => sub {
38                  my $tmp = shift || return;                  my $tmp = shift || return;
39                  return undef unless ($tmp =~ s/\s+CROVOC.*$/ */);                  return undef unless ($tmp =~ s/\s*CROVOC.*$/ */);
40                  return $tmp;                  return $tmp;
41          },          },
42          'CROVOC_tree' => sub {          'CROVOC_tree' => sub {
43                  my $tmp = shift || return;                  my $tmp = shift || return;
44                  $tmp =~ s/\s+CROVOC.*$/ */;                  $tmp =~ s/\s*CROVOC.*$/ */;
45                  $tmp =~ s/\s+EUROVOC.*//;                  $tmp =~ s/\s*EUROVOC.*//;
46                  return $tmp;                  return $tmp;
47          },          },
48  };  };
49    
50    ## remove accented characters
51    #
52    sub unac {
53            my $string = shift || return;
54            $string = unac_string($code_page,$string);
55            $string =~ tr/ðÐ/dD/;
56            return $string;
57    }
58    sub unac_2 {
59            my $string = shift || return;
60            if (length($string) > 2) {
61                    my $pr = substr($string,0,2);
62                    $string = unac_string($code_page,substr($string,2));
63                    $string =~ tr/ðÐ/dD/;
64                    $string = $pr . $string;
65            }
66            return lc($string);
67    }
68    
69  # create WebPAC object  # create WebPAC object
70  #  #
71  my $webpac = new WebPAC(  my $webpac = new WebPAC(
# Line 138  while (my $rec = $webpac->fetch_rec) { Line 158  while (my $rec = $webpac->fetch_rec) {
158                  $words =~ s/\W*\s+\W*/ /g;                  $words =~ s/\W*\s+\W*/ /g;
159                  $words =~ s/\W+$//;                  $words =~ s/\W+$//;
160    
161                    # first try to generate headline for this entry from index
162                    my $h = $ds->{'index'}->[0];
163                    # then, from display
164                    $h ||= $ds->{'display'}->[0];
165                    # and as last resport, fallback to headline
166                    $h ||= $headline;
167    
168                  $index->insert(                  $index->insert(
169                          index_name => $ds->{'tag'},                          index_name => $ds->{'tag'},
170                          #path => $f,                          #path => $f,
171                          path => $webpac->mfn,                          path => $webpac->mfn,
172                          headline => $headline,                          headline => $h,
173                          words => $words,                          words => unac($words),
174                  );                  );
175          }          }
176    
# Line 151  while (my $rec = $webpac->fetch_rec) { Line 178  while (my $rec = $webpac->fetch_rec) {
178          foreach my $ds (@ds) {          foreach my $ds (@ds) {
179                  next if (! $ds->{'index'});                  next if (! $ds->{'index'});
180    
181                  $thes->{$ds->{'tag'}} ||= new WebPAC::Index;                  $thes->{$ds->{'tag'}} ||= new WebPAC::Index( name => $ds->{'tag'} );
182    
183                  foreach my $h (@{$ds->{'index'}}) {                  foreach my $h (@{$ds->{'index'}}) {
184                          $thes->{$ds->{'tag'}}->insert(                          $thes->{$ds->{'tag'}}->insert(
185                                  headline => $h,                                  sort_by => unac_2($h),
186                                  mfn => $webpac->mfn,                                  mfn => $webpac->mfn,
187                                    headline => $h,
188                          );                          );
189                  }                  }
190          }          }
# Line 194  if (0 && $log->is_debug) { Line 222  if (0 && $log->is_debug) {
222    
223  } # XXX if(0)  } # XXX if(0)
224    
225  $log->debug("lookup hash: ",Dump($webpac->{'lookup'}));  #$log->debug("lookup hash: ",Dump($webpac->{'lookup'}));
226    
227  $log->info("creating tree");  $log->info("creating tree");
228    
# Line 303  my @tree = ({ Line 331  my @tree = ({
331  });  });
332    
333  my $tree = new WebPAC::Tree(  my $tree = new WebPAC::Tree(
334          dir => './out',          tree => \@tree,
335          html => 'browse.html',  );
336    
337    $tree->output(
338            dir => './out',
339            html => 'browse.html',
340          template => './output_template/tree.tt',          template => './output_template/tree.tt',
341          js => 'tree-ids.js',          js => 'tree-ids.js',
         tree => \@tree,  
342  );  );
343    
344    $tree->output(
345            dir => './eurovoc',
346            html => 'hijerarhija.html',
347            template => './output_template/hijerarhija.tt',
348            js => 'tree-ids.js',
349    );
350    
351    
352  $log->info("closing index");  $log->info("closing index");
353  $index->close;  $index->close;
354    

Legend:
Removed from v.501  
changed lines
  Added in v.546

  ViewVC Help
Powered by ViewVC 1.1.26