Plucene/Analysis/Standard/StandardTokenizer.pm

filter: Statementstmt 88.8% 24 / 27 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 4 / 5 Podpod 100% 2 / 2 totaltotal 84.2% 32 / 38 CC 3 SCAR 7.8
CC
3
Cov
84%
normalize
3.4
token_re
2.0
BEGIN
1.0
CRAP 2.2
« Plucene/Search/TermScorer.pm ↑ Summary Plucene/Index/SegmentMergeInfo.pm »
1 package Plucene::Analysis::Standard::StandardTokenizer;
2  
3 =head1 NAME
4  
5 Plucene::Analysis::Standard::StandardTokenizer - standard tokenizer
6  
7 =head1 SYNOPSIS
8  
9 # isa Plucene::Analysis::CharTokenizer
10  
11 =head1 DESCRIPTION
12  
13 This is the standard tokenizer.
14  
15 This should be a good tokenizer for most European-language documents.
16  
17 =head1 METHODS
18  
19 =cut
20  
21 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 2 ▶use base 'Plucene::Analysis::CharTokenizer';
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 # Don't blame me, blame the Plucene people!
27 2 my $alpha = qr/\p{IsAlpha}+/;
28 2 my $apostrophe = qr/$alpha('$alpha)+/;
29 2 my $acronym = qr/$alpha\.($alpha\.)+/;
30 2 my $company = qr/$alpha(&|\@)$alpha/;
31 2 my $hostname = qr/\w+(\.\w+)+/;
32 2 my $email = qr/\w+\@$hostname/;
33 2 my $p = qr/[_\/.,-]/;
34 2 my $hasdigit = qr/\w*\d\w*/;
35 2 my $num = qr/\w+$p$hasdigit|$hasdigit$p\w+
36 |\w+($p$hasdigit$p\w+)+
37 |$hasdigit($p\w+$p$hasdigit)+
38 |\w+$p$hasdigit($p\w+$p$hasdigit)+
39 |$hasdigit$p\w+($p$hasdigit$p\w+)+/x;
40  
41 =head2 token_re
42  
43 The regular expression for tokenising.
44  
45 =cut
46  
47 0 ▶sub token_re {
Subroutine token_re: not called CC=1 SCAR=6.9
Pod documented
48 0 qr/
49 $apostrophe | $acronym | $company | $hostname | $email | $num
50 | \w+
51 /x;
52 }
53  
54 =head2 normalize
55  
56 Remove 's and .
57  
58 =cut
59  
60 1 ▶sub normalize {
Subroutine normalize: called CC=3 SCAR=12.3
Pod documented
61 1 my $class = shift;
62  
63 # These are in the StandardFilter in Java, but Perl is not Java.
64 # Thankfully.
65 1 local $_ = shift;
66 0 ▶ if (/$apostrophe/) { s/'s//; }
Branch: 1 branch
BranchTrueFalseTotal
if (/$apostrophe/) 0 1 1
67 0 ▶ if (/$company/) { s/\.//g; }
Branch: 1 branch
BranchTrueFalseTotal
if (/$company/) 0 1 1
68 1 return $_;
69 }
70  
71 2 1;
« Plucene/Search/TermScorer.pm ↑ Summary Plucene/Index/SegmentMergeInfo.pm »