in reply to removing stopwords
#!/usr/bin/perl -w use strict; my @data = ( "Some lines of text", "I love my lines of text", "These a +re nice lines" ); my @stopwords = ( "lines" ); my @lessWords = (); my (@arr,@a); foreach my $word (@data) { push @arr,split(/ /,$word); } WORD: foreach my $a (@arr) { foreach my $stop (@stopwords) { next WORD if $a eq $stop; } push(@lessWords, $a); } print join( ' ', @lessWords ), "\n"; __OUTPUT__ Some of text I love my of text These are nice
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: removing stopwords
by zulqernain (Novice) on Jun 01, 2005 at 23:08 UTC | |
by ikegami (Patriarch) on Jun 01, 2005 at 23:23 UTC |