Plucene::Analysis::StopFilter - the stop filter


Plucene documentation Contained in the Plucene distribution.

Index


Code Index:

NAME

Top

Plucene::Analysis::StopFilter - the stop filter

SYNOPSIS

Top

	# isa Plucene::Analysis::TokenFilter

	my $next = $stop_filter->next;

DESCRIPTION

Top

This removes stop words from a token stream.

Instances of the StopFilter class are tokens filters that removes from the indexed text words of your choice. Typically this is used to filter out common words ('the', 'a' 'if' etc) that increase the overhead but add no value during searches.

METHODS

Top

next

	my $next = $stop_filter->next;

This returns the next input token whose term is not a stop word.


Plucene documentation Contained in the Plucene distribution.
package Plucene::Analysis::StopFilter;

use strict;
use warnings;

use base 'Plucene::Analysis::TokenFilter';

sub next {
	my $self = shift;
	$self->{stophash} ||= { map { $_ => 1 } @{ $self->{stoplist} } };
	while (my $t = $self->input->next) {
		next if exists $self->{stophash}->{ $t->text() };
		return $t;
	}
	return;
}

1;