Здравствйте!
Как оптимальнее всего хранить стоп-слова
и как оптимальнее всего удалять их из текста?
our %stop_hash;
our @stop_words = qw/i in a to the it have haven\'t was but is be from/;
foreach @stop_words {$stop_hash{$_}++ };
sub get_words {
# теперь с поддержкой стоп-листа!
my ( $text ) = @_;
return map { $_ => 1 }
grep { !( exists $stop_hash{$_} ) }
map lc,
map { /([a-z\\-\']+)/i }
split /\\s+/s, $text;
}
Это правильный подход?