| 1 | package Plucene::Analysis::StopFilter; | ||||||||||||
| 2 | |||||||||||||
| 3 | =head1 NAME | ||||||||||||
| 4 | |||||||||||||
| 5 | Plucene::Analysis::StopFilter - the stop filter | ||||||||||||
| 6 | |||||||||||||
| 7 | =head1 SYNOPSIS | ||||||||||||
| 8 | |||||||||||||
| 9 | # isa Plucene::Analysis::TokenFilter | ||||||||||||
| 10 | |||||||||||||
| 11 | my $next = $stop_filter->next; | ||||||||||||
| 12 | |||||||||||||
| 13 | =head1 DESCRIPTION | ||||||||||||
| 14 | |||||||||||||
| 15 | This removes stop words from a token stream. | ||||||||||||
| 16 | |||||||||||||
| 17 | Instances of the StopFilter class are tokens filters that removes from the | ||||||||||||
| 18 | indexed text words of your choice. Typically this is used to filter out common | ||||||||||||
| 19 | words ('the', 'a' 'if' etc) that increase the overhead but add no value during | ||||||||||||
| 20 | searches. | ||||||||||||
| 21 | |||||||||||||
| 22 | =head1 METHODS | ||||||||||||
| 23 | |||||||||||||
| 24 | =cut | ||||||||||||
| 25 | |||||||||||||
| 26 | 1 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 27 | 1 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 28 | |||||||||||||
| 29 | 1 | ▶ | use base 'Plucene::Analysis::TokenFilter'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 30 | |||||||||||||
| 31 | =head2 next | ||||||||||||
| 32 | |||||||||||||
| 33 | my $next = $stop_filter->next; | ||||||||||||
| 34 | |||||||||||||
| 35 | This returns the next input token whose term is not a stop word. | ||||||||||||
| 36 | |||||||||||||
| 37 | =cut | ||||||||||||
| 38 | |||||||||||||
| 39 | 10 | ▶ | sub next { | ||||||||||
|
Subroutine
next: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||
| 40 | 10 | my $self = shift; | |||||||||||
| 41 | 10 | ▶ | $self->{stophash} ||= { map { $_ => 1 } @{ $self->{stoplist} } }; | ||||||||||
|
Condition100%2/2
$self->{"stophash"} ||= {map({$_, 1;} @{$$self{"stoplist"};})}
MC/DC100%1/1
$self->{"stophash"} ||= {map({$_, 1;} @{$$self{"stoplist"};})}
$self->{"stophash"}
Truth table100%2/2
A
A= $self->{"stophash"}
| |||||||||||||
| 42 | 10 | ▶ | while (my $t = $self->input->next) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 43 | 11 | ▶ | next if exists $self->{stophash}->{ $t->text() }; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 44 | 8 | return $t; | |||||||||||
| 45 | } | ||||||||||||
| 46 | 2 | return; | |||||||||||
| 47 | } | ||||||||||||
| 48 | |||||||||||||
| 49 | 1 | 1; | |||||||||||