Plucene/Analysis/PorterStemFilter.pm untested

filter: Statementstmt 0.0% 0 / 21 Branchbran n/a Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 30 CC 1 SCAR 6.9
CC
1
Cov
0%
next
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Plucene::Analysis::PorterStemFilter;
2  
3 =head1 NAME
4  
5 Plucene::Analysis::PorterStemFilter - Porter stemming on the token stream
6  
7 =head1 SYNOPSIS
8  
9 # isa Plucene::Analysis:::TokenFilter
10
11 my $token = $porter_stem_filter->next;
12  
13 =head1 DESCRIPTION
14  
15 This class transforms the token stream as per the Porter stemming algorithm.
16  
17 Note: the input to the stemming filter must already be in lower case, so you
18 will need to use LowerCaseFilter or LowerCaseTokenizer farther down the
19 Tokenizer chain in order for this to work properly!
20  
21 The Porter Stemmer implements Porter Algorithm for normalization of English
22 words by stripping their extensions and is used to generalize the searches.
23 For example, the Porter algorithm maps both 'search' and 'searching'
24 (as well as 'searchnessing') to 'search' such that a query for 'search' will
25 also match documents that contains the word 'searching'.
26  
27 Note that the Porter algorithm is specific to the English language and may give
28 unpredictable results for other languages. Also, make sure to use the same
29 analyzer during the indexing and the searching.
30  
31 You can find more information on the Porter algorithm at
32 www.tartarus.org/~martin/PorterStemmer.
33  
34 A nice online demonstration of the Porter algorithm is available at
35 www.scs.carleton.ca/~dquesnel/java/stuff/PorterApplet.html.
36  
37 =head1 METHODS
38  
39 =cut
40  
41 use strict;
42 use warnings;
43  
44 use Lingua::Stem::En;
45 Lingua::Stem::En::stem_caching({ -level => 2 });
46  
47 use base 'Plucene::Analysis::TokenFilter';
48  
49 =head2 next
50  
51 my $token = $porter_stem_filter->next;
52  
53 Returns the next input token, after being stemmed.
54  
55 =cut
56  
57 sub next {
58 my $self = shift;
59 my $t = $self->input->next or return;
60 $t->text(@{ Lingua::Stem::En::stem({ -words => [ $t->text ] }) });
61 return $t;
62 }
63  
64 1;