line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plucene::Plugin::Analyzer::MetaphoneFilter; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Plucene::Plugin::Analyzer::MetaphoneFilter - Metaphone filter on the token stream |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# isa Plucene::Analysis:::TokenFilter |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $token = $metaphone_filter->next; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
This class transforms the token stream as per the Metaphone algorithm. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
You can find more information on the Metaphone algorithm at |
18
|
|
|
|
|
|
|
Text::Metaphone |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 METHODS |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
47
|
|
25
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
39
|
|
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
1
|
|
951
|
use Text::Metaphone; |
|
1
|
|
|
|
|
1894
|
|
|
1
|
|
|
|
|
81
|
|
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
1
|
|
7
|
use base 'Plucene::Analysis::TokenFilter'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
995
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 next |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my $token = $metaphone_filter->next; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Returns the next input token, after being metaphoned. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub next { |
40
|
4
|
|
|
4
|
1
|
79
|
my $self = shift; |
41
|
4
|
100
|
|
|
|
20
|
my $t = $self->input->next or return; |
42
|
3
|
|
|
|
|
6855
|
my @r; |
43
|
3
|
|
|
|
|
12
|
push @r, Metaphone($t->text); |
44
|
3
|
|
|
|
|
34
|
$t->text(@r); |
45
|
3
|
|
|
|
|
25
|
return $t; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |