diff options
| author | Stefan Suhren <suhren.stefan@fh-swf.de> | 2015-12-04 10:34:17 +0100 |
|---|---|---|
| committer | Stefan Suhren <suhren.stefan@fh-swf.de> | 2015-12-04 10:34:17 +0100 |
| commit | f3b1181bcb08a56d79e1f9fc1c3def5ad58f7024 (patch) | |
| tree | 93b100433e45949692d87052e4dae35240f94505 /Aufgabe5/searchengine.pm | |
| parent | b906f04beb5b8678693d855280ed8ec9e18e9b0b (diff) | |
| download | Skriptsprachen-f3b1181bcb08a56d79e1f9fc1c3def5ad58f7024.tar.gz Skriptsprachen-f3b1181bcb08a56d79e1f9fc1c3def5ad58f7024.zip | |
Optimize searchengine plugin
Diffstat (limited to 'Aufgabe5/searchengine.pm')
| -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 |
