| 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 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 34 | 19 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 35 | 19 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 19 | ▶ | use base 'Class::Accessor::Fast'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 19 | __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 | 1459 | ▶ | sub _cmp { | ||||||||||||||||||
|
Subroutine
_cmp: called CC=2 SCAR=6.9
| |||||||||||||||||||||
| 48 | 1459 | ▶ | ($_[0]->{field} cmp $_[1]->{field}) || ($_[0]->{text} cmp $_[1]->{text}); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 49 | } | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | 797 | ▶ | sub eq { | ||||||||||||||||||
|
Subroutine
eq: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 52 | 797 | ▶ | $_[0]->{field} eq $_[1]->{field} && $_[0]->{text} eq $_[1]->{text}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 53 | } | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 0 | ▶ | sub ne { | ||||||||||||||||||
|
Subroutine
ne: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 56 | 0 | ▶ | $_[0]->{field} ne $_[1]->{field} || $_[0]->{text} ne $_[1]->{text}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 57 | } | ||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | 46072 | ▶ | sub lt { | ||||||||||||||||||
|
Subroutine
lt: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||
| 60 | 46072 | ▶ | ($_[0]->{field} cmp $_[1]->{field} || $_[0]->{text} cmp $_[1]->{text}) < 0; | ||||||||||||||||||
|
Condition66%2/3
$_[0]{'field'} cmp $_[1]{'field'} || $_[0]{'text'} cmp $_[1]{'text'}
MC/DC0%0/2
$_[0]{'field'} cmp $_[1]{'field'} || $_[0]{'text'} cmp $_[1]{'text'}
$_[0]{'field'} cmp $_[1]{'field'}
$_[0]{'text'} cmp $_[1]{'text'}
Truth table66%2/3
A || B
A= $_[0]{'field'} cmp $_[1]{'field'}B= $_[0]{'text'} cmp $_[1]{'text'}
| |||||||||||||||||||||
| 61 | } | ||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | 39452 | ▶ | sub gt { | ||||||||||||||||||
|
Subroutine
gt: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 64 | 39452 | ▶ | ($_[0]->{field} cmp $_[1]->{field} || $_[0]->{text} cmp $_[1]->{text}) > 0; | ||||||||||||||||||
|
Condition100%3/3
$_[0]{'field'} cmp $_[1]{'field'} || $_[0]{'text'} cmp $_[1]{'text'}
MC/DC100%2/2
$_[0]{'field'} cmp $_[1]{'field'} || $_[0]{'text'} cmp $_[1]{'text'}
$_[0]{'field'} cmp $_[1]{'field'}
$_[0]{'text'} cmp $_[1]{'text'}
Truth table100%3/3
A || B
A= $_[0]{'field'} cmp $_[1]{'field'}B= $_[0]{'text'} cmp $_[1]{'text'}
| |||||||||||||||||||||
| 65 | } | ||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | 0 | ▶ | sub ge { | ||||||||||||||||||
|
Subroutine
ge: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 68 | 0 | ▶ | ($_[0]->{field} cmp $_[1]->{field} || $_[0]->{text} cmp $_[1]->{text}) >= 0; | ||||||||||||||||||
|
Condition0%0/3
$_[0]{'field'} cmp $_[1]{'field'} || $_[0]{'text'} cmp $_[1]{'text'}
MC/DC0%0/2
$_[0]{'field'} cmp $_[1]{'field'} || $_[0]{'text'} cmp $_[1]{'text'}
$_[0]{'field'} cmp $_[1]{'field'}
$_[0]{'text'} cmp $_[1]{'text'}
Truth table0%0/3
A || B
A= $_[0]{'field'} cmp $_[1]{'field'}B= $_[0]{'text'} cmp $_[1]{'text'}
| |||||||||||||||||||||
| 69 | } | ||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | 3 | ▶ | sub le { | ||||||||||||||||||
|
Subroutine
le: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||
| 72 | 3 | ▶ | ($_[0]->{field} cmp $_[1]->{field} || $_[0]->{text} cmp $_[1]->{text}) <= 0; | ||||||||||||||||||
|
Condition66%2/3
$_[0]{'field'} cmp $_[1]{'field'} || $_[0]{'text'} cmp $_[1]{'text'}
MC/DC0%0/2
$_[0]{'field'} cmp $_[1]{'field'} || $_[0]{'text'} cmp $_[1]{'text'}
$_[0]{'field'} cmp $_[1]{'field'}
$_[0]{'text'} cmp $_[1]{'text'}
Truth table66%2/3
A || B
A= $_[0]{'field'} cmp $_[1]{'field'}B= $_[0]{'text'} cmp $_[1]{'text'}
| |||||||||||||||||||||
| 73 | } | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | 19 | 1; | |||||||||||||||||||