line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plucene::Index::Term; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Plucene::Index::Term - a word from text |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my $term = Plucene::Index::Term->new({ |
10
|
|
|
|
|
|
|
field => $field_name, |
11
|
|
|
|
|
|
|
text => $text, |
12
|
|
|
|
|
|
|
}); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# with two Plucene::Index::Term objects you can do: |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
if ($term1->eq($term2)) { ... } |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# etc |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 DESCRIPTION |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
A Term represents a word from text, and is the unit of search. It is |
23
|
|
|
|
|
|
|
composed of two elements, the text of the word, as a string, and the |
24
|
|
|
|
|
|
|
name of the field that the text occured in, as a string. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Note that terms may represent more than words from text fields, but |
27
|
|
|
|
|
|
|
also things like dates, email addresses, urls, etc. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 METHODS |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
32
|
|
|
|
|
|
|
|
33
|
19
|
|
|
19
|
|
112
|
use strict; |
|
19
|
|
|
|
|
35
|
|
|
19
|
|
|
|
|
768
|
|
34
|
19
|
|
|
19
|
|
102
|
use warnings; |
|
19
|
|
|
|
|
61
|
|
|
19
|
|
|
|
|
540
|
|
35
|
19
|
|
|
19
|
|
123
|
no warnings 'uninitialized'; |
|
19
|
|
|
|
|
42
|
|
|
19
|
|
|
|
|
755
|
|
36
|
|
|
|
|
|
|
|
37
|
19
|
|
|
19
|
|
95
|
use base 'Class::Accessor::Fast'; |
|
19
|
|
|
|
|
39
|
|
|
19
|
|
|
|
|
11846
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw(field text)); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 eq / ne / lt / gt / ge / le |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Exactly what you would think they are. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub _cmp { |
48
|
1096
|
100
|
|
1096
|
|
7593
|
($_[0]->{field} cmp $_[1]->{field}) || ($_[0]->{text} cmp $_[1]->{text}); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub eq { |
52
|
635
|
100
|
|
635
|
1
|
15036
|
$_[0]->{field} eq $_[1]->{field} && $_[0]->{text} eq $_[1]->{text}; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub ne { |
56
|
0
|
0
|
|
0
|
1
|
0
|
$_[0]->{field} ne $_[1]->{field} || $_[0]->{text} ne $_[1]->{text}; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub lt { |
60
|
46072
|
|
66
|
46072
|
1
|
453845
|
($_[0]->{field} cmp $_[1]->{field} || $_[0]->{text} cmp $_[1]->{text}) < 0; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub gt { |
64
|
32324
|
|
100
|
32324
|
1
|
431220
|
($_[0]->{field} cmp $_[1]->{field} || $_[0]->{text} cmp $_[1]->{text}) > 0; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub ge { |
68
|
0
|
|
0
|
0
|
1
|
0
|
($_[0]->{field} cmp $_[1]->{field} || $_[0]->{text} cmp $_[1]->{text}) >= 0; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub le { |
72
|
3
|
|
66
|
3
|
1
|
51
|
($_[0]->{field} cmp $_[1]->{field} || $_[0]->{text} cmp $_[1]->{text}) <= 0; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |