9 Einträge, 1 Seite |
1 2 3 4 5 6 7 8 9 10 11 12 13
foreach $key (keys%wordcounter){ my $keyword = Word->new($key); # ... hier passieren noch einige nicht relevante Dinge push @keywords, $keyword; print "Test: ".$keyword->getName()."\n"; } foreach my $wd(@keywords){ print "Test: ".$wd->getName()."\n"; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
# hash that counts appearance of a word my %wordcounter; # collected words foreach (@words){ if (length $_ >= 2){ chomp $_; # remove newline $_ =~ s/[!:.,?()#]//g; # remove possible symbols #print $_."\n"; # increase wordcounter $wordcounter{$_}++; }; } my $position; my @keywords; my $keyword; # print out words from wordcounter foreach $key (keys%wordcounter){ foreach(@blacklists){ # check if a word is blacklistet # if it is not, all positions that have been found in the file are recorded if ($_->validate($key)){ $keyword = HTML_Indexer::Word->new($key); # save all positions #for(1..$wordcounter{$key}){ # #print $key." : ".$wordcounter{$key}."\n"; # $position = new HTML_Indexer::Position($filename, $anchorid); # $keyword->addPosition($position); # } push @keywords, $keyword; print "Test: ".$keyword->getName()."\n"; } else { print $key." : BLACKLISTED \n"; } } } # Testoutput => Hier tritt der Fehler auf! foreach my $wd(@keywords){ print "Test: ".$wd->getName()."\n"; #output is alway @_ ??; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
package HTML_Indexer::Word; use HTML_Indexer::Position; use HTML_Indexer::HeadlinePosition; my $wordname; my @positions; my @headline_positions; sub new (){ my $classname = shift; $wordname = shift; print "Creating word: ".$wordname."\n"; my $self = {}; $counter++; return bless $self, $classname; }; sub addPosition(){ my $classname = shift; # 1. Parameter Klassenname my $position = shift; push @positions, $position; }; sub addPositions(){ my $classname = shift; # 1. Parameter Klassenname my @pos = shift; push @positions, @pos; }; sub getPositions(){ return @positions; } sub getName(){ return $wordname; }
Gast+2008-07-04 15:12:37--Code (perl): (dl )1 2 3 4 5sub addPositions(){ my $classname = shift; # 1. Parameter Klassenname my @pos = shift; # <---- SORRY ??? push @positions, @pos; };
9 Einträge, 1 Seite |