diff options
| -rw-r--r-- | Aufgabe5/searchengine.pm | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/Aufgabe5/searchengine.pm b/Aufgabe5/searchengine.pm index 9a70367..00bd8a4 100644 --- a/Aufgabe5/searchengine.pm +++ b/Aufgabe5/searchengine.pm @@ -50,7 +50,7 @@ sub buildStoplist { while( my $word = <$stoplistFile> ) { chomp $word; - $stoplist->{$word} = ''; + $stoplist->{$word} = defined; } close $stoplistFile @@ -66,16 +66,13 @@ sub getWords { defined $stoplist or die "Stoplist hash must be supplied"; # Split at whitespaces - my @words = split /[[:space:]]+/, $text; + my @words = split /[[:space:]]+/, lc $text; # Apply regex @words = map /([[:lower:]]{3,})/i , @words; - # Convert to lower case - @words = map {lc $_} @words; - # Remove all words that are in the stoplist - @words = map {!exists $stoplist->{$_} ? ($_) : ()} @words; + @words = grep {!exists $stoplist->{$_}} @words; return @words; } ## --- end sub getWords |
