Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Friday, October 16, 2026

Diff for iotta/Iotta/Categorizer/Simple.pm between version 1.1 and 1.2

version 1.1, 2003/02/16 15:48:13 version 1.2, 2003/03/14 14:19:10
Line 12  our @ISA = ("Iotta::Elem");
Line 12  our @ISA = ("Iotta::Elem");
 sub setup {  sub setup {
         my $self = shift;          my $self = shift;
         my $o = shift;          my $o = shift;
           my @segm;
         $self->ctrl ($$o{control}) if $$o{control};          $self->ctrl ($$o{control}) if $$o{control};
           for (keys %$o) {
                   if (/^segment/) {
                           my $s = $self->chain->mod_creat ($$o{$_});
                           push @segm, $s;
                   }
           }
           $self->segm (\@segm);
   }
   
   sub segment {
           my $self = shift;
           my $c = shift;
           my $fls = shift;
           for (@{$self->segm}) {
                   print "segmenter: $_\n";
                   $fls = $_->segment ($c, $fls);
           };
           return $fls;
   }
   
   sub fillcat
   {
           my $self = shift;
           my $c = shift;
           my $files = shift;
           my $fls;
           print "categorizer: $$c{input}\n";
           my @_fls = sort { $$a{input} cmp $$b{input} } grep
                   { (join ":", @{$$_{topics}}) =~ /$$c{kw}/ }
                   @$files;
           $fls = \@_fls;
           my @remain = sort { $$a{input} cmp $$b{input} } grep
                   { (join ":", @{$$_{topics}}) !~ /$$c{kw}/ }
                   @$files;
           for (@{$$c{subs}}) {
                   print "sub: $$_{input}\n";
                   my $rem = $self->fillcat ($_, $fls);
                   print "endsub: $$_{input}\n";
                   if (scalar @{$$_{files}} < 5 and scalar @{$$_{files}} + scalar @$fls <
                   10 and not scalar @{$$_{subs}}) {
                           $$_{remove} = 1;
                   } else {
                           $fls = $rem;
                   }
           }
           my $i = 0;
           while ($i < scalar @{$$c{subs}}) {
                   my $it = ${$$c{subs}}[$i];
                   if ($$it{remove}) {
                           print "removing: $$it{input}\n";
                           splice @{$$c{subs}}, $i, 1;
                           $i --;
                   }
                   $i ++;
           }
           if (scalar @$fls > 10) {
                   $fls = $self->segment ($c, $fls);
           }
           for (@$fls) {
                   print "file: $$_{input}\n";
           }
           for (@{$$c{subs}}) {
                   print "remained sub: $$_{input}\n";
           }
           $$c{files} = $fls;
           return \@remain;
 }  }
   
 sub sort {  sub sort {
Line 20  sub sort {
Line 87  sub sort {
         my $s = shift;          my $s = shift;
         my $files =shift;          my $files =shift;
         my $in;          my $in;
           my @cats;
         open IN, $s->ctrl;          open IN, $s->ctrl;
         $in .= $_ while (<IN>);          $in .= $_ while (<IN>);
         close IN;          close IN;
           $in =~ s/^#.*?\n//gsm;
         for (split /\n/, $in) {          for (split /\n/, $in) {
                 my %cidx;                  my %cat;
                 /^(.*?)[ \t]*\[(.*?)\][ \t]*\((.*?)\)$/;                  /^(.*?)[ \t]*\[(.*?)\][ \t]*\((.*?)\)$/;
                 $cidx{input} = $1;                  $cat{input} = $1;
                 $cidx{title} = $2;                  $cat{title} = $2;
                 my $kw = $3;                  $cat{kw} = $3;
                 print "categorizer: $1\n";                  push @cats, \%cat;
                 my @fls = sort { $$a{input} cmp $$b{input} } grep          }
                         { scalar grep /$kw/, @{$$_{topics}} }          my @tcats = @cats;
                         @$files;          for my $c (@cats) {
                 for (@fls) {                  my @subs = grep { $$_{input} =~ /^$$c{input}-/ } @tcats;
                         print "file: $$_{input}\n";                  @tcats = grep { $$_{input} !~ /^$$c{input}-/ } @tcats;
                   for (@subs) {
                           print "sub: $$_{input}\n";
                 }                  }
                 $cidx{files} = \@fls;                  $$c{subs} = \@subs;
                 push @idx, \%cidx;          }
           for my $c (@tcats) {
                   $s->fillcat ($c, $files);
         }          }
         return \@idx;          return \@tcats;
 }  }
   
 sub initialize {  sub initialize {
         my $self = shift;          my $self = shift;
         $self->SUPER::initialize (@_);          $self->SUPER::initialize (@_);
         $self->{ctrl} = 'default.cat';          $self->{ctrl} = 'default.cat';
           $self->{segm} = ();
 }  }
 1;  1;

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top